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

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

Issue 7273013: Stop using deprecated factory API for SkDevice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « skia/ext/vector_platform_device_emf_win.h ('k') | skia/ext/vector_platform_device_skia.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) 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"
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 SkDevice* VectorPlatformDeviceEmfFactory::newDevice(SkCanvas* unused,
16 SkBitmap::Config config,
17 int width, int height,
18 bool isOpaque,
19 bool isForLayer) {
20 SkASSERT(config == SkBitmap::kARGB_8888_Config);
21 return CreateDevice(width, height, isOpaque, NULL);
22 }
23
24 //static 15 //static
25 PlatformDevice* VectorPlatformDeviceEmfFactory::CreateDevice( 16 PlatformDevice* VectorPlatformDeviceEmf::CreateDevice(int width, int height,
26 int width, int height, bool is_opaque, HANDLE shared_section) { 17 bool is_opaque,
18 HANDLE shared_section) {
27 if (!is_opaque) { 19 if (!is_opaque) {
28 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent 20 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent
29 // layer, i.e. merging it, we need to rasterize it because GDI doesn't 21 // layer, i.e. merging it, we need to rasterize it because GDI doesn't
30 // support transparency except for AlphaBlend(). Right now, a 22 // support transparency except for AlphaBlend(). Right now, a
31 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers() 23 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers()
32 // call is being done. The way to save a layer would be to create an 24 // call is being done. The way to save a layer would be to create an
33 // EMF-based VectorDevice and have this device registers the drawing. When 25 // EMF-based VectorDevice and have this device registers the drawing. When
34 // playing back the device into a bitmap, do it at the printer's dpi instead 26 // playing back the device into a bitmap, do it at the printer's dpi instead
35 // of the layout's dpi (which is much lower). 27 // of the layout's dpi (which is much lower).
36 return BitmapPlatformDevice::create(width, height, is_opaque, 28 return BitmapPlatformDevice::create(width, height, is_opaque,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 previous_pen_(NULL), 100 previous_pen_(NULL),
109 alpha_blend_used_(false) { 101 alpha_blend_used_(false) {
110 transform_.reset(); 102 transform_.reset();
111 } 103 }
112 104
113 VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() { 105 VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() {
114 SkASSERT(previous_brush_ == NULL); 106 SkASSERT(previous_brush_ == NULL);
115 SkASSERT(previous_pen_ == NULL); 107 SkASSERT(previous_pen_ == NULL);
116 } 108 }
117 109
118 SkDeviceFactory* VectorPlatformDeviceEmf::onNewDeviceFactory() {
119 return SkNEW(VectorPlatformDeviceEmfFactory);
120 }
121
122 HDC VectorPlatformDeviceEmf::BeginPlatformPaint() { 110 HDC VectorPlatformDeviceEmf::BeginPlatformPaint() {
123 return hdc_; 111 return hdc_;
124 } 112 }
125 113
126 uint32_t VectorPlatformDeviceEmf::getDeviceCapabilities() { 114 uint32_t VectorPlatformDeviceEmf::getDeviceCapabilities() {
127 return SkDevice::getDeviceCapabilities() | kVector_Capability; 115 return SkDevice::getDeviceCapabilities() | kVector_Capability;
128 } 116 }
129 117
130 void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw, 118 void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw,
131 const SkPaint& paint) { 119 const SkPaint& paint) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 const RECT* src_rect) { 431 const RECT* src_rect) {
444 SkASSERT(false); 432 SkASSERT(false);
445 } 433 }
446 434
447 void VectorPlatformDeviceEmf::LoadClipRegion() { 435 void VectorPlatformDeviceEmf::LoadClipRegion() {
448 SkMatrix t; 436 SkMatrix t;
449 t.reset(); 437 t.reset();
450 LoadClippingRegionToDC(hdc_, clip_region_, t); 438 LoadClippingRegionToDC(hdc_, clip_region_, t);
451 } 439 }
452 440
441 SkDevice* VectorPlatformDeviceEmf::onCreateCompatibleDevice(
442 SkBitmap::Config config, int width, int height, bool isOpaque,
443 Usage /*usage*/) {
444 SkASSERT(config == SkBitmap::kARGB_8888_Config);
445 return VectorPlatformDeviceEmf::CreateDevice(width, height, isOpaque, NULL);
446 }
447
453 bool VectorPlatformDeviceEmf::CreateBrush(bool use_brush, COLORREF color) { 448 bool VectorPlatformDeviceEmf::CreateBrush(bool use_brush, COLORREF color) {
454 SkASSERT(previous_brush_ == NULL); 449 SkASSERT(previous_brush_ == NULL);
455 // We can't use SetDCBrushColor() or DC_BRUSH when drawing to a EMF buffer. 450 // We can't use SetDCBrushColor() or DC_BRUSH when drawing to a EMF buffer.
456 // SetDCBrushColor() calls are not recorded at all and DC_BRUSH will use 451 // SetDCBrushColor() calls are not recorded at all and DC_BRUSH will use
457 // WHITE_BRUSH instead. 452 // WHITE_BRUSH instead.
458 453
459 if (!use_brush) { 454 if (!use_brush) {
460 // Set the transparency. 455 // Set the transparency.
461 if (0 == SetBkMode(hdc_, TRANSPARENT)) { 456 if (0 == SetBkMode(hdc_, TRANSPARENT)) {
462 SkASSERT(false); 457 SkASSERT(false);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 DIB_RGB_COLORS, 727 DIB_RGB_COLORS,
733 SRCCOPY); 728 SRCCOPY);
734 SkASSERT(result); 729 SkASSERT(result);
735 } 730 }
736 EndPlatformPaint(); 731 EndPlatformPaint();
737 Cleanup(); 732 Cleanup();
738 } 733 }
739 734
740 } // namespace skia 735 } // namespace skia
741 736
OLDNEW
« no previous file with comments | « skia/ext/vector_platform_device_emf_win.h ('k') | skia/ext/vector_platform_device_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698