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 GrClipMaskCache_DEFINED | 8 #ifndef GrClipMaskCache_DEFINED |
9 #define GrClipMaskCache_DEFINED | 9 #define GrClipMaskCache_DEFINED |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 SkASSERT(false); | 107 SkASSERT(false); |
108 return NULL; | 108 return NULL; |
109 } | 109 } |
110 | 110 |
111 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 111 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
112 | 112 |
113 return back->fLastMask; | 113 return back->fLastMask; |
114 } | 114 } |
115 | 115 |
116 void acquireMask(int32_t clipGenID, | 116 void acquireMask(int32_t clipGenID, |
117 const GrTextureDesc& desc, | 117 const GrSurfaceDesc& desc, |
118 const SkIRect& bound) { | 118 const SkIRect& bound) { |
119 | 119 |
120 if (fStack.empty()) { | 120 if (fStack.empty()) { |
121 SkASSERT(false); | 121 SkASSERT(false); |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); | 125 GrClipStackFrame* back = (GrClipStackFrame*) fStack.back(); |
126 | 126 |
127 back->acquireMask(fContext, clipGenID, desc, bound); | 127 back->acquireMask(fContext, clipGenID, desc, bound); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 private: | 193 private: |
194 struct GrClipStackFrame { | 194 struct GrClipStackFrame { |
195 | 195 |
196 GrClipStackFrame() { | 196 GrClipStackFrame() { |
197 this->reset(); | 197 this->reset(); |
198 } | 198 } |
199 | 199 |
200 void acquireMask(GrContext* context, | 200 void acquireMask(GrContext* context, |
201 int32_t clipGenID, | 201 int32_t clipGenID, |
202 const GrTextureDesc& desc, | 202 const GrSurfaceDesc& desc, |
203 const SkIRect& bound) { | 203 const SkIRect& bound) { |
204 | 204 |
205 fLastClipGenID = clipGenID; | 205 fLastClipGenID = clipGenID; |
206 | 206 |
207 // HACK: set the last param to true to indicate that this request is
at | 207 // HACK: set the last param to true to indicate that this request is
at |
208 // flush time and therefore we require a scratch texture with no pen
ding IO operations. | 208 // flush time and therefore we require a scratch texture with no pen
ding IO operations. |
209 fLastMask.reset(context->refScratchTexture(desc, GrContext::kApprox_
ScratchTexMatch, | 209 fLastMask.reset(context->refScratchTexture(desc, GrContext::kApprox_
ScratchTexMatch, |
210 /*flushing=*/true)); | 210 /*flushing=*/true)); |
211 | 211 |
212 fLastBound = bound; | 212 fLastBound = bound; |
213 } | 213 } |
214 | 214 |
215 void reset () { | 215 void reset () { |
216 fLastClipGenID = SkClipStack::kInvalidGenID; | 216 fLastClipGenID = SkClipStack::kInvalidGenID; |
217 | 217 |
218 GrTextureDesc desc; | 218 GrSurfaceDesc desc; |
219 | 219 |
220 fLastMask.reset(NULL); | 220 fLastMask.reset(NULL); |
221 fLastBound.setEmpty(); | 221 fLastBound.setEmpty(); |
222 } | 222 } |
223 | 223 |
224 int32_t fLastClipGenID; | 224 int32_t fLastClipGenID; |
225 // The mask's width & height values are used by GrClipMaskManager to cor
rectly scale the | 225 // The mask's width & height values are used by GrClipMaskManager to cor
rectly scale the |
226 // texture coords for the geometry drawn with this mask. TODO: This shou
ld be a cache key | 226 // texture coords for the geometry drawn with this mask. TODO: This shou
ld be a cache key |
227 // and not a hard ref to a texture. | 227 // and not a hard ref to a texture. |
228 SkAutoTUnref<GrTexture> fLastMask; | 228 SkAutoTUnref<GrTexture> fLastMask; |
229 // fLastBound stores the bounding box of the clip mask in clip-stack spa
ce. This rect is | 229 // fLastBound stores the bounding box of the clip mask in clip-stack spa
ce. This rect is |
230 // used by GrClipMaskManager to position a rect and compute texture coor
ds for the mask. | 230 // used by GrClipMaskManager to position a rect and compute texture coor
ds for the mask. |
231 SkIRect fLastBound; | 231 SkIRect fLastBound; |
232 }; | 232 }; |
233 | 233 |
234 GrContext* fContext; | 234 GrContext* fContext; |
235 SkDeque fStack; | 235 SkDeque fStack; |
236 | 236 |
237 typedef SkNoncopyable INHERITED; | 237 typedef SkNoncopyable INHERITED; |
238 }; | 238 }; |
239 | 239 |
240 #endif // GrClipMaskCache_DEFINED | 240 #endif // GrClipMaskCache_DEFINED |
OLD | NEW |