aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-11-04 06:46:11 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-04 06:46:11 -0800
commitb32f0ad89119625feedb4f0403bbbc94fae44668 (patch)
treea99845c2eaf4d2cf2e0375ac192ae10208994ce2
parent5698f91d602dc974ad5c453ff9588ded7353050b (diff)
Fix layer cache memory leak
The issue was that, with caching disabled, the layer cache code was removing layers outside of a purge (i.e., in unlock) but not correctly cleaning up the GrPictureInfo objects (as is done in purgePlot). Review URL: https://codereview.chromium.org/703643002
-rw-r--r--src/gpu/GrLayerCache.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index f60b6a8120..d4f8b70b39 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -94,6 +94,8 @@ GrLayerCache::~GrLayerCache() {
SkDELETE(layer);
}
+ SkASSERT(0 == fPictureHash.count());
+
// The atlas only lets go of its texture when the atlas is deleted.
fAtlas.free();
}
@@ -273,6 +275,11 @@ void GrLayerCache::unlock(GrCachedLayer* layer) {
if (0 == pictInfo->plotUsage(plotID)) {
GrAtlas::RemovePlot(&pictInfo->fPlotUsage, layer->plot());
+
+ if (pictInfo->fPlotUsage.isEmpty()) {
+ fPictureHash.remove(pictInfo->fPictureID);
+ SkDELETE(pictInfo);
+ }
}
layer->setPlot(NULL);
@@ -442,6 +449,8 @@ void GrLayerCache::purgeAll() {
this->purgePlot(plot);
}
+ SkASSERT(0 == fPictureHash.count());
+
fContext->discardRenderTarget(fAtlas->getTexture()->asRenderTarget());
}
#endif