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

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

Issue 125109: Refactor the PlatformContext layer to have only one class. (Closed)
Patch Set: Created 11 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
« no previous file with comments | « skia/ext/platform_device_win.h ('k') | skia/ext/vector_canvas.h » ('j') | 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/platform_device_win.h" 5 #include "skia/ext/platform_device_win.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 PlatformDeviceWin::PlatformDeviceWin(const SkBitmap& bitmap) 15 PlatformDevice::PlatformDevice(const SkBitmap& bitmap)
16 : SkDevice(bitmap) { 16 : SkDevice(bitmap) {
17 } 17 }
18 18
19 // static 19 // static
20 void PlatformDeviceWin::InitializeDC(HDC context) { 20 void PlatformDevice::InitializeDC(HDC context) {
21 // Enables world transformation. 21 // Enables world transformation.
22 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the 22 // If the GM_ADVANCED graphics mode is set, GDI always draws arcs in the
23 // counterclockwise direction in logical space. This is equivalent to the 23 // counterclockwise direction in logical space. This is equivalent to the
24 // statement that, in the GM_ADVANCED graphics mode, both arc control points 24 // statement that, in the GM_ADVANCED graphics mode, both arc control points
25 // and arcs themselves fully respect the device context's world-to-device 25 // and arcs themselves fully respect the device context's world-to-device
26 // transformation. 26 // transformation.
27 BOOL res = SetGraphicsMode(context, GM_ADVANCED); 27 BOOL res = SetGraphicsMode(context, GM_ADVANCED);
28 SkASSERT(res != 0); 28 SkASSERT(res != 0);
29 29
30 // Enables dithering. 30 // Enables dithering.
(...skipping 19 matching lines...) Expand all
50 SkASSERT(res != CLR_INVALID); 50 SkASSERT(res != CLR_INVALID);
51 51
52 // Sets up default transparency. 52 // Sets up default transparency.
53 res = SetBkMode(context, OPAQUE); 53 res = SetBkMode(context, OPAQUE);
54 SkASSERT(res != 0); 54 SkASSERT(res != 0);
55 res = SetROP2(context, R2_COPYPEN); 55 res = SetROP2(context, R2_COPYPEN);
56 SkASSERT(res != 0); 56 SkASSERT(res != 0);
57 } 57 }
58 58
59 // static 59 // static
60 void PlatformDeviceWin::LoadPathToDC(HDC context, const SkPath& path) { 60 void PlatformDevice::LoadPathToDC(HDC context, const SkPath& path) {
61 switch (path.getFillType()) { 61 switch (path.getFillType()) {
62 case SkPath::kWinding_FillType: { 62 case SkPath::kWinding_FillType: {
63 int res = SetPolyFillMode(context, WINDING); 63 int res = SetPolyFillMode(context, WINDING);
64 SkASSERT(res != 0); 64 SkASSERT(res != 0);
65 break; 65 break;
66 } 66 }
67 case SkPath::kEvenOdd_FillType: { 67 case SkPath::kEvenOdd_FillType: {
68 int res = SetPolyFillMode(context, ALTERNATE); 68 int res = SetPolyFillMode(context, ALTERNATE);
69 SkASSERT(res != 0); 69 SkASSERT(res != 0);
70 break; 70 break;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (res == 0) { 110 if (res == 0) {
111 // Make sure the path is discarded. 111 // Make sure the path is discarded.
112 AbortPath(context); 112 AbortPath(context);
113 } else { 113 } else {
114 res = EndPath(context); 114 res = EndPath(context);
115 SkASSERT(res != 0); 115 SkASSERT(res != 0);
116 } 116 }
117 } 117 }
118 118
119 // static 119 // static
120 void PlatformDeviceWin::LoadTransformToDC(HDC dc, const SkMatrix& matrix) { 120 void PlatformDevice::LoadTransformToDC(HDC dc, const SkMatrix& matrix) {
121 XFORM xf; 121 XFORM xf;
122 xf.eM11 = matrix[SkMatrix::kMScaleX]; 122 xf.eM11 = matrix[SkMatrix::kMScaleX];
123 xf.eM21 = matrix[SkMatrix::kMSkewX]; 123 xf.eM21 = matrix[SkMatrix::kMSkewX];
124 xf.eDx = matrix[SkMatrix::kMTransX]; 124 xf.eDx = matrix[SkMatrix::kMTransX];
125 xf.eM12 = matrix[SkMatrix::kMSkewY]; 125 xf.eM12 = matrix[SkMatrix::kMSkewY];
126 xf.eM22 = matrix[SkMatrix::kMScaleY]; 126 xf.eM22 = matrix[SkMatrix::kMScaleY];
127 xf.eDy = matrix[SkMatrix::kMTransY]; 127 xf.eDy = matrix[SkMatrix::kMTransY];
128 SetWorldTransform(dc, &xf); 128 SetWorldTransform(dc, &xf);
129 } 129 }
130 130
131 // static 131 // static
132 bool PlatformDeviceWin::SkPathToCubicPaths(CubicPaths* paths, 132 bool PlatformDevice::SkPathToCubicPaths(CubicPaths* paths,
133 const SkPath& skpath) { 133 const SkPath& skpath) {
134 paths->clear(); 134 paths->clear();
135 CubicPath* current_path = NULL; 135 CubicPath* current_path = NULL;
136 SkPoint current_points[4]; 136 SkPoint current_points[4];
137 CubicPoints points_to_add; 137 CubicPoints points_to_add;
138 SkPath::Iter iter(skpath, false); 138 SkPath::Iter iter(skpath, false);
139 for (SkPath::Verb verb = iter.next(current_points); 139 for (SkPath::Verb verb = iter.next(current_points);
140 verb != SkPath::kDone_Verb; 140 verb != SkPath::kDone_Verb;
141 verb = iter.next(current_points)) { 141 verb = iter.next(current_points)) {
142 switch (verb) { 142 switch (verb) {
143 case SkPath::kMove_Verb: { // iter.next returns 1 point 143 case SkPath::kMove_Verb: { // iter.next returns 1 point
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (!current_path) { 185 if (!current_path) {
186 paths->clear(); 186 paths->clear();
187 return false; 187 return false;
188 } 188 }
189 current_path->push_back(points_to_add); 189 current_path->push_back(points_to_add);
190 } 190 }
191 return true; 191 return true;
192 } 192 }
193 193
194 // static 194 // static
195 void PlatformDeviceWin::LoadClippingRegionToDC(HDC context, 195 void PlatformDevice::LoadClippingRegionToDC(HDC context,
196 const SkRegion& region, 196 const SkRegion& region,
197 const SkMatrix& transformation) { 197 const SkMatrix& transformation) {
198 HRGN hrgn; 198 HRGN hrgn;
199 if (region.isEmpty()) { 199 if (region.isEmpty()) {
200 // region can be empty, in which case everything will be clipped. 200 // region can be empty, in which case everything will be clipped.
201 hrgn = CreateRectRgn(0, 0, 0, 0); 201 hrgn = CreateRectRgn(0, 0, 0, 0);
202 } else if (region.isRect()) { 202 } else if (region.isRect()) {
203 // We don't apply transformation, because the translation is already applied 203 // We don't apply transformation, because the translation is already applied
204 // to the region. 204 // to the region.
205 hrgn = CreateRectRgnIndirect(&SkIRectToRECT(region.getBounds())); 205 hrgn = CreateRectRgnIndirect(&SkIRectToRECT(region.getBounds()));
206 } else { 206 } else {
207 // It is complex. 207 // It is complex.
(...skipping 11 matching lines...) Expand all
219 hrgn = PathToRegion(context); 219 hrgn = PathToRegion(context);
220 } 220 }
221 int result = SelectClipRgn(context, hrgn); 221 int result = SelectClipRgn(context, hrgn);
222 SkASSERT(result != ERROR); 222 SkASSERT(result != ERROR);
223 result = DeleteObject(hrgn); 223 result = DeleteObject(hrgn);
224 SkASSERT(result != 0); 224 SkASSERT(result != 0);
225 } 225 }
226 226
227 } // namespace skia 227 } // namespace skia
228 228
OLDNEW
« no previous file with comments | « skia/ext/platform_device_win.h ('k') | skia/ext/vector_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698