OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkSurface_DEFINED | 8 #ifndef SkSurface_DEFINED |
9 #define SkSurface_DEFINED | 9 #define SkSurface_DEFINED |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 * | 24 * |
25 * To draw into a canvas, first create the appropriate type of Surface, and | 25 * To draw into a canvas, first create the appropriate type of Surface, and |
26 * then request the canvas from the surface. | 26 * then request the canvas from the surface. |
27 * | 27 * |
28 * SkSurface always has non-zero dimensions. If there is a request for a new su
rface, and either | 28 * SkSurface always has non-zero dimensions. If there is a request for a new su
rface, and either |
29 * of the requested dimensions are zero, then NULL will be returned. | 29 * of the requested dimensions are zero, then NULL will be returned. |
30 */ | 30 */ |
31 class SK_API SkSurface : public SkRefCnt { | 31 class SK_API SkSurface : public SkRefCnt { |
32 public: | 32 public: |
33 /** | 33 /** |
| 34 * Indicates whether a new surface or image should count against a cache bu
dget. Currently this |
| 35 * is only used by the GPU backend (sw-raster surfaces and images are never
counted against the |
| 36 * resource cache budget.) |
| 37 */ |
| 38 enum Budgeted { |
| 39 /** The surface or image does not count against the cache budget. */ |
| 40 kNo_Budgeted, |
| 41 /** The surface or image counts against the cache budget. */ |
| 42 kYes_Budgeted |
| 43 }; |
| 44 |
| 45 /** |
34 * Create a new surface, using the specified pixels/rowbytes as its | 46 * Create a new surface, using the specified pixels/rowbytes as its |
35 * backend. | 47 * backend. |
36 * | 48 * |
37 * If the requested surface cannot be created, or the request is not a | 49 * If the requested surface cannot be created, or the request is not a |
38 * supported configuration, NULL will be returned. | 50 * supported configuration, NULL will be returned. |
39 */ | 51 */ |
40 static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t r
owBytes, | 52 static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t r
owBytes, |
41 const SkSurfaceProps* = NULL); | 53 const SkSurfaceProps* = NULL); |
42 | 54 |
43 /** | 55 /** |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 GrContext*, const GrBackendTextureDesc&, const SkSurfaceProps*); | 128 GrContext*, const GrBackendTextureDesc&, const SkSurfaceProps*); |
117 | 129 |
118 /** | 130 /** |
119 * Return a new surface whose contents will be drawn to an offscreen | 131 * Return a new surface whose contents will be drawn to an offscreen |
120 * render target, allocated by the surface. | 132 * render target, allocated by the surface. |
121 * | 133 * |
122 * The GrTextureStorageAllocator will be reused if SkImage snapshots create | 134 * The GrTextureStorageAllocator will be reused if SkImage snapshots create |
123 * additional textures. | 135 * additional textures. |
124 */ | 136 */ |
125 static SkSurface* NewRenderTarget( | 137 static SkSurface* NewRenderTarget( |
126 GrContext*, SkBudgeted, const SkImageInfo&, int sampleCount, | 138 GrContext*, Budgeted, const SkImageInfo&, int sampleCount, const SkS
urfaceProps* = NULL, |
127 const SkSurfaceProps* = NULL, GrTextureStorageAllocator = GrTextureS
torageAllocator()); | 139 GrTextureStorageAllocator = GrTextureStorageAllocator()); |
128 | 140 |
129 static SkSurface* NewRenderTarget(GrContext* gr, SkBudgeted b, const SkImage
Info& info) { | 141 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn
fo& info) { |
130 return NewRenderTarget(gr, b, info, 0); | 142 return NewRenderTarget(gr, b, info, 0); |
131 } | 143 } |
132 | 144 |
133 int width() const { return fWidth; } | 145 int width() const { return fWidth; } |
134 int height() const { return fHeight; } | 146 int height() const { return fHeight; } |
135 | 147 |
136 /** | 148 /** |
137 * Returns a unique non-zero, unique value identifying the content of this | 149 * Returns a unique non-zero, unique value identifying the content of this |
138 * surface. Each time the content is changed changed, either by drawing | 150 * surface. Each time the content is changed changed, either by drawing |
139 * into this surface, or explicitly calling notifyContentChanged()) this | 151 * into this surface, or explicitly calling notifyContentChanged()) this |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 */ | 237 */ |
226 SkSurface* newSurface(const SkImageInfo&); | 238 SkSurface* newSurface(const SkImageInfo&); |
227 | 239 |
228 /** | 240 /** |
229 * Returns an image of the current state of the surface pixels up to this | 241 * Returns an image of the current state of the surface pixels up to this |
230 * point. Subsequent changes to the surface (by drawing into its canvas) | 242 * point. Subsequent changes to the surface (by drawing into its canvas) |
231 * will not be reflected in this image. If a copy must be made the Budgeted | 243 * will not be reflected in this image. If a copy must be made the Budgeted |
232 * parameter controls whether it counts against the resource budget | 244 * parameter controls whether it counts against the resource budget |
233 * (currently for the gpu backend only). | 245 * (currently for the gpu backend only). |
234 */ | 246 */ |
235 SkImage* newImageSnapshot(SkBudgeted = SkBudgeted::kYes); | 247 SkImage* newImageSnapshot(Budgeted = kYes_Budgeted); |
236 | 248 |
237 /** | 249 /** |
238 * In rare instances a client may want a unique copy of the SkSurface's cont
ents in an image | 250 * In rare instances a client may want a unique copy of the SkSurface's cont
ents in an image |
239 * snapshot. This enum can be used to enforce that the image snapshot's back
ing store is not | 251 * snapshot. This enum can be used to enforce that the image snapshot's back
ing store is not |
240 * shared with another image snapshot or the surface's backing store. This i
s generally more | 252 * shared with another image snapshot or the surface's backing store. This i
s generally more |
241 * expensive. This was added for Chromium bug 585250. | 253 * expensive. This was added for Chromium bug 585250. |
242 */ | 254 */ |
243 enum ForceUnique { | 255 enum ForceUnique { |
244 kNo_ForceUnique, | 256 kNo_ForceUnique, |
245 kYes_ForceUnique | 257 kYes_ForceUnique |
246 }; | 258 }; |
247 SkImage* newImageSnapshot(SkBudgeted, ForceUnique); | 259 SkImage* newImageSnapshot(Budgeted, ForceUnique); |
248 | 260 |
249 /** | 261 /** |
250 * Though the caller could get a snapshot image explicitly, and draw that, | 262 * Though the caller could get a snapshot image explicitly, and draw that, |
251 * it seems that directly drawing a surface into another canvas might be | 263 * it seems that directly drawing a surface into another canvas might be |
252 * a common pattern, and that we could possibly be more efficient, since | 264 * a common pattern, and that we could possibly be more efficient, since |
253 * we'd know that the "snapshot" need only live until we've handed it off | 265 * we'd know that the "snapshot" need only live until we've handed it off |
254 * to the canvas. | 266 * to the canvas. |
255 */ | 267 */ |
256 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); | 268 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); |
257 | 269 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 private: | 319 private: |
308 const SkSurfaceProps fProps; | 320 const SkSurfaceProps fProps; |
309 const int fWidth; | 321 const int fWidth; |
310 const int fHeight; | 322 const int fHeight; |
311 uint32_t fGenerationID; | 323 uint32_t fGenerationID; |
312 | 324 |
313 typedef SkRefCnt INHERITED; | 325 typedef SkRefCnt INHERITED; |
314 }; | 326 }; |
315 | 327 |
316 #endif | 328 #endif |
OLD | NEW |