OLD | NEW |
---|---|
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 "skia/ext/platform_canvas.h" | 5 #include "skia/ext/platform_canvas.h" |
6 | 6 |
7 #include "skia/ext/bitmap_platform_device.h" | 7 #include "skia/ext/bitmap_platform_device.h" |
8 #include "third_party/skia/include/core/SkTypes.h" | 8 #include "third_party/skia/include/core/SkTypes.h" |
9 | 9 |
10 namespace skia { | 10 namespace skia { |
(...skipping 16 matching lines...) Expand all Loading... | |
27 | 27 |
28 setDevice(device); | 28 setDevice(device); |
29 device->unref(); // Was created with refcount 1, and setDevice also refs. | 29 device->unref(); // Was created with refcount 1, and setDevice also refs. |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque) { | 33 SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque) { |
34 return new PlatformCanvas(width, height, is_opaque); | 34 return new PlatformCanvas(width, height, is_opaque); |
35 } | 35 } |
36 | 36 |
37 SkCanvas* TryCreateBitmapCanvas(int width, int height, bool is_opaque) { | |
alokp
2011/08/19 15:34:39
Couldn't you change the existing function to retur
junov1
2011/08/19 15:50:25
There are many places that currently call CreateBi
| |
38 PlatformCanvas* canvas = new PlatformCanvas(); | |
39 if (!canvas->initialize(width, height, is_opaque)) { | |
40 delete canvas; | |
41 canvas = NULL; | |
42 } | |
43 return canvas; | |
44 } | |
45 | |
37 SkDevice* GetTopDevice(const SkCanvas& canvas) { | 46 SkDevice* GetTopDevice(const SkCanvas& canvas) { |
38 SkCanvas::LayerIter iter(const_cast<SkCanvas*>(&canvas), false); | 47 SkCanvas::LayerIter iter(const_cast<SkCanvas*>(&canvas), false); |
39 return iter.device(); | 48 return iter.device(); |
40 } | 49 } |
41 | 50 |
42 bool SupportsPlatformPaint(const SkCanvas* canvas) { | 51 bool SupportsPlatformPaint(const SkCanvas* canvas) { |
43 // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these | 52 // TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these |
44 // calls from WebKit. | 53 // calls from WebKit. |
45 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 54 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
46 return platform_device && platform_device->IsNativeFontRenderingAllowed(); | 55 return platform_device && platform_device->IsNativeFontRenderingAllowed(); |
(...skipping 20 matching lines...) Expand all Loading... | |
67 platform_device->DrawToNativeContext(context, x, y, src_rect); | 76 platform_device->DrawToNativeContext(context, x, y, src_rect); |
68 } | 77 } |
69 | 78 |
70 void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { | 79 void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) { |
71 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); | 80 PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas)); |
72 if (platform_device) | 81 if (platform_device) |
73 platform_device->MakeOpaque(x, y, width, height); | 82 platform_device->MakeOpaque(x, y, width, height); |
74 } | 83 } |
75 | 84 |
76 } // namespace skia | 85 } // namespace skia |
OLD | NEW |