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

Unified Diff: src/gpu/GrLayerCache.cpp

Issue 654463004: Fix bug in aggressive layer cache purging (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerCache.cpp
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index a24c9e040b70bb7ecd3581e48cd9dacc4cd4c617..f60b6a8120a6792aef1f04d7fca8d3af3e897850 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -100,6 +100,7 @@ GrLayerCache::~GrLayerCache() {
void GrLayerCache::initAtlas() {
SkASSERT(NULL == fAtlas.get());
+ GR_STATIC_ASSERT(kNumPlotsX*kNumPlotsX == GrPictureInfo::kNumPlots);
SkISize textureSize = SkISize::Make(kAtlasTextureWidth, kAtlasTextureHeight);
fAtlas.reset(SkNEW_ARGS(GrAtlas, (fContext->getGpu(), kSkia8888_GrPixelConfig,
@@ -201,6 +202,9 @@ bool GrLayerCache::tryToAtlas(GrCachedLayer* layer,
// addToAtlas can allocate the backing texture
SkDEBUGCODE(avl.setBackingTexture(fAtlas->getTexture()));
if (plot) {
+#if !GR_CACHE_HOISTED_LAYERS
+ pictInfo->incPlotUsage(plot->id());
+#endif
// The layer was successfully added to the atlas
GrIRect16 bounds = GrIRect16::MakeXYWH(loc.fX, loc.fY,
SkToS16(desc.fWidth),
@@ -264,8 +268,12 @@ void GrLayerCache::unlock(GrCachedLayer* layer) {
// render target pingponging from that due to the re-use of cached layers
GrPictureInfo* pictInfo = fPictureHash.find(layer->pictureID());
SkASSERT(pictInfo);
-
- GrAtlas::RemovePlot(&pictInfo->fPlotUsage, layer->plot());
+
+ pictInfo->decPlotUsage(plotID);
+
+ if (0 == pictInfo->plotUsage(plotID)) {
+ GrAtlas::RemovePlot(&pictInfo->fPlotUsage, layer->plot());
+ }
layer->setPlot(NULL);
layer->setTexture(NULL, GrIRect16::MakeEmpty());
@@ -301,6 +309,9 @@ void GrLayerCache::validate() const {
SkASSERT(pictInfo->fPictureID == layer->pictureID());
SkASSERT(pictInfo->fPlotUsage.contains(layer->plot()));
+#if !GR_CACHE_HOISTED_LAYERS
+ SkASSERT(pictInfo->plotUsage(layer->plot()->id()) > 0);
+#endif
if (layer->locked()) {
plotLocks[layer->plot()->id()]++;
@@ -400,6 +411,9 @@ void GrLayerCache::purgePlot(GrPlot* plot) {
GrPictureInfo* pictInfo = fPictureHash.find(pictureIDToRemove);
if (pictInfo) {
+#if !GR_CACHE_HOISTED_LAYERS
+ SkASSERT(0 == pictInfo->plotUsage(plot->id()));
+#endif
GrAtlas::RemovePlot(&pictInfo->fPlotUsage, plot);
if (pictInfo->fPlotUsage.isEmpty()) {
« no previous file with comments | « src/gpu/GrLayerCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698