| 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 SK_DECLARE_INST_COUNT(SkSurface) | |
| 34 | |
| 35 /** | 33 /** |
| 36 * Indicates whether a new surface or image should count against a cache bu
dget. Currently this | 34 * Indicates whether a new surface or image should count against a cache bu
dget. Currently this |
| 37 * is only used by the GPU backend (sw-raster surfaces and images are never
counted against the | 35 * is only used by the GPU backend (sw-raster surfaces and images are never
counted against the |
| 38 * resource cache budget.) | 36 * resource cache budget.) |
| 39 */ | 37 */ |
| 40 enum Budgeted { | 38 enum Budgeted { |
| 41 /** The surface or image does not count against the cache budget. */ | 39 /** The surface or image does not count against the cache budget. */ |
| 42 kNo_Budgeted, | 40 kNo_Budgeted, |
| 43 /** The surface or image counts against the cache budget. */ | 41 /** The surface or image counts against the cache budget. */ |
| 44 kYes_Budgeted | 42 kYes_Budgeted |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 * pixels in SkPMColor format. | 75 * pixels in SkPMColor format. |
| 78 */ | 76 */ |
| 79 static SkSurface* NewRasterN32Premul(int width, int height, const SkSurfaceP
rops* props = NULL) { | 77 static SkSurface* NewRasterN32Premul(int width, int height, const SkSurfaceP
rops* props = NULL) { |
| 80 return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); | 78 return NewRaster(SkImageInfo::MakeN32Premul(width, height), props); |
| 81 } | 79 } |
| 82 | 80 |
| 83 /** | 81 /** |
| 84 * Return a new surface using the specified render target. | 82 * Return a new surface using the specified render target. |
| 85 */ | 83 */ |
| 86 static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*); | 84 static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp
s*); |
| 87 | 85 |
| 88 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { | 86 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { |
| 89 return NewRenderTargetDirect(target, NULL); | 87 return NewRenderTargetDirect(target, NULL); |
| 90 } | 88 } |
| 91 | 89 |
| 92 /** | 90 /** |
| 93 * Used to wrap a pre-existing backend 3D API texture in a SkSurface. The k
RenderTarget flag | 91 * Used to wrap a pre-existing backend 3D API texture in a SkSurface. The k
RenderTarget flag |
| 94 * must be set on GrBackendTextureDesc for this to succeed. | 92 * must be set on GrBackendTextureDesc for this to succeed. |
| 95 */ | 93 */ |
| 96 static SkSurface* NewWrappedRenderTarget(GrContext*, GrBackendTextureDesc, | 94 static SkSurface* NewWrappedRenderTarget(GrContext*, GrBackendTextureDesc, |
| 97 const SkSurfaceProps*); | 95 const SkSurfaceProps*); |
| 98 | 96 |
| 99 /** | 97 /** |
| 100 * Return a new surface whose contents will be drawn to an offscreen | 98 * Return a new surface whose contents will be drawn to an offscreen |
| 101 * render target, allocated by the surface. | 99 * render target, allocated by the surface. |
| 102 */ | 100 */ |
| 103 static SkSurface* NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&,
int sampleCount, | 101 static SkSurface* NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&,
int sampleCount, |
| 104 const SkSurfaceProps* = NULL); | 102 const SkSurfaceProps* = NULL); |
| 105 | 103 |
| 106 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn
fo& info) { | 104 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn
fo& info) { |
| 107 return NewRenderTarget(gr, b, info, 0, NULL); | 105 return NewRenderTarget(gr, b, info, 0, NULL); |
| 108 } | 106 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 private: | 229 private: |
| 232 const SkSurfaceProps fProps; | 230 const SkSurfaceProps fProps; |
| 233 const int fWidth; | 231 const int fWidth; |
| 234 const int fHeight; | 232 const int fHeight; |
| 235 uint32_t fGenerationID; | 233 uint32_t fGenerationID; |
| 236 | 234 |
| 237 typedef SkRefCnt INHERITED; | 235 typedef SkRefCnt INHERITED; |
| 238 }; | 236 }; |
| 239 | 237 |
| 240 #endif | 238 #endif |
| OLD | NEW |