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"
10 #include "third_party/skia/include/core/SkRect.h"
11 #include "third_party/skia/include/core/SkTypes.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h"
16 static_assert(offsetof(RECT
, left
) == offsetof(SkIRect
, fLeft
), "o1");
17 static_assert(offsetof(RECT
, top
) == offsetof(SkIRect
, fTop
), "o2");
18 static_assert(offsetof(RECT
, right
) == offsetof(SkIRect
, fRight
), "o3");
19 static_assert(offsetof(RECT
, bottom
) == offsetof(SkIRect
, fBottom
), "o4");
20 static_assert(sizeof(RECT().left
) == sizeof(SkIRect().fLeft
), "o5");
21 static_assert(sizeof(RECT().top
) == sizeof(SkIRect().fTop
), "o6");
22 static_assert(sizeof(RECT().right
) == sizeof(SkIRect().fRight
), "o7");
23 static_assert(sizeof(RECT().bottom
) == sizeof(SkIRect().fBottom
), "o8");
24 static_assert(sizeof(RECT
) == sizeof(SkIRect
), "o9");
30 POINT
SkPointToPOINT(const SkPoint
& point
) {
32 SkScalarRoundToInt(point
.fX
), SkScalarRoundToInt(point
.fY
)
37 SkRect
RECTToSkRect(const RECT
& rect
) {
38 SkRect sk_rect
= { SkIntToScalar(rect
.left
), SkIntToScalar(rect
.top
),
39 SkIntToScalar(rect
.right
), SkIntToScalar(rect
.bottom
) };
43 SkColor
COLORREFToSkColor(COLORREF color
) {
45 return SkColorSetRGB(GetRValue(color
), GetGValue(color
), GetBValue(color
));
47 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8)
48 return 0xFF000000u
| (_byteswap_ulong(color
) >> 8);
52 COLORREF
SkColorToCOLORREF(SkColor color
) {
54 return RGB(SkColorGetR(color
), SkColorGetG(color
), SkColorGetB(color
));
56 // 0BGR = ((ARGB -> BGRA) >> 8)
57 return (_byteswap_ulong(color
) >> 8);