Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: skia/ext/skia_utils_win.cc

Issue 343433008: Use standard compile asserts and offsetof in skia_utils_win.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h>
7 #include <windows.h> 8 #include <windows.h>
8 9
9 #include "third_party/skia/include/core/SkRect.h" 10 #include "third_party/skia/include/core/SkRect.h"
11 #include "third_party/skia/include/core/SkTypes.h"
10 #include "third_party/skia/include/effects/SkGradientShader.h" 12 #include "third_party/skia/include/effects/SkGradientShader.h"
11 13
12 namespace { 14 namespace {
13 15
14 template <bool> 16 SK_COMPILE_ASSERT(offsetof(RECT, left) == offsetof(SkIRect, fLeft), o1);
15 struct CompileAssert { 17 SK_COMPILE_ASSERT(offsetof(RECT, top) == offsetof(SkIRect, fTop), o2);
16 }; 18 SK_COMPILE_ASSERT(offsetof(RECT, right) == offsetof(SkIRect, fRight), o3);
17 19 SK_COMPILE_ASSERT(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), o4);
18 #undef COMPILE_ASSERT 20 SK_COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5);
19 #define COMPILE_ASSERT(expr, msg) \ 21 SK_COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6);
20 typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] 22 SK_COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7);
21 23 SK_COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8);
22 COMPILE_ASSERT(SK_OFFSETOF(RECT, left) == SK_OFFSETOF(SkIRect, fLeft), o1); 24 SK_COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9);
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);
31 25
32 } // namespace 26 } // namespace
33 27
34 namespace skia { 28 namespace skia {
35 29
36 POINT SkPointToPOINT(const SkPoint& point) { 30 POINT SkPointToPOINT(const SkPoint& point) {
37 POINT win_point = { 31 POINT win_point = {
38 SkScalarRoundToInt(point.fX), SkScalarRoundToInt(point.fY) 32 SkScalarRoundToInt(point.fX), SkScalarRoundToInt(point.fY)
39 }; 33 };
40 return win_point; 34 return win_point;
(...skipping 18 matching lines...) Expand all
59 #ifndef _MSC_VER 53 #ifndef _MSC_VER
60 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); 54 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
61 #else 55 #else
62 // 0BGR = ((ARGB -> BGRA) >> 8) 56 // 0BGR = ((ARGB -> BGRA) >> 8)
63 return (_byteswap_ulong(color) >> 8); 57 return (_byteswap_ulong(color) >> 8);
64 #endif 58 #endif
65 } 59 }
66 60
67 } // namespace skia 61 } // namespace skia
68 62
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698