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

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

Issue 6691067: Fixed a few styles issues in skia::PlatformDevice. Made function names consistent. Added Begin/En... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 6
7 #include "skia/ext/vector_platform_device_emf_win.h" 7 #include "skia/ext/vector_platform_device_emf_win.h"
8 8
9 #include "skia/ext/bitmap_platform_device.h" 9 #include "skia/ext/bitmap_platform_device.h"
10 #include "skia/ext/skia_utils_win.h" 10 #include "skia/ext/skia_utils_win.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 previous_pen_(NULL), 108 previous_pen_(NULL),
109 alpha_blend_used_(false) { 109 alpha_blend_used_(false) {
110 transform_.reset(); 110 transform_.reset();
111 } 111 }
112 112
113 VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() { 113 VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() {
114 SkASSERT(previous_brush_ == NULL); 114 SkASSERT(previous_brush_ == NULL);
115 SkASSERT(previous_pen_ == NULL); 115 SkASSERT(previous_pen_ == NULL);
116 } 116 }
117 117
118 HDC VectorPlatformDeviceEmf::BeginPlatformPaint() {
119 return hdc_;
120 }
118 121
119 void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw, 122 void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw,
120 const SkPaint& paint) { 123 const SkPaint& paint) {
121 // TODO(maruel): Bypass the current transformation matrix. 124 // TODO(maruel): Bypass the current transformation matrix.
122 SkRect rect; 125 SkRect rect;
123 rect.fLeft = 0; 126 rect.fLeft = 0;
124 rect.fTop = 0; 127 rect.fTop = 0;
125 rect.fRight = SkIntToScalar(width() + 1); 128 rect.fRight = SkIntToScalar(width() + 1);
126 rect.fBottom = SkIntToScalar(height() + 1); 129 rect.fBottom = SkIntToScalar(height() + 1);
127 drawRect(draw, rect, paint); 130 drawRect(draw, rect, paint);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SkSafeUnref(paint_no_effet.setPathEffect(NULL)); 190 SkSafeUnref(paint_no_effet.setPathEffect(NULL));
188 191
189 // Draw the calculated path. 192 // Draw the calculated path.
190 drawPath(draw, path_modified, paint_no_effet); 193 drawPath(draw, path_modified, paint_no_effet);
191 return; 194 return;
192 } 195 }
193 196
194 if (!ApplyPaint(paint)) { 197 if (!ApplyPaint(paint)) {
195 return; 198 return;
196 } 199 }
197 HDC dc = beginPlatformPaint(); 200 HDC dc = BeginPlatformPaint();
198 if (!Rectangle(dc, SkScalarRound(rect.fLeft), 201 if (!Rectangle(dc, SkScalarRound(rect.fLeft),
199 SkScalarRound(rect.fTop), 202 SkScalarRound(rect.fTop),
200 SkScalarRound(rect.fRight), 203 SkScalarRound(rect.fRight),
201 SkScalarRound(rect.fBottom))) { 204 SkScalarRound(rect.fBottom))) {
202 SkASSERT(false); 205 SkASSERT(false);
203 } 206 }
204 endPlatformPaint(); 207 EndPlatformPaint();
205 Cleanup(); 208 Cleanup();
206 } 209 }
207 210
208 void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, 211 void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw,
209 const SkPath& path, 212 const SkPath& path,
210 const SkPaint& paint, 213 const SkPaint& paint,
211 const SkMatrix* prePathMatrix, 214 const SkMatrix* prePathMatrix,
212 bool pathIsMutable) { 215 bool pathIsMutable) {
213 if (paint.getPathEffect()) { 216 if (paint.getPathEffect()) {
214 // Apply the path effect forehand. 217 // Apply the path effect forehand.
215 SkPath path_modified; 218 SkPath path_modified;
216 paint.getFillPath(path, &path_modified); 219 paint.getFillPath(path, &path_modified);
217 220
218 // Removes the path effect from the temporary SkPaint object. 221 // Removes the path effect from the temporary SkPaint object.
219 SkPaint paint_no_effet(paint); 222 SkPaint paint_no_effet(paint);
220 SkSafeUnref(paint_no_effet.setPathEffect(NULL)); 223 SkSafeUnref(paint_no_effet.setPathEffect(NULL));
221 224
222 // Draw the calculated path. 225 // Draw the calculated path.
223 drawPath(draw, path_modified, paint_no_effet); 226 drawPath(draw, path_modified, paint_no_effet);
224 return; 227 return;
225 } 228 }
226 229
227 if (!ApplyPaint(paint)) { 230 if (!ApplyPaint(paint)) {
228 return; 231 return;
229 } 232 }
230 HDC dc = beginPlatformPaint(); 233 HDC dc = BeginPlatformPaint();
231 PlatformDevice::LoadPathToDC(dc, path); 234 PlatformDevice::LoadPathToDC(dc, path);
232 switch (paint.getStyle()) { 235 switch (paint.getStyle()) {
233 case SkPaint::kFill_Style: { 236 case SkPaint::kFill_Style: {
234 BOOL res = StrokeAndFillPath(dc); 237 BOOL res = StrokeAndFillPath(dc);
235 SkASSERT(res != 0); 238 SkASSERT(res != 0);
236 break; 239 break;
237 } 240 }
238 case SkPaint::kStroke_Style: { 241 case SkPaint::kStroke_Style: {
239 BOOL res = StrokePath(dc); 242 BOOL res = StrokePath(dc);
240 SkASSERT(res != 0); 243 SkASSERT(res != 0);
241 break; 244 break;
242 } 245 }
243 case SkPaint::kStrokeAndFill_Style: { 246 case SkPaint::kStrokeAndFill_Style: {
244 BOOL res = StrokeAndFillPath(dc); 247 BOOL res = StrokeAndFillPath(dc);
245 SkASSERT(res != 0); 248 SkASSERT(res != 0);
246 break; 249 break;
247 } 250 }
248 default: 251 default:
249 SkASSERT(false); 252 SkASSERT(false);
250 break; 253 break;
251 } 254 }
252 endPlatformPaint(); 255 EndPlatformPaint();
253 Cleanup(); 256 Cleanup();
254 } 257 }
255 258
256 void VectorPlatformDeviceEmf::drawBitmap(const SkDraw& draw, 259 void VectorPlatformDeviceEmf::drawBitmap(const SkDraw& draw,
257 const SkBitmap& bitmap, 260 const SkBitmap& bitmap,
258 const SkIRect* srcRectOrNull, 261 const SkIRect* srcRectOrNull,
259 const SkMatrix& matrix, 262 const SkMatrix& matrix,
260 const SkPaint& paint) { 263 const SkPaint& paint) {
261 // Load the temporary matrix. This is what will translate, rotate and resize 264 // Load the temporary matrix. This is what will translate, rotate and resize
262 // the bitmap. 265 // the bitmap.
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 for (int x2 = 0; x2 < src_size_x; ++x2) { 652 for (int x2 = 0; x2 < src_size_x; ++x2) {
650 if (SkColorGetA(pixels[(y2 * row_length) + x2]) != 255) { 653 if (SkColorGetA(pixels[(y2 * row_length) + x2]) != 255) {
651 is_translucent = true; 654 is_translucent = true;
652 y2 = src_size_y; 655 y2 = src_size_y;
653 break; 656 break;
654 } 657 }
655 } 658 }
656 } 659 }
657 } 660 }
658 661
659 HDC dc = beginPlatformPaint(); 662 HDC dc = BeginPlatformPaint();
660 BITMAPINFOHEADER hdr; 663 BITMAPINFOHEADER hdr;
661 FillBitmapInfoHeader(src_size_x, src_size_y, &hdr); 664 FillBitmapInfoHeader(src_size_x, src_size_y, &hdr);
662 if (is_translucent) { 665 if (is_translucent) {
663 // The image must be loaded as a bitmap inside a device context. 666 // The image must be loaded as a bitmap inside a device context.
664 HDC bitmap_dc = ::CreateCompatibleDC(dc); 667 HDC bitmap_dc = ::CreateCompatibleDC(dc);
665 void* bits = NULL; 668 void* bits = NULL;
666 HBITMAP hbitmap = ::CreateDIBSection( 669 HBITMAP hbitmap = ::CreateDIBSection(
667 bitmap_dc, reinterpret_cast<const BITMAPINFO*>(&hdr), 670 bitmap_dc, reinterpret_cast<const BITMAPINFO*>(&hdr),
668 DIB_RGB_COLORS, &bits, NULL, 0); 671 DIB_RGB_COLORS, &bits, NULL, 0);
669 672
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 x, y, // Destination origin. 718 x, y, // Destination origin.
716 src_size_x, src_size_y, 719 src_size_x, src_size_y,
717 0, 0, // Source origin. 720 0, 0, // Source origin.
718 src_size_x, src_size_y, // Source size. 721 src_size_x, src_size_y, // Source size.
719 pixels, 722 pixels,
720 reinterpret_cast<const BITMAPINFO*>(&hdr), 723 reinterpret_cast<const BITMAPINFO*>(&hdr),
721 DIB_RGB_COLORS, 724 DIB_RGB_COLORS,
722 SRCCOPY); 725 SRCCOPY);
723 SkASSERT(result); 726 SkASSERT(result);
724 } 727 }
725 endPlatformPaint(); 728 EndPlatformPaint();
726 Cleanup(); 729 Cleanup();
727 } 730 }
728 731
729 } // namespace skia 732 } // namespace skia
730 733
OLDNEW
« no previous file with comments | « skia/ext/vector_platform_device_emf_win.h ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698