OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include <windows.h> |
| 6 |
5 #include "skia/ext/skia_utils_win.h" | 7 #include "skia/ext/skia_utils_win.h" |
6 | 8 |
7 #include "base/logging.h" | |
8 #include "SkRect.h" | 9 #include "SkRect.h" |
9 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 COMPILE_ASSERT(offsetof(RECT, left) == offsetof(SkIRect, fLeft), o1); | 14 template <bool> |
14 COMPILE_ASSERT(offsetof(RECT, top) == offsetof(SkIRect, fTop), o2); | 15 struct CompileAssert { |
15 COMPILE_ASSERT(offsetof(RECT, right) == offsetof(SkIRect, fRight), o3); | 16 }; |
16 COMPILE_ASSERT(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), o4); | 17 |
| 18 #undef COMPILE_ASSERT |
| 19 #define COMPILE_ASSERT(expr, msg) \ |
| 20 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] |
| 21 |
| 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); |
17 COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5); | 26 COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5); |
18 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); | 27 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); |
19 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); | 28 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); |
20 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); | 29 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); |
21 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); | 30 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); |
22 | 31 |
23 } // namespace | 32 } // namespace |
24 | 33 |
25 namespace skia { | 34 namespace skia { |
26 | 35 |
(...skipping 14 matching lines...) Expand all Loading... |
41 #else | 50 #else |
42 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8) | 51 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8) |
43 return 0xFF000000u | (_byteswap_ulong(color) >> 8); | 52 return 0xFF000000u | (_byteswap_ulong(color) >> 8); |
44 #endif | 53 #endif |
45 } | 54 } |
46 | 55 |
47 COLORREF SkColorToCOLORREF(SkColor color) { | 56 COLORREF SkColorToCOLORREF(SkColor color) { |
48 // Currently, Alpha is always 255 or the color is 0 so there is no need to | 57 // Currently, Alpha is always 255 or the color is 0 so there is no need to |
49 // demultiply the channels. If this DCHECK() is ever hit, the full | 58 // demultiply the channels. If this DCHECK() is ever hit, the full |
50 // (SkColorGetX(color) * 255 / a) will have to be added in the conversion. | 59 // (SkColorGetX(color) * 255 / a) will have to be added in the conversion. |
51 DCHECK((0xFF == SkColorGetA(color)) || (0 == color)); | 60 SkASSERT((0xFF == SkColorGetA(color)) || (0 == color)); |
52 #ifndef _MSC_VER | 61 #ifndef _MSC_VER |
53 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); | 62 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); |
54 #else | 63 #else |
55 // 0BGR = ((ARGB -> BGRA) >> 8) | 64 // 0BGR = ((ARGB -> BGRA) >> 8) |
56 return (_byteswap_ulong(color) >> 8); | 65 return (_byteswap_ulong(color) >> 8); |
57 #endif | 66 #endif |
58 } | 67 } |
59 | 68 |
60 } // namespace skia | 69 } // namespace skia |
61 | 70 |
OLD | NEW |