OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrLayerCache_DEFINED | 8 #ifndef GrLayerCache_DEFINED |
9 #define GrLayerCache_DEFINED | 9 #define GrLayerCache_DEFINED |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL) | 157 , fPaint(paint ? SkNEW_ARGS(SkPaint, (*paint)) : NULL) |
158 , fFilter(NULL) | 158 , fFilter(NULL) |
159 , fTexture(NULL) | 159 , fTexture(NULL) |
160 , fRect(SkIRect::MakeEmpty()) | 160 , fRect(SkIRect::MakeEmpty()) |
161 , fPlot(NULL) | 161 , fPlot(NULL) |
162 , fUses(0) | 162 , fUses(0) |
163 , fLocked(false) { | 163 , fLocked(false) { |
164 SkASSERT(SK_InvalidGenID != pictureID); | 164 SkASSERT(SK_InvalidGenID != pictureID); |
165 | 165 |
166 if (fPaint) { | 166 if (fPaint) { |
167 if (fPaint->getImageFilter() && fPaint->getImageFilter()->canFilterI
mageGPU()) { | 167 if (fPaint->getImageFilter()) { |
168 fFilter = SkSafeRef(fPaint->getImageFilter()); | 168 fFilter = SkSafeRef(fPaint->getImageFilter()); |
169 fPaint->setImageFilter(NULL); | 169 fPaint->setImageFilter(NULL); |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 ~GrCachedLayer() { | 174 ~GrCachedLayer() { |
175 SkSafeUnref(fTexture); | 175 SkSafeUnref(fTexture); |
176 SkSafeUnref(fFilter); | 176 SkSafeUnref(fFilter); |
177 SkDELETE(fPaint); | 177 SkDELETE(fPaint); |
178 } | 178 } |
179 | 179 |
180 uint32_t pictureID() const { return fKey.pictureID(); } | 180 uint32_t pictureID() const { return fKey.pictureID(); } |
181 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse | 181 // TODO: remove these when GrCachedLayer & ReplacementInfo fuse |
182 const unsigned* key() const { return fKey.key(); } | 182 const unsigned* key() const { return fKey.key(); } |
183 int keySize() const { return fKey.keySize(); } | 183 int keySize() const { return fKey.keySize(); } |
184 | 184 |
185 unsigned start() const { return fStart; } | 185 unsigned start() const { return fStart; } |
186 // TODO: make bound debug only | 186 // TODO: make bound debug only |
187 const SkIRect& srcIR() const { return fSrcIR; } | 187 const SkIRect& srcIR() const { return fSrcIR; } |
188 const SkIRect& dstIR() const { return fDstIR; } | 188 const SkIRect& dstIR() const { return fDstIR; } |
189 unsigned stop() const { return fStop; } | 189 unsigned stop() const { return fStop; } |
190 void setTexture(GrTexture* texture, const SkIRect& rect) { | 190 void setTexture(GrTexture* texture, const SkIRect& rect) { |
191 SkRefCnt_SafeAssign(fTexture, texture); | 191 SkRefCnt_SafeAssign(fTexture, texture); |
192 fRect = rect; | 192 fRect = rect; |
| 193 if (!fTexture) { |
| 194 fLocked = false; |
| 195 } |
193 } | 196 } |
194 GrTexture* texture() { return fTexture; } | 197 GrTexture* texture() { return fTexture; } |
195 const SkPaint* paint() const { return fPaint; } | 198 const SkPaint* paint() const { return fPaint; } |
196 const SkImageFilter* filter() const { return fFilter; } | 199 const SkImageFilter* filter() const { return fFilter; } |
197 const SkIRect& rect() const { return fRect; } | 200 const SkIRect& rect() const { return fRect; } |
198 | 201 |
199 void setOffset(const SkIPoint& offset) { fOffset = offset; } | 202 void setOffset(const SkIPoint& offset) { fOffset = offset; } |
200 const SkIPoint& offset() const { return fOffset; } | 203 const SkIPoint& offset() const { return fOffset; } |
201 | 204 |
202 void setPlot(GrPlot* plot) { | 205 void setPlot(GrPlot* plot) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 SkASSERT(fPlotLocks[plotIdx] > 0); | 398 SkASSERT(fPlotLocks[plotIdx] > 0); |
396 --fPlotLocks[plotIdx]; | 399 --fPlotLocks[plotIdx]; |
397 } | 400 } |
398 | 401 |
399 // for testing | 402 // for testing |
400 friend class TestingAccess; | 403 friend class TestingAccess; |
401 int numLayers() const { return fLayerHash.count(); } | 404 int numLayers() const { return fLayerHash.count(); } |
402 }; | 405 }; |
403 | 406 |
404 #endif | 407 #endif |
OLD | NEW |