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

Side by Side Diff: src/gpu/GrLayerHoister.cpp

Issue 640323002: Fix bug in GrCachedLayer reuse (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Improve comment Created 6 years, 2 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 | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('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 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 #include "GrLayerCache.h" 8 #include "GrLayerCache.h"
9 #include "GrLayerHoister.h" 9 #include "GrLayerHoister.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (needsRendering) { 47 if (needsRendering) {
48 if (layer->isAtlased()) { 48 if (layer->isAtlased()) {
49 hl = atlased->append(); 49 hl = atlased->append();
50 } else { 50 } else {
51 hl = nonAtlased->append(); 51 hl = nonAtlased->append();
52 } 52 }
53 } else { 53 } else {
54 hl = recycled->append(); 54 hl = recycled->append();
55 } 55 }
56 56
57 layerCache->addUse(layer);
57 hl->fLayer = layer; 58 hl->fLayer = layer;
58 hl->fPicture = pict; 59 hl->fPicture = pict;
59 hl->fOffset = info.fOffset; 60 hl->fOffset = info.fOffset;
60 hl->fCTM = info.fOriginXform; 61 hl->fCTM = info.fOriginXform;
61 } 62 }
62 63
63 // Return true if any layers are suitable for hoisting 64 // Return true if any layers are suitable for hoisting
64 bool GrLayerHoister::FindLayersToHoist(GrContext* context, 65 bool GrLayerHoister::FindLayersToHoist(GrContext* context,
65 const SkPicture* topLevelPicture, 66 const SkPicture* topLevelPicture,
66 const SkRect& query, 67 const SkRect& query,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 layer->start()+1, layer->stop(), initialCTM); 257 layer->start()+1, layer->stop(), initialCTM);
257 258
258 layerCanvas->flush(); 259 layerCanvas->flush();
259 } 260 }
260 261
261 convert_layers_to_replacements(atlased, replacements); 262 convert_layers_to_replacements(atlased, replacements);
262 convert_layers_to_replacements(nonAtlased, replacements); 263 convert_layers_to_replacements(nonAtlased, replacements);
263 convert_layers_to_replacements(recycled, replacements); 264 convert_layers_to_replacements(recycled, replacements);
264 } 265 }
265 266
266 static void unlock_layer_in_cache(GrLayerCache* layerCache,
267 const SkPicture* picture,
268 GrCachedLayer* layer) {
269 layerCache->unlock(layer);
270
271 #if DISABLE_CACHING
272 // This code completely clears out the atlas. It is required when
273 // caching is disabled so the atlas doesn't fill up and force more
274 // free floating layers
275 layerCache->purge(picture->uniqueID());
276 #endif
277 }
278
279 void GrLayerHoister::UnlockLayers(GrContext* context, 267 void GrLayerHoister::UnlockLayers(GrContext* context,
280 const SkTDArray<GrHoistedLayer>& atlased, 268 const SkTDArray<GrHoistedLayer>& atlased,
281 const SkTDArray<GrHoistedLayer>& nonAtlased, 269 const SkTDArray<GrHoistedLayer>& nonAtlased,
282 const SkTDArray<GrHoistedLayer>& recycled) { 270 const SkTDArray<GrHoistedLayer>& recycled) {
283 GrLayerCache* layerCache = context->getLayerCache(); 271 GrLayerCache* layerCache = context->getLayerCache();
284 272
285 for (int i = 0; i < atlased.count(); ++i) { 273 for (int i = 0; i < atlased.count(); ++i) {
286 unlock_layer_in_cache(layerCache, atlased[i].fPicture, atlased[i].fLayer ); 274 layerCache->removeUse(atlased[i].fLayer);
287 } 275 }
288 276
289 for (int i = 0; i < nonAtlased.count(); ++i) { 277 for (int i = 0; i < nonAtlased.count(); ++i) {
290 unlock_layer_in_cache(layerCache, nonAtlased[i].fPicture, nonAtlased[i]. fLayer); 278 layerCache->removeUse(nonAtlased[i].fLayer);
291 } 279 }
292 280
293 for (int i = 0; i < recycled.count(); ++i) { 281 for (int i = 0; i < recycled.count(); ++i) {
294 unlock_layer_in_cache(layerCache, recycled[i].fPicture, recycled[i].fLay er); 282 layerCache->removeUse(recycled[i].fLayer);
295 } 283 }
296 284
297 #if DISABLE_CACHING 285 #if DISABLE_CACHING
298 // This code completely clears out the atlas. It is required when 286 // This code completely clears out the atlas. It is required when
299 // caching is disabled so the atlas doesn't fill up and force more 287 // caching is disabled so the atlas doesn't fill up and force more
300 // free floating layers 288 // free floating layers
301 layerCache->purgeAll(); 289 layerCache->purgeAll();
302 #endif 290 #endif
291
292 SkDEBUGCODE(layerCache->validate();)
303 } 293 }
304 294
OLDNEW
« no previous file with comments | « src/gpu/GrLayerCache.cpp ('k') | tests/GpuLayerCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698