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

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

Issue 933043006: Implement SkBaseDevice snapshot support Base URL: https://skia.googlesource.com/skia.git@skimage-filters-04-snapshot-devices
Patch Set: Created 5 years, 9 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
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const SkSurfaceProps* = NULL); 102 const SkSurfaceProps* = NULL);
103 103
104 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn fo& info) { 104 static SkSurface* NewRenderTarget(GrContext* gr, Budgeted b, const SkImageIn fo& info) {
105 return NewRenderTarget(gr, b, info, 0, NULL); 105 return NewRenderTarget(gr, b, info, 0, NULL);
106 } 106 }
107 107
108 int width() const { return fWidth; } 108 int width() const { return fWidth; }
109 int height() const { return fHeight; } 109 int height() const { return fHeight; }
110 110
111 /** 111 /**
112 * Returns a unique non-zero, unique value identifying the content of this 112 * Returns a unique non-zero value identifying the content of this
113 * surface. Each time the content is changed changed, either by drawing 113 * surface. Each time the content is changed changed by drawing
114 * into this surface, or explicitly calling notifyContentChanged()) this 114 * into this surface through the canvas, this method will return a new
115 * method will return a new value. 115 * value.
116 * 116 *
117 * If this surface is empty (i.e. has a zero-dimention), this will return 117 * Implementations guarantee that all generationIDs are unique among
118 * all possible SkSurfaces and their possible contents.
119 *
120 * If this surface is empty (i.e. has a zero-dimension), this will return
118 * 0. 121 * 0.
119 */ 122 */
120 uint32_t generationID(); 123 virtual uint32_t generationID() = 0;
121
122 /**
123 * Modes that can be passed to notifyContentWillChange
124 */
125 enum ContentChangeMode {
126 /**
127 * Use this mode if it is known that the upcoming content changes will
128 * clear or overwrite prior contents, thus making them discardable.
129 */
130 kDiscard_ContentChangeMode,
131 /**
132 * Use this mode if prior surface contents need to be preserved or
133 * if in doubt.
134 */
135 kRetain_ContentChangeMode,
136 };
137
138 /**
139 * Call this if the contents are about to change. This will (lazily) force a new
140 * value to be returned from generationID() when it is called next.
141 */
142 void notifyContentWillChange(ContentChangeMode mode);
143 124
144 /** 125 /**
145 * Return a canvas that will draw into this surface. This will always 126 * Return a canvas that will draw into this surface. This will always
146 * return the same canvas for a given surface, and is manged/owned by the 127 * return the same canvas for a given surface, and is manged/owned by the
147 * surface. It should not be used when its parent surface has gone out of 128 * surface. It should not be used when its parent surface has gone out of
148 * scope. 129 * scope.
149 */ 130 */
150 SkCanvas* getCanvas(); 131 SkCanvas* getCanvas();
151 132
152 /** 133 /**
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 */ 195 */
215 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes, 196 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes,
216 int srcX, int srcY); 197 int srcX, int srcY);
217 198
218 const SkSurfaceProps& props() const { return fProps; } 199 const SkSurfaceProps& props() const { return fProps; }
219 200
220 protected: 201 protected:
221 SkSurface(int width, int height, const SkSurfaceProps*); 202 SkSurface(int width, int height, const SkSurfaceProps*);
222 SkSurface(const SkImageInfo&, const SkSurfaceProps*); 203 SkSurface(const SkImageInfo&, const SkSurfaceProps*);
223 204
224 // called by subclass if their contents have changed
225 void dirtyGenerationID() {
226 fGenerationID = 0;
227 }
228
229 private: 205 private:
230 const SkSurfaceProps fProps; 206 const SkSurfaceProps fProps;
231 const int fWidth; 207 const int fWidth;
232 const int fHeight; 208 const int fHeight;
233 uint32_t fGenerationID;
234 209
235 typedef SkRefCnt INHERITED; 210 typedef SkRefCnt INHERITED;
236 }; 211 };
237 212
238 #endif 213 #endif
OLDNEW
« no previous file with comments | « include/core/SkDevice.h ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698