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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 const SkIRect& bounds, const SkMatrix& ctm); | 204 const SkIRect& bounds, const SkMatrix& ctm); |
205 GrCachedLayer* findLayerOrCreate(uint32_t pictureID, | 205 GrCachedLayer* findLayerOrCreate(uint32_t pictureID, |
206 int start, int stop, | 206 int start, int stop, |
207 const SkIRect& bounds, | 207 const SkIRect& bounds, |
208 const SkMatrix& ctm, | 208 const SkMatrix& ctm, |
209 const SkPaint* paint); | 209 const SkPaint* paint); |
210 | 210 |
211 // Attempt to place 'layer' in the atlas. Return true on success; false on f
ailure. | 211 // Attempt to place 'layer' in the atlas. Return true on success; false on f
ailure. |
212 // When true is returned, 'needsRendering' will indicate if the layer must b
e (re)drawn. | 212 // When true is returned, 'needsRendering' will indicate if the layer must b
e (re)drawn. |
213 // Additionally, the GPU resources will be locked. | 213 // Additionally, the GPU resources will be locked. |
214 bool tryToAtlas(GrCachedLayer* layer, const GrTextureDesc& desc, bool* needs
Rendering); | 214 bool tryToAtlas(GrCachedLayer* layer, const GrSurfaceDesc& desc, bool* needs
Rendering); |
215 | 215 |
216 // Attempt to lock the GPU resources required for a layer. Return true on su
ccess; | 216 // Attempt to lock the GPU resources required for a layer. Return true on su
ccess; |
217 // false on failure. When true is returned 'needsRendering' will indicate if
the | 217 // false on failure. When true is returned 'needsRendering' will indicate if
the |
218 // layer must be (re)drawn. | 218 // layer must be (re)drawn. |
219 // Note that atlased layers should already have been locked and rendered so
only | 219 // Note that atlased layers should already have been locked and rendered so
only |
220 // free floating layers will have 'needsRendering' set. | 220 // free floating layers will have 'needsRendering' set. |
221 // Currently, this path always uses a new scratch texture for non-Atlased la
yers | 221 // Currently, this path always uses a new scratch texture for non-Atlased la
yers |
222 // and (thus) doesn't cache anything. This can yield a lot of re-rendering. | 222 // and (thus) doesn't cache anything. This can yield a lot of re-rendering. |
223 // TODO: allow rediscovery of free-floating layers that are still in the res
ource cache. | 223 // TODO: allow rediscovery of free-floating layers that are still in the res
ource cache. |
224 bool lock(GrCachedLayer* layer, const GrTextureDesc& desc, bool* needsRender
ing); | 224 bool lock(GrCachedLayer* layer, const GrSurfaceDesc& desc, bool* needsRender
ing); |
225 | 225 |
226 // addUse is just here to keep the API symmetric | 226 // addUse is just here to keep the API symmetric |
227 void addUse(GrCachedLayer* layer) { layer->addUse(); } | 227 void addUse(GrCachedLayer* layer) { layer->addUse(); } |
228 void removeUse(GrCachedLayer* layer) { | 228 void removeUse(GrCachedLayer* layer) { |
229 layer->removeUse(); | 229 layer->removeUse(); |
230 if (layer->uses() == 0) { | 230 if (layer->uses() == 0) { |
231 // If no one cares about the layer allow it to be recycled. | 231 // If no one cares about the layer allow it to be recycled. |
232 this->unlock(layer); | 232 this->unlock(layer); |
233 } | 233 } |
234 } | 234 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 SkASSERT(fPlotLocks[plotIdx] > 0); | 307 SkASSERT(fPlotLocks[plotIdx] > 0); |
308 --fPlotLocks[plotIdx]; | 308 --fPlotLocks[plotIdx]; |
309 } | 309 } |
310 | 310 |
311 // for testing | 311 // for testing |
312 friend class TestingAccess; | 312 friend class TestingAccess; |
313 int numLayers() const { return fLayerHash.count(); } | 313 int numLayers() const { return fLayerHash.count(); } |
314 }; | 314 }; |
315 | 315 |
316 #endif | 316 #endif |
OLD | NEW |