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/platform_device_win.h" | 5 #include "skia/ext/platform_device.h" |
6 | 6 |
7 #include "skia/ext/skia_utils_win.h" | 7 #include "skia/ext/skia_utils_win.h" |
8 #include "third_party/skia/include/core/SkMatrix.h" | 8 #include "third_party/skia/include/core/SkMatrix.h" |
9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
10 #include "third_party/skia/include/core/SkRegion.h" | 10 #include "third_party/skia/include/core/SkRegion.h" |
11 #include "third_party/skia/include/core/SkUtils.h" | 11 #include "third_party/skia/include/core/SkUtils.h" |
12 | 12 |
13 namespace skia { | 13 namespace skia { |
14 | 14 |
15 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) | 15 void InitializeDC(HDC context) { |
16 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { | |
17 } | |
18 | |
19 void PlatformDevice::EndPlatformPaint() { | |
20 // We don't clear the DC here since it will be likely to be used again. | |
21 // Flushing will be done in onAccessBitmap. | |
22 } | |
23 | |
24 // static | |
25 void PlatformDevice::InitializeDC(HDC context) { | |
26 // Enables world transformation. | 16 // Enables world transformation. |
27 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the | 17 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the |
28 // counterclockwise direction in logical space. This is equivalent to the | 18 // counterclockwise direction in logical space. This is equivalent to the |
29 // statement that, in the GM_ADVANCED graphics mode, both arc control points | 19 // statement that, in the GM_ADVANCED graphics mode, both arc control points |
30 // and arcs themselves fully respect the device context's world-to-device | 20 // and arcs themselves fully respect the device context's world-to-device |
31 // transformation. | 21 // transformation. |
32 BOOL res = SetGraphicsMode(context, GM_ADVANCED); | 22 BOOL res = SetGraphicsMode(context, GM_ADVANCED); |
33 SkASSERT(res != 0); | 23 SkASSERT(res != 0); |
34 | 24 |
35 // Enables dithering. | 25 // Enables dithering. |
(...skipping 18 matching lines...) Expand all Loading... |
54 res = SetDCPenColor(context, RGB(0, 0, 0)); | 44 res = SetDCPenColor(context, RGB(0, 0, 0)); |
55 SkASSERT(res != CLR_INVALID); | 45 SkASSERT(res != CLR_INVALID); |
56 | 46 |
57 // Sets up default transparency. | 47 // Sets up default transparency. |
58 res = SetBkMode(context, OPAQUE); | 48 res = SetBkMode(context, OPAQUE); |
59 SkASSERT(res != 0); | 49 SkASSERT(res != 0); |
60 res = SetROP2(context, R2_COPYPEN); | 50 res = SetROP2(context, R2_COPYPEN); |
61 SkASSERT(res != 0); | 51 SkASSERT(res != 0); |
62 } | 52 } |
63 | 53 |
| 54 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) |
| 55 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { |
| 56 SetPlatformDevice(this, this); |
| 57 } |
| 58 |
| 59 void PlatformDevice::EndPlatformPaint() { |
| 60 // We don't clear the DC here since it will be likely to be used again. |
| 61 // Flushing will be done in onAccessBitmap. |
| 62 } |
| 63 |
64 // static | 64 // static |
65 void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) { | 65 void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) { |
66 switch (path.getFillType()) { | 66 switch (path.getFillType()) { |
67 case SkPath::kWinding_FillType: { | 67 case SkPath::kWinding_FillType: { |
68 int res = SetPolyFillMode(context, WINDING); | 68 int res = SetPolyFillMode(context, WINDING); |
69 SkASSERT(res != 0); | 69 SkASSERT(res != 0); |
70 break; | 70 break; |
71 } | 71 } |
72 case SkPath::kEvenOdd_FillType: { | 72 case SkPath::kEvenOdd_FillType: { |
73 int res = SetPolyFillMode(context, ALTERNATE); | 73 int res = SetPolyFillMode(context, ALTERNATE); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 hrgn = PathToRegion(context); | 224 hrgn = PathToRegion(context); |
225 } | 225 } |
226 int result = SelectClipRgn(context, hrgn); | 226 int result = SelectClipRgn(context, hrgn); |
227 SkASSERT(result != ERROR); | 227 SkASSERT(result != ERROR); |
228 result = DeleteObject(hrgn); | 228 result = DeleteObject(hrgn); |
229 SkASSERT(result != 0); | 229 SkASSERT(result != 0); |
230 } | 230 } |
231 | 231 |
232 } // namespace skia | 232 } // namespace skia |
233 | 233 |
OLD | NEW |