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 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool is_opaque) { | 105 bool is_opaque) { |
106 return CreatePlatformCanvas(width, height, is_opaque, 0, | 106 return CreatePlatformCanvas(width, height, is_opaque, 0, |
107 RETURN_NULL_ON_FAILURE); | 107 RETURN_NULL_ON_FAILURE); |
108 } | 108 } |
109 | 109 |
110 // Return the stride (length of a line in bytes) for the given width. Because | 110 // Return the stride (length of a line in bytes) for the given width. Because |
111 // we use 32-bits per pixel, this will be roughly 4*width. However, for | 111 // we use 32-bits per pixel, this will be roughly 4*width. However, for |
112 // alignment reasons we may wish to increase that. | 112 // alignment reasons we may wish to increase that. |
113 SK_API size_t PlatformCanvasStrideForWidth(unsigned width); | 113 SK_API size_t PlatformCanvasStrideForWidth(unsigned width); |
114 | 114 |
115 // Returns the SkBaseDevice pointer of the topmost rect with a non-empty | |
116 // clip. In practice, this is usually either the top layer or nothing, since | |
117 // we usually set the clip to new layers when we make them. | |
118 // | |
119 // This may return NULL, so callers need to check. | |
120 // | |
121 // This is different than SkCanvas' getDevice, because that returns the | |
122 // bottommost device. | |
123 // | |
124 // Danger: the resulting device should not be saved. It will be invalidated | |
125 // by the next call to save() or restore(). | |
126 SK_API SkBaseDevice* GetTopDevice(const SkCanvas& canvas); | |
127 | |
128 // Copies pixels from the SkCanvas into an SkBitmap, fetching pixels from | 115 // Copies pixels from the SkCanvas into an SkBitmap, fetching pixels from |
129 // GPU memory if necessary. | 116 // GPU memory if necessary. |
130 // | 117 // |
131 // The bitmap will remain empty if we can't allocate enough memory for a copy | 118 // The bitmap will remain empty if we can't allocate enough memory for a copy |
132 // of the pixels. | 119 // of the pixels. |
133 SK_API SkBitmap ReadPixels(SkCanvas* canvas); | 120 SK_API SkBitmap ReadPixels(SkCanvas* canvas); |
134 | 121 |
135 // Gives the pixmap passed in *writable* access to the pixels backing this | 122 // Gives the pixmap passed in *writable* access to the pixels backing this |
136 // canvas. All writes to the pixmap should be visible if the canvas is | 123 // canvas. All writes to the pixmap should be visible if the canvas is |
137 // raster-backed. | 124 // raster-backed. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | 161 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); |
175 | 162 |
176 // Returns the CGContext that backing the SkCanvas. | 163 // Returns the CGContext that backing the SkCanvas. |
177 // Returns NULL if none is bound. | 164 // Returns NULL if none is bound. |
178 SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas); | 165 SK_API CGContextRef GetBitmapContext(const SkCanvas& canvas); |
179 #endif | 166 #endif |
180 | 167 |
181 } // namespace skia | 168 } // namespace skia |
182 | 169 |
183 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ | 170 #endif // SKIA_EXT_PLATFORM_CANVAS_H_ |
OLD | NEW |