1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "skia/ext/skia_utils_win.h"
9 #include "third_party/skia/include/core/SkRect.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h"
15 struct CompileAssert
{
19 #define COMPILE_ASSERT(expr, msg) \
20 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
22 COMPILE_ASSERT(SK_OFFSETOF(RECT
, left
) == SK_OFFSETOF(SkIRect
, fLeft
), o1
);
23 COMPILE_ASSERT(SK_OFFSETOF(RECT
, top
) == SK_OFFSETOF(SkIRect
, fTop
), o2
);
24 COMPILE_ASSERT(SK_OFFSETOF(RECT
, right
) == SK_OFFSETOF(SkIRect
, fRight
), o3
);
25 COMPILE_ASSERT(SK_OFFSETOF(RECT
, bottom
) == SK_OFFSETOF(SkIRect
, fBottom
), o4
);
26 COMPILE_ASSERT(sizeof(RECT().left
) == sizeof(SkIRect().fLeft
), o5
);
27 COMPILE_ASSERT(sizeof(RECT().top
) == sizeof(SkIRect().fTop
), o6
);
28 COMPILE_ASSERT(sizeof(RECT().right
) == sizeof(SkIRect().fRight
), o7
);
29 COMPILE_ASSERT(sizeof(RECT().bottom
) == sizeof(SkIRect().fBottom
), o8
);
30 COMPILE_ASSERT(sizeof(RECT
) == sizeof(SkIRect
), o9
);
36 POINT
SkPointToPOINT(const SkPoint
& point
) {
37 POINT win_point
= { SkScalarRound(point
.fX
), SkScalarRound(point
.fY
) };
41 SkRect
RECTToSkRect(const RECT
& rect
) {
42 SkRect sk_rect
= { SkIntToScalar(rect
.left
), SkIntToScalar(rect
.top
),
43 SkIntToScalar(rect
.right
), SkIntToScalar(rect
.bottom
) };
47 SkColor
COLORREFToSkColor(COLORREF color
) {
49 return SkColorSetRGB(GetRValue(color
), GetGValue(color
), GetBValue(color
));
51 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8)
52 return 0xFF000000u
| (_byteswap_ulong(color
) >> 8);
56 COLORREF
SkColorToCOLORREF(SkColor color
) {
58 return RGB(SkColorGetR(color
), SkColorGetG(color
), SkColorGetB(color
));
60 // 0BGR = ((ARGB -> BGRA) >> 8)
61 return (_byteswap_ulong(color
) >> 8);