Chromium Code Reviews

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

Issue 3590011: Update use of SkCanvas and SkDevice to match change in Skia (Closed)
Patch Set: Bump deps again to bring in fix for memory leak Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « skia/ext/vector_canvas_linux.cc ('k') | skia/ext/vector_platform_device.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-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/vector_canvas.h" 5 #include "skia/ext/vector_canvas.h"
6 6
7 #include "skia/ext/bitmap_platform_device.h" 7 #include "skia/ext/bitmap_platform_device.h"
8 #include "skia/ext/vector_platform_device.h" 8 #include "skia/ext/vector_platform_device.h"
9 9
10 namespace skia { 10 namespace skia {
11 11
12 VectorCanvas::VectorCanvas(HDC dc, int width, int height) { 12 VectorCanvas::VectorCanvas(HDC dc, int width, int height) {
13 bool initialized = initialize(dc, width, height); 13 bool initialized = initialize(dc, width, height);
14 if (!initialized) 14 if (!initialized)
15 __debugbreak(); 15 __debugbreak();
16 } 16 }
17 17
18 bool VectorCanvas::initialize(HDC context, int width, int height) { 18 bool VectorCanvas::initialize(HDC context, int width, int height) {
19 SkDevice* device = createPlatformDevice(width, height, true, context); 19 SkDevice* device = SkVectorPlatformDeviceFactory::CreateDevice(width, height,
20 true, context);
20 if (!device) 21 if (!device)
21 return false; 22 return false;
22 23
23 setDevice(device); 24 setDevice(device);
24 device->unref(); // was created with refcount 1, and setDevice also refs 25 device->unref(); // was created with refcount 1, and setDevice also refs
25 return true; 26 return true;
26 } 27 }
27 28
28 SkDevice* VectorCanvas::createDevice(SkBitmap::Config config,
29 int width, int height,
30 bool is_opaque, bool isForLayer) {
31 SkASSERT(config == SkBitmap::kARGB_8888_Config);
32 return createPlatformDevice(width, height, is_opaque, NULL);
33 }
34
35 SkDevice* VectorCanvas::createPlatformDevice(int width,
36 int height, bool is_opaque,
37 HANDLE shared_section) {
38 if (!is_opaque) {
39 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent
40 // layer, i.e. merging it, we need to rasterize it because GDI doesn't
41 // support transparency except for AlphaBlend(). Right now, a
42 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers()
43 // call is being done. The way to save a layer would be to create an
44 // EMF-based VectorDevice and have this device registers the drawing. When
45 // playing back the device into a bitmap, do it at the printer's dpi instead
46 // of the layout's dpi (which is much lower).
47 return BitmapPlatformDevice::create(width, height,
48 is_opaque, shared_section);
49 }
50
51 // TODO(maruel): http://crbug.com/18383 Look if it would be worth to
52 // increase the resolution by ~10x (any worthy factor) to increase the
53 // rendering precision (think about printing) while using a relatively
54 // low dpi. This happens because we receive float as input but the GDI
55 // functions works with integers. The idea is to premultiply the matrix
56 // with this factor and multiply each SkScalar that are passed to
57 // SkScalarRound(value) as SkScalarRound(value * 10). Safari is already
58 // doing the same for text rendering.
59 SkASSERT(shared_section);
60 PlatformDevice* device = VectorPlatformDevice::create(
61 reinterpret_cast<HDC>(shared_section), width, height);
62 return device;
63 }
64
65 } // namespace skia 29 } // namespace skia
66 30
OLDNEW
« no previous file with comments | « skia/ext/vector_canvas_linux.cc ('k') | skia/ext/vector_platform_device.h » ('j') | no next file with comments »

Powered by Google App Engine