| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "SkRect.h" | 8 #include "SkRect.h" |
| 9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 COMPILE_ASSERT(offsetof(RECT, left) == offsetof(SkIRect, fLeft), o1); | 13 COMPILE_ASSERT(offsetof(RECT, left) == offsetof(SkIRect, fLeft), o1); |
| 14 COMPILE_ASSERT(offsetof(RECT, top) == offsetof(SkIRect, fTop), o2); | 14 COMPILE_ASSERT(offsetof(RECT, top) == offsetof(SkIRect, fTop), o2); |
| 15 COMPILE_ASSERT(offsetof(RECT, right) == offsetof(SkIRect, fRight), o3); | 15 COMPILE_ASSERT(offsetof(RECT, right) == offsetof(SkIRect, fRight), o3); |
| 16 COMPILE_ASSERT(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), o4); | 16 COMPILE_ASSERT(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), o4); |
| 17 COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5); | 17 COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5); |
| 18 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); | 18 COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); |
| 19 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); | 19 COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); |
| 20 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); | 20 COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); |
| 21 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); | 21 COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace gfx { | 25 namespace skia { |
| 26 | 26 |
| 27 POINT SkPointToPOINT(const SkPoint& point) { | 27 POINT SkPointToPOINT(const SkPoint& point) { |
| 28 POINT win_point = { SkScalarRound(point.fX), SkScalarRound(point.fY) }; | 28 POINT win_point = { SkScalarRound(point.fX), SkScalarRound(point.fY) }; |
| 29 return win_point; | 29 return win_point; |
| 30 } | 30 } |
| 31 | 31 |
| 32 SkRect RECTToSkRect(const RECT& rect) { | 32 SkRect RECTToSkRect(const RECT& rect) { |
| 33 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top), | 33 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top), |
| 34 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) }; | 34 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) }; |
| 35 return sk_rect; | 35 return sk_rect; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 // (SkColorGetX(color) * 255 / a) will have to be added in the conversion. | 50 // (SkColorGetX(color) * 255 / a) will have to be added in the conversion. |
| 51 DCHECK((0xFF == SkColorGetA(color)) || (0 == color)); | 51 DCHECK((0xFF == SkColorGetA(color)) || (0 == color)); |
| 52 #ifndef _MSC_VER | 52 #ifndef _MSC_VER |
| 53 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); | 53 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); |
| 54 #else | 54 #else |
| 55 // 0BGR = ((ARGB -> BGRA) >> 8) | 55 // 0BGR = ((ARGB -> BGRA) >> 8) |
| 56 return (_byteswap_ulong(color) >> 8); | 56 return (_byteswap_ulong(color) >> 8); |
| 57 #endif | 57 #endif |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace gfx | 60 } // namespace skia |
| 61 | 61 |
| OLD | NEW |