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 <stddef.h> | 7 #include <stddef.h> |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "third_party/skia/include/core/SkRect.h" | 10 #include "third_party/skia/include/core/SkRect.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 COLORREF SkColorToCOLORREF(SkColor color) { | 52 COLORREF SkColorToCOLORREF(SkColor color) { |
53 #ifndef _MSC_VER | 53 #ifndef _MSC_VER |
54 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); | 54 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); |
55 #else | 55 #else |
56 // 0BGR = ((ARGB -> BGRA) >> 8) | 56 // 0BGR = ((ARGB -> BGRA) >> 8) |
57 return (_byteswap_ulong(color) >> 8); | 57 return (_byteswap_ulong(color) >> 8); |
58 #endif | 58 #endif |
59 } | 59 } |
60 | 60 |
| 61 void InitializeDC(HDC context) { |
| 62 // Enables world transformation. |
| 63 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the |
| 64 // counterclockwise direction in logical space. This is equivalent to the |
| 65 // statement that, in the GM_ADVANCED graphics mode, both arc control points |
| 66 // and arcs themselves fully respect the device context's world-to-device |
| 67 // transformation. |
| 68 BOOL res = SetGraphicsMode(context, GM_ADVANCED); |
| 69 SkASSERT(res != 0); |
| 70 |
| 71 // Enables dithering. |
| 72 res = SetStretchBltMode(context, HALFTONE); |
| 73 SkASSERT(res != 0); |
| 74 // As per SetStretchBltMode() documentation, SetBrushOrgEx() must be called |
| 75 // right after. |
| 76 res = SetBrushOrgEx(context, 0, 0, NULL); |
| 77 SkASSERT(res != 0); |
| 78 |
| 79 // Sets up default orientation. |
| 80 res = SetArcDirection(context, AD_CLOCKWISE); |
| 81 SkASSERT(res != 0); |
| 82 |
| 83 // Sets up default colors. |
| 84 res = SetBkColor(context, RGB(255, 255, 255)); |
| 85 SkASSERT(res != CLR_INVALID); |
| 86 res = SetTextColor(context, RGB(0, 0, 0)); |
| 87 SkASSERT(res != CLR_INVALID); |
| 88 res = SetDCBrushColor(context, RGB(255, 255, 255)); |
| 89 SkASSERT(res != CLR_INVALID); |
| 90 res = SetDCPenColor(context, RGB(0, 0, 0)); |
| 91 SkASSERT(res != CLR_INVALID); |
| 92 |
| 93 // Sets up default transparency. |
| 94 res = SetBkMode(context, OPAQUE); |
| 95 SkASSERT(res != 0); |
| 96 res = SetROP2(context, R2_COPYPEN); |
| 97 SkASSERT(res != 0); |
| 98 } |
| 99 |
61 } // namespace skia | 100 } // namespace skia |
62 | 101 |
OLD | NEW |