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 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_ | 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_H_ |
6 #define SKIA_EXT_PLATFORM_CANVAS_H_ | 6 #define SKIA_EXT_PLATFORM_CANVAS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // The platform-specific device will include the necessary platform headers | 9 // The platform-specific device will include the necessary platform headers |
10 // to get the surface type. | 10 // to get the surface type. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // | 102 // |
103 // Danger: the resulting device should not be saved. It will be invalidated | 103 // Danger: the resulting device should not be saved. It will be invalidated |
104 // by the next call to save() or restore(). | 104 // by the next call to save() or restore(). |
105 SK_API SkDevice* GetTopDevice(const SkCanvas& canvas); | 105 SK_API SkDevice* GetTopDevice(const SkCanvas& canvas); |
106 | 106 |
107 // Creates a canvas with raster bitmap backing. | 107 // Creates a canvas with raster bitmap backing. |
108 // Set is_opaque if you are going to erase the bitmap and not use | 108 // Set is_opaque if you are going to erase the bitmap and not use |
109 // transparency: this will enable some optimizations. | 109 // transparency: this will enable some optimizations. |
110 SK_API SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque); | 110 SK_API SkCanvas* CreateBitmapCanvas(int width, int height, bool is_opaque); |
111 | 111 |
| 112 // Non-crashing version of CreateBitmapCanvas |
| 113 // returns NULL if allocation fails for any reason. |
| 114 // Use this instead of CreateBitmapCanvas in places that are likely to |
| 115 // attempt to allocate very large canvases (therefore likely to fail), |
| 116 // and where it is possible to recover gracefully from the failed allocation. |
| 117 SK_API SkCanvas* TryCreateBitmapCanvas(int width, int height, bool is_opaque); |
| 118 |
112 // Returns true if native platform routines can be used to draw on the | 119 // Returns true if native platform routines can be used to draw on the |
113 // given canvas. If this function returns false, BeginPlatformPaint will | 120 // given canvas. If this function returns false, BeginPlatformPaint will |
114 // return NULL PlatformSurface. | 121 // return NULL PlatformSurface. |
115 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); | 122 SK_API bool SupportsPlatformPaint(const SkCanvas* canvas); |
116 | 123 |
117 // Draws into the a native platform surface, |context|. Forwards to | 124 // Draws into the a native platform surface, |context|. Forwards to |
118 // DrawToNativeContext on a PlatformDevice instance bound to the top device. | 125 // DrawToNativeContext on a PlatformDevice instance bound to the top device. |
119 // If no PlatformDevice instance is bound, is a no-operation. | 126 // If no PlatformDevice instance is bound, is a no-operation. |
120 SK_API void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, | 127 SK_API void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, |
121 int x, int y, const PlatformRect* src_rect); | 128 int x, int y, const PlatformRect* src_rect); |
(...skipping 27 matching lines...) Expand all Loading... |
149 PlatformSurface platform_surface_; | 156 PlatformSurface platform_surface_; |
150 | 157 |
151 // Disallow copy and assign | 158 // Disallow copy and assign |
152 ScopedPlatformPaint(const ScopedPlatformPaint&); | 159 ScopedPlatformPaint(const ScopedPlatformPaint&); |
153 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); | 160 ScopedPlatformPaint& operator=(const ScopedPlatformPaint&); |
154 }; | 161 }; |
155 | 162 |
156 } // namespace skia | 163 } // namespace skia |
157 | 164 |
158 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 165 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
OLD | NEW |