OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/SkTemplates.h" | 11 #include "third_party/skia/include/core/SkTemplates.h" |
12 #include "third_party/skia/include/core/SkUtils.h" | 12 #include "third_party/skia/include/core/SkUtils.h" |
13 #include "third_party/skia/include/ports/SkTypeface_win.h" | 13 #include "third_party/skia/include/ports/SkTypeface_win.h" |
14 | 14 |
15 namespace skia { | 15 namespace skia { |
16 | 16 |
17 // static | 17 // static |
18 SkDevice* VectorPlatformDeviceEmf::CreateDevice( | 18 SkDevice* VectorPlatformDeviceEmf::CreateDevice( |
19 int width, int height, bool is_opaque, HANDLE shared_section) { | 19 int width, int height, int flags, HANDLE shared_section) { |
20 if (!is_opaque) { | 20 if (!flags & FLAGS_OPAQUE) { |
21 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent | 21 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent |
22 // layer, i.e. merging it, we need to rasterize it because GDI doesn't | 22 // layer, i.e. merging it, we need to rasterize it because GDI doesn't |
23 // support transparency except for AlphaBlend(). Right now, a | 23 // support transparency except for AlphaBlend(). Right now, a |
24 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers() | 24 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers() |
25 // call is being done. The way to save a layer would be to create an | 25 // call is being done. The way to save a layer would be to create an |
26 // EMF-based VectorDevice and have this device registers the drawing. When | 26 // EMF-based VectorDevice and have this device registers the drawing. When |
27 // playing back the device into a bitmap, do it at the printer's dpi instead | 27 // playing back the device into a bitmap, do it at the printer's dpi instead |
28 // of the layout's dpi (which is much lower). | 28 // of the layout's dpi (which is much lower). |
29 return BitmapPlatformDevice::create(width, height, is_opaque, | 29 return BitmapPlatformDevice::create(width, height, flags, shared_section); |
30 shared_section); | |
31 } | 30 } |
32 | 31 |
33 // TODO(maruel): http://crbug.com/18383 Look if it would be worth to | 32 // TODO(maruel): http://crbug.com/18383 Look if it would be worth to |
34 // increase the resolution by ~10x (any worthy factor) to increase the | 33 // increase the resolution by ~10x (any worthy factor) to increase the |
35 // rendering precision (think about printing) while using a relatively | 34 // rendering precision (think about printing) while using a relatively |
36 // low dpi. This happens because we receive float as input but the GDI | 35 // low dpi. This happens because we receive float as input but the GDI |
37 // functions works with integers. The idea is to premultiply the matrix | 36 // functions works with integers. The idea is to premultiply the matrix |
38 // with this factor and multiply each SkScalar that are passed to | 37 // with this factor and multiply each SkScalar that are passed to |
39 // SkScalarRound(value) as SkScalarRound(value * 10). Safari is already | 38 // SkScalarRound(value) as SkScalarRound(value * 10). Safari is already |
40 // doing the same for text rendering. | 39 // doing the same for text rendering. |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 pixels, | 861 pixels, |
863 reinterpret_cast<const BITMAPINFO*>(&hdr), | 862 reinterpret_cast<const BITMAPINFO*>(&hdr), |
864 DIB_RGB_COLORS, | 863 DIB_RGB_COLORS, |
865 SRCCOPY); | 864 SRCCOPY); |
866 } | 865 } |
867 EndPlatformPaint(); | 866 EndPlatformPaint(); |
868 Cleanup(); | 867 Cleanup(); |
869 } | 868 } |
870 | 869 |
871 } // namespace skia | 870 } // namespace skia |
OLD | NEW |