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

Side by Side Diff: src/gpu/GrClipMaskCache.h

Issue 477323006: Revert of Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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/gpu/GrGpuResource.h ('k') | src/gpu/GrClipMaskManager.h » ('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 GrClipMaskCache_DEFINED 8 #ifndef GrClipMaskCache_DEFINED
9 #define GrClipMaskCache_DEFINED 9 #define GrClipMaskCache_DEFINED
10 10
(...skipping 23 matching lines...) Expand all
34 bool canReuse(int32_t clipGenID, const SkIRect& bounds) { 34 bool canReuse(int32_t clipGenID, const SkIRect& bounds) {
35 35
36 SkASSERT(clipGenID != SkClipStack::kWideOpenGenID); 36 SkASSERT(clipGenID != SkClipStack::kWideOpenGenID);
37 SkASSERT(clipGenID != SkClipStack::kEmptyGenID); 37 SkASSERT(clipGenID != SkClipStack::kEmptyGenID);
38 38
39 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); 39 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back();
40 40
41 // We could reuse the mask if bounds is a subset of last bounds. We'd ha ve to communicate 41 // We could reuse the mask if bounds is a subset of last bounds. We'd ha ve to communicate
42 // an offset to the caller. 42 // an offset to the caller.
43 if (back->fLastMask.texture() && 43 if (back->fLastMask.texture() &&
44 !back->fLastMask.texture()->wasDestroyed() &&
45 back->fLastBound == bounds && 44 back->fLastBound == bounds &&
46 back->fLastClipGenID == clipGenID) { 45 back->fLastClipGenID == clipGenID) {
47 return true; 46 return true;
48 } 47 }
49 48
50 return false; 49 return false;
51 } 50 }
52 51
53 void reset() { 52 void reset() {
54 if (fStack.empty()) { 53 if (fStack.empty()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 172 }
174 173
175 void setContext(GrContext* context) { 174 void setContext(GrContext* context) {
176 fContext = context; 175 fContext = context;
177 } 176 }
178 177
179 GrContext* getContext() { 178 GrContext* getContext() {
180 return fContext; 179 return fContext;
181 } 180 }
182 181
183 // TODO: Remove this when we hold cache keys instead of refs to textures. 182 void releaseResources() {
184 void purgeResources() { 183
185 SkDeque::F2BIter iter(fStack); 184 SkDeque::F2BIter iter(fStack);
186 for (GrClipStackFrame* frame = (GrClipStackFrame*) iter.next(); 185 for (GrClipStackFrame* frame = (GrClipStackFrame*) iter.next();
187 frame != NULL; 186 frame != NULL;
188 frame = (GrClipStackFrame*) iter.next()) { 187 frame = (GrClipStackFrame*) iter.next()) {
189 frame->reset(); 188 frame->reset();
190 } 189 }
191 } 190 }
192 191
193 private: 192 private:
194 struct GrClipStackFrame { 193 struct GrClipStackFrame {
(...skipping 18 matching lines...) Expand all
213 fLastClipGenID = SkClipStack::kInvalidGenID; 212 fLastClipGenID = SkClipStack::kInvalidGenID;
214 213
215 GrTextureDesc desc; 214 GrTextureDesc desc;
216 215
217 fLastMask.set(NULL, desc); 216 fLastMask.set(NULL, desc);
218 fLastBound.setEmpty(); 217 fLastBound.setEmpty();
219 } 218 }
220 219
221 int32_t fLastClipGenID; 220 int32_t fLastClipGenID;
222 // The mask's width & height values are used by GrClipMaskManager to cor rectly scale the 221 // The mask's width & height values are used by GrClipMaskManager to cor rectly scale the
223 // texture coords for the geometry drawn with this mask. TODO: This shou ld be a cache key 222 // texture coords for the geometry drawn with this mask.
224 // and not a hard ref to a texture.
225 GrAutoScratchTexture fLastMask; 223 GrAutoScratchTexture fLastMask;
226 // fLastBound stores the bounding box of the clip mask in clip-stack spa ce. This rect is 224 // fLastBound stores the bounding box of the clip mask in clip-stack spa ce. This rect is
227 // used by GrClipMaskManager to position a rect and compute texture coor ds for the mask. 225 // used by GrClipMaskManager to position a rect and compute texture coor ds for the mask.
228 SkIRect fLastBound; 226 SkIRect fLastBound;
229 }; 227 };
230 228
231 GrContext* fContext; 229 GrContext* fContext;
232 SkDeque fStack; 230 SkDeque fStack;
233 231
234 typedef SkNoncopyable INHERITED; 232 typedef SkNoncopyable INHERITED;
235 }; 233 };
236 234
237 #endif // GrClipMaskCache_DEFINED 235 #endif // GrClipMaskCache_DEFINED
OLDNEW
« no previous file with comments | « include/gpu/GrGpuResource.h ('k') | src/gpu/GrClipMaskManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698