Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: include/core/SkSurface.h

Issue 848903004: Require budget decision when creating a RenderTarget SkSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address initial comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
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) 33 SK_DECLARE_INST_COUNT(SkSurface)
34 34
35 /** 35 /**
36 * 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
38 * resource cache budget.)
39 */
40 enum Budgeted {
41 /** The surface or image does not count against the cache budget. */
42 kNo_Budgeted,
43 /** The surface or image counts against the cache budget. */
44 kYes_Budgeted
45 };
46
47 /**
36 * Create a new surface, using the specified pixels/rowbytes as its 48 * Create a new surface, using the specified pixels/rowbytes as its
37 * backend. 49 * backend.
38 * 50 *
39 * If the requested surface cannot be created, or the request is not a 51 * If the requested surface cannot be created, or the request is not a
40 * supported configuration, NULL will be returned. 52 * supported configuration, NULL will be returned.
41 */ 53 */
42 static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t r owBytes, 54 static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t r owBytes,
43 const SkSurfaceProps* = NULL); 55 const SkSurfaceProps* = NULL);
44 56
45 /** 57 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp s*); 91 static SkSurface* NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProp s*);
80 92
81 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) { 93 static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) {
82 return NewRenderTargetDirect(target, NULL); 94 return NewRenderTargetDirect(target, NULL);
83 } 95 }
84 96
85 /** 97 /**
86 * 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
87 * render target, allocated by the surface. 99 * render target, allocated by the surface.
88 */ 100 */
89 static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sample Count, 101 static SkSurface* NewRenderTarget(GrContext*, Budgeted, const SkImageInfo&, int sampleCount,
90 const SkSurfaceProps* = NULL); 102 const SkSurfaceProps* = NULL);
91 103
92 static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info) { 104 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn fo& info) {
93 return NewRenderTarget(gr, info, 0, NULL); 105 return NewRenderTarget(gr, b, info, 0, NULL);
94 } 106 }
95 107
96 /** 108 /**
97 * Return a new surface whose contents will be drawn to an offscreen 109 * Deprecated - use the Budgeted param on NewRenderTarget.
98 * render target, allocated by the surface from the scratch texture pool
99 * managed by the GrContext. The scratch texture pool serves the purpose
100 * of retaining textures after they are no longer in use in order to
101 * re-use them later without having to re-allocate. Scratch textures
102 * should be used in cases where high turnover is expected. This allows,
103 * for example, the copy on write to recycle a texture from a recently
104 * released SkImage snapshot of the surface.
105 * Note: Scratch textures count against the GrContext's cached resource
106 * budget.
107 */ 110 */
108 static SkSurface* NewScratchRenderTarget(GrContext*, const SkImageInfo&, int sampleCount, 111 static SkSurface* NewScratchRenderTarget(GrContext* gr, const SkImageInfo& i nfo,
109 const SkSurfaceProps* = NULL); 112 int sampleCount, const SkSurfacePro ps* props) {
113 return NewRenderTarget(gr, kYes_Budgeted, info, sampleCount, props);
114 }
110 115
111 static SkSurface* NewScratchRenderTarget(GrContext* gr, const SkImageInfo& i nfo) { 116 /**
112 return NewScratchRenderTarget(gr, info, 0, NULL); 117 * Deprecated - use the version that takes a Budgeted param.
118 */
119 static SkSurface* NewRenderTarget(GrContext* gr, const SkImageInfo& info, in t sampleCount,
120 const SkSurfaceProps* props) {
121 return NewRenderTarget(gr, kNo_Budgeted, info, sampleCount, props);
113 } 122 }
114 123
115 int width() const { return fWidth; } 124 int width() const { return fWidth; }
116 int height() const { return fHeight; } 125 int height() const { return fHeight; }
117 126
118 /** 127 /**
119 * Returns a unique non-zero, unique value identifying the content of this 128 * Returns a unique non-zero, unique value identifying the content of this
120 * surface. Each time the content is changed changed, either by drawing 129 * surface. Each time the content is changed changed, either by drawing
121 * into this surface, or explicitly calling notifyContentChanged()) this 130 * into this surface, or explicitly calling notifyContentChanged()) this
122 * method will return a new value. 131 * method will return a new value.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 private: 243 private:
235 const SkSurfaceProps fProps; 244 const SkSurfaceProps fProps;
236 const int fWidth; 245 const int fWidth;
237 const int fHeight; 246 const int fHeight;
238 uint32_t fGenerationID; 247 uint32_t fGenerationID;
239 248
240 typedef SkRefCnt INHERITED; 249 typedef SkRefCnt INHERITED;
241 }; 250 };
242 251
243 #endif 252 #endif
OLDNEW
« no previous file with comments | « gm/xfermodes3.cpp ('k') | include/gpu/GrGpuResource.h » ('j') | tests/SurfaceTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698