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 SK_COMPILE_ASSERT(offsetof(RECT
, left
) == offsetof(SkIRect
, fLeft
), o1
);
17 SK_COMPILE_ASSERT(offsetof(RECT
, top
) == offsetof(SkIRect
, fTop
), o2
);
18 SK_COMPILE_ASSERT(offsetof(RECT
, right
) == offsetof(SkIRect
, fRight
), o3
);
19 SK_COMPILE_ASSERT(offsetof(RECT
, bottom
) == offsetof(SkIRect
, fBottom
), o4
);
20 SK_COMPILE_ASSERT(sizeof(RECT().left
) == sizeof(SkIRect().fLeft
), o5
);
21 SK_COMPILE_ASSERT(sizeof(RECT().top
) == sizeof(SkIRect().fTop
), o6
);
22 SK_COMPILE_ASSERT(sizeof(RECT().right
) == sizeof(SkIRect().fRight
), o7
);
23 SK_COMPILE_ASSERT(sizeof(RECT().bottom
) == sizeof(SkIRect().fBottom
), o8
);
24 SK_COMPILE_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);