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

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

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove unnecessary headers. Created 9 years, 7 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
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/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 namespace platform_util {
16 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { 16
17 void DrawToHDC(SkDevice* device, HDC dc, int x, int y, const RECT* src_rect) {
18 PlatformDevice* platform_device = GetPlatformDevice(device);
19 if (platform_device)
20 platform_device->drawToHDC(dc, x, y, src_rect);
17 } 21 }
18 22
19 void PlatformDevice::EndPlatformPaint() { 23 void MakeOpaque(SkDevice* device, int x, int y, int width, int height) {
20 // We don't clear the DC here since it will be likely to be used again. 24 PlatformDevice* platform_device = GetPlatformDevice(device);
21 // Flushing will be done in onAccessBitmap. 25 if (platform_device)
26 platform_device->makeOpaque(x, y, width, height);
22 } 27 }
23 28
24 // static 29 void InitializeDC(HDC context) {
25 void PlatformDevice::InitializeDC(HDC context) {
26 // Enables world transformation. 30 // Enables world transformation.
27 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the 31 // 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 32 // counterclockwise direction in logical space. This is equivalent to the
29 // statement that, in the GM_ADVANCED graphics mode, both arc control points 33 // 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 34 // and arcs themselves fully respect the device context's world-to-device
31 // transformation. 35 // transformation.
32 BOOL res = SetGraphicsMode(context, GM_ADVANCED); 36 BOOL res = SetGraphicsMode(context, GM_ADVANCED);
33 SkASSERT(res != 0); 37 SkASSERT(res != 0);
34 38
35 // Enables dithering. 39 // Enables dithering.
(...skipping 18 matching lines...) Expand all
54 res = SetDCPenColor(context, RGB(0, 0, 0)); 58 res = SetDCPenColor(context, RGB(0, 0, 0));
55 SkASSERT(res != CLR_INVALID); 59 SkASSERT(res != CLR_INVALID);
56 60
57 // Sets up default transparency. 61 // Sets up default transparency.
58 res = SetBkMode(context, OPAQUE); 62 res = SetBkMode(context, OPAQUE);
59 SkASSERT(res != 0); 63 SkASSERT(res != 0);
60 res = SetROP2(context, R2_COPYPEN); 64 res = SetROP2(context, R2_COPYPEN);
61 SkASSERT(res != 0); 65 SkASSERT(res != 0);
62 } 66 }
63 67
68 } // namespace platform_util
69
70 PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
71 : SkDevice(NULL, bitmap, /*isForLayer=*/false) {
72 platform_util::SetPlatformDevice(this, this);
73 }
74
75 void PlatformDevice::EndPlatformPaint() {
76 // We don't clear the DC here since it will be likely to be used again.
77 // Flushing will be done in onAccessBitmap.
78 }
79
64 // static 80 // static
65 void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) { 81 void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) {
66 switch (path.getFillType()) { 82 switch (path.getFillType()) {
67 case SkPath::kWinding_FillType: { 83 case SkPath::kWinding_FillType: {
68 int res = SetPolyFillMode(context, WINDING); 84 int res = SetPolyFillMode(context, WINDING);
69 SkASSERT(res != 0); 85 SkASSERT(res != 0);
70 break; 86 break;
71 } 87 }
72 case SkPath::kEvenOdd_FillType: { 88 case SkPath::kEvenOdd_FillType: {
73 int res = SetPolyFillMode(context, ALTERNATE); 89 int res = SetPolyFillMode(context, ALTERNATE);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 hrgn = PathToRegion(context); 240 hrgn = PathToRegion(context);
225 } 241 }
226 int result = SelectClipRgn(context, hrgn); 242 int result = SelectClipRgn(context, hrgn);
227 SkASSERT(result != ERROR); 243 SkASSERT(result != ERROR);
228 result = DeleteObject(hrgn); 244 result = DeleteObject(hrgn);
229 SkASSERT(result != 0); 245 SkASSERT(result != 0);
230 } 246 }
231 247
232 } // namespace skia 248 } // namespace skia
233 249
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698