Roll leveldb from r73 to r75.
[chromium-blink-merge.git] / skia / ext / skia_utils_win.cc
blob8b72b986b58be0b85572e33d5c74c7e0e7bc7317
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"
7 #include <windows.h>
9 #include "third_party/skia/include/core/SkRect.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h"
12 namespace {
14 template <bool>
15 struct CompileAssert {
18 #undef COMPILE_ASSERT
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);
32 } // namespace
34 namespace skia {
36 POINT SkPointToPOINT(const SkPoint& point) {
37 POINT win_point = { SkScalarRound(point.fX), SkScalarRound(point.fY) };
38 return win_point;
41 SkRect RECTToSkRect(const RECT& rect) {
42 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top),
43 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) };
44 return sk_rect;
47 SkColor COLORREFToSkColor(COLORREF color) {
48 #ifndef _MSC_VER
49 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color));
50 #else
51 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8)
52 return 0xFF000000u | (_byteswap_ulong(color) >> 8);
53 #endif
56 COLORREF SkColorToCOLORREF(SkColor color) {
57 #ifndef _MSC_VER
58 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
59 #else
60 // 0BGR = ((ARGB -> BGRA) >> 8)
61 return (_byteswap_ulong(color) >> 8);
62 #endif
65 } // namespace skia