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 "skia/ext/skia_utils_win.h" | 5 #include "skia/ext/skia_utils_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "third_party/skia/include/core/SkRect.h" | 9 #include "third_party/skia/include/core/SkRect.h" |
10 #include "third_party/skia/include/effects/SkGradientShader.h" | 10 #include "third_party/skia/include/effects/SkGradientShader.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); | 27 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); |
28 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); | 28 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); |
29 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); | 29 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); |
30 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); | 30 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 namespace skia { | 34 namespace skia { |
35 | 35 |
36 POINT SkPointToPOINT(const SkPoint& point) { | 36 POINT SkPointToPOINT(const SkPoint& point) { |
37 POINT win_point = { SkScalarRound(point.fX), SkScalarRound(point.fY) }; | 37 POINT win_point = { |
| 38 SkScalarRoundToInt(point.fX), SkScalarRoundToInt(point.fY) |
| 39 }; |
38 return win_point; | 40 return win_point; |
39 } | 41 } |
40 | 42 |
41 SkRect RECTToSkRect(const RECT& rect) { | 43 SkRect RECTToSkRect(const RECT& rect) { |
42 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top), | 44 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top), |
43 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) }; | 45 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) }; |
44 return sk_rect; | 46 return sk_rect; |
45 } | 47 } |
46 | 48 |
47 SkColor COLORREFToSkColor(COLORREF color) { | 49 SkColor COLORREFToSkColor(COLORREF color) { |
48 #ifndef _MSC_VER | 50 #ifndef _MSC_VER |
49 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); | 51 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); |
50 #else | 52 #else |
51 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8) | 53 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8) |
52 return 0xFF000000u | (_byteswap_ulong(color) >> 8); | 54 return 0xFF000000u | (_byteswap_ulong(color) >> 8); |
53 #endif | 55 #endif |
54 } | 56 } |
55 | 57 |
56 COLORREF SkColorToCOLORREF(SkColor color) { | 58 COLORREF SkColorToCOLORREF(SkColor color) { |
57 #ifndef _MSC_VER | 59 #ifndef _MSC_VER |
58 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); | 60 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); |
59 #else | 61 #else |
60 // 0BGR = ((ARGB -> BGRA) >> 8) | 62 // 0BGR = ((ARGB -> BGRA) >> 8) |
61 return (_byteswap_ulong(color) >> 8); | 63 return (_byteswap_ulong(color) >> 8); |
62 #endif | 64 #endif |
63 } | 65 } |
64 | 66 |
65 } // namespace skia | 67 } // namespace skia |
66 | 68 |
OLD | NEW |