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/SkPathEffect.h" | 11 #include "third_party/skia/include/core/SkPathEffect.h" |
12 #include "third_party/skia/include/core/SkTemplates.h" | 12 #include "third_party/skia/include/core/SkTemplates.h" |
13 #include "third_party/skia/include/core/SkUtils.h" | 13 #include "third_party/skia/include/core/SkUtils.h" |
14 #include "third_party/skia/include/ports/SkTypeface_win.h" | 14 #include "third_party/skia/include/ports/SkTypeface_win.h" |
15 | 15 |
16 namespace skia { | 16 namespace skia { |
17 | 17 |
18 #define CHECK_FOR_NODRAW_ANNOTATION(paint) \ | |
19 do { if (paint.isNoDrawAnnotation()) { return; } } while (0) | |
Vitaly Buka (NO REVIEWS)
2012/08/20 20:36:45
Why do you need macro for two instances of such si
| |
20 | |
18 // static | 21 // static |
19 SkDevice* VectorPlatformDeviceEmf::CreateDevice( | 22 SkDevice* VectorPlatformDeviceEmf::CreateDevice( |
20 int width, int height, bool is_opaque, HANDLE shared_section) { | 23 int width, int height, bool is_opaque, HANDLE shared_section) { |
21 if (!is_opaque) { | 24 if (!is_opaque) { |
22 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent | 25 // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent |
23 // layer, i.e. merging it, we need to rasterize it because GDI doesn't | 26 // layer, i.e. merging it, we need to rasterize it because GDI doesn't |
24 // support transparency except for AlphaBlend(). Right now, a | 27 // support transparency except for AlphaBlend(). Right now, a |
25 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers() | 28 // BitmapPlatformDevice is created when VectorCanvas think a saveLayers() |
26 // call is being done. The way to save a layer would be to create an | 29 // call is being done. The way to save a layer would be to create an |
27 // EMF-based VectorDevice and have this device registers the drawing. When | 30 // EMF-based VectorDevice and have this device registers the drawing. When |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 SkASSERT(false); | 169 SkASSERT(false); |
167 return; | 170 return; |
168 } | 171 } |
169 // Draw the calculated path. | 172 // Draw the calculated path. |
170 drawPath(draw, path, tmp_paint); | 173 drawPath(draw, path, tmp_paint); |
171 } | 174 } |
172 | 175 |
173 void VectorPlatformDeviceEmf::drawRect(const SkDraw& draw, | 176 void VectorPlatformDeviceEmf::drawRect(const SkDraw& draw, |
174 const SkRect& rect, | 177 const SkRect& rect, |
175 const SkPaint& paint) { | 178 const SkPaint& paint) { |
179 CHECK_FOR_NODRAW_ANNOTATION(paint); | |
176 if (paint.getPathEffect()) { | 180 if (paint.getPathEffect()) { |
177 // Draw a path instead. | 181 // Draw a path instead. |
178 SkPath path_orginal; | 182 SkPath path_orginal; |
179 path_orginal.addRect(rect); | 183 path_orginal.addRect(rect); |
180 | 184 |
181 // Apply the path effect to the rect. | 185 // Apply the path effect to the rect. |
182 SkPath path_modified; | 186 SkPath path_modified; |
183 paint.getFillPath(path_orginal, &path_modified); | 187 paint.getFillPath(path_orginal, &path_modified); |
184 | 188 |
185 // Removes the path effect from the temporary SkPaint object. | 189 // Removes the path effect from the temporary SkPaint object. |
(...skipping 17 matching lines...) Expand all Loading... | |
203 } | 207 } |
204 EndPlatformPaint(); | 208 EndPlatformPaint(); |
205 Cleanup(); | 209 Cleanup(); |
206 } | 210 } |
207 | 211 |
208 void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, | 212 void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, |
209 const SkPath& path, | 213 const SkPath& path, |
210 const SkPaint& paint, | 214 const SkPaint& paint, |
211 const SkMatrix* prePathMatrix, | 215 const SkMatrix* prePathMatrix, |
212 bool pathIsMutable) { | 216 bool pathIsMutable) { |
217 CHECK_FOR_NODRAW_ANNOTATION(paint); | |
213 if (paint.getPathEffect()) { | 218 if (paint.getPathEffect()) { |
214 // Apply the path effect forehand. | 219 // Apply the path effect forehand. |
215 SkPath path_modified; | 220 SkPath path_modified; |
216 paint.getFillPath(path, &path_modified); | 221 paint.getFillPath(path, &path_modified); |
217 | 222 |
218 // Removes the path effect from the temporary SkPaint object. | 223 // Removes the path effect from the temporary SkPaint object. |
219 SkPaint paint_no_effet(paint); | 224 SkPaint paint_no_effet(paint); |
220 SkSafeUnref(paint_no_effet.setPathEffect(NULL)); | 225 SkSafeUnref(paint_no_effet.setPathEffect(NULL)); |
221 | 226 |
222 // Draw the calculated path. | 227 // Draw the calculated path. |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 pixels, | 868 pixels, |
864 reinterpret_cast<const BITMAPINFO*>(&hdr), | 869 reinterpret_cast<const BITMAPINFO*>(&hdr), |
865 DIB_RGB_COLORS, | 870 DIB_RGB_COLORS, |
866 SRCCOPY); | 871 SRCCOPY); |
867 } | 872 } |
868 EndPlatformPaint(); | 873 EndPlatformPaint(); |
869 Cleanup(); | 874 Cleanup(); |
870 } | 875 } |
871 | 876 |
872 } // namespace skia | 877 } // namespace skia |
OLD | NEW |