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