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

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

Issue 481443002: Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove removeHead 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
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() &&
44 back->fLastBound == bounds && 45 back->fLastBound == bounds &&
45 back->fLastClipGenID == clipGenID) { 46 back->fLastClipGenID == clipGenID) {
46 return true; 47 return true;
47 } 48 }
48 49
49 return false; 50 return false;
50 } 51 }
51 52
52 void reset() { 53 void reset() {
53 if (fStack.empty()) { 54 if (fStack.empty()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 173 }
173 174
174 void setContext(GrContext* context) { 175 void setContext(GrContext* context) {
175 fContext = context; 176 fContext = context;
176 } 177 }
177 178
178 GrContext* getContext() { 179 GrContext* getContext() {
179 return fContext; 180 return fContext;
180 } 181 }
181 182
182 void releaseResources() { 183 // TODO: Remove this when we hold cache keys instead of refs to textures.
183 184 void purgeResources() {
184 SkDeque::F2BIter iter(fStack); 185 SkDeque::F2BIter iter(fStack);
185 for (GrClipStackFrame* frame = (GrClipStackFrame*) iter.next(); 186 for (GrClipStackFrame* frame = (GrClipStackFrame*) iter.next();
186 frame != NULL; 187 frame != NULL;
187 frame = (GrClipStackFrame*) iter.next()) { 188 frame = (GrClipStackFrame*) iter.next()) {
188 frame->reset(); 189 frame->reset();
189 } 190 }
190 } 191 }
191 192
192 private: 193 private:
193 struct GrClipStackFrame { 194 struct GrClipStackFrame {
(...skipping 17 matching lines...) Expand all
211 void reset () { 212 void reset () {
212 fLastClipGenID = SkClipStack::kInvalidGenID; 213 fLastClipGenID = SkClipStack::kInvalidGenID;
213 214
214 GrTextureDesc desc; 215 GrTextureDesc desc;
215 216
216 fLastMask.set(NULL, desc); 217 fLastMask.set(NULL, desc);
217 fLastBound.setEmpty(); 218 fLastBound.setEmpty();
218 } 219 }
219 220
220 int32_t fLastClipGenID; 221 int32_t fLastClipGenID;
221 // The mask's width & height values are used by GrClipMaskManager to cor rectly scale the 222 // The mask's width & height values are used by GrClipMaskManager to cor rectly scale the
robertphillips 2014/08/15 19:36:17 overlength ?
bsalomon 2014/08/19 15:16:08 Done.
222 // texture coords for the geometry drawn with this mask. 223 // texture coords for the geometry drawn with this mask. TODO: This shou ld be a cache key and
224 // not a hard ref to a texture.
223 GrAutoScratchTexture fLastMask; 225 GrAutoScratchTexture fLastMask;
224 // fLastBound stores the bounding box of the clip mask in clip-stack spa ce. This rect is 226 // fLastBound stores the bounding box of the clip mask in clip-stack spa ce. This rect is
225 // used by GrClipMaskManager to position a rect and compute texture coor ds for the mask. 227 // used by GrClipMaskManager to position a rect and compute texture coor ds for the mask.
226 SkIRect fLastBound; 228 SkIRect fLastBound;
227 }; 229 };
228 230
229 GrContext* fContext; 231 GrContext* fContext;
230 SkDeque fStack; 232 SkDeque fStack;
231 233
232 typedef SkNoncopyable INHERITED; 234 typedef SkNoncopyable INHERITED;
233 }; 235 };
234 236
235 #endif // GrClipMaskCache_DEFINED 237 #endif // GrClipMaskCache_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698