summaryrefslogtreecommitdiff
path: root/libs/hwui/OpenGLRenderer.cpp
diff options
context:
space:
mode:
author Digish Pandya <digishp@codeaurora.org> 2015-11-04 11:00:28 +0530
committer Digish Pandya <digishp@codeaurora.org> 2015-11-09 14:22:25 +0530
commit2e4f67c388aff0def50dd619388624f1dbe359ad (patch)
tree5a99d7887fb1583bf73be3215d3b1c17b1b8a343 /libs/hwui/OpenGLRenderer.cpp
parenta61515720ab95f6aa307c1fa4337c5c2078bad26 (diff)
Fix HWUI Path Cache dangling pointer
When precache, PathTexture is added to PathCache, and it is released after drawn if we want to clean it. But the PathCache LRU still holds the entry of the PathTexture object. When trim the cache in the end of each frame, LRU finds that its mListener is not NULL and invoke the functor, however, mListerer points to the released PathTexture object and is a dangling pointer, thus leads to crash. Smart pointer don't help here since they only manage scopes, while PathTexture is also controled by its cleanup field. The fix is to also remove the LRU entry of PathTexture*, it will also release the texture object and there won't be texture leaks. Change-Id: Iaa0621df5dc71532e9e75b38ad94384353930b95
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 2292ef415cfc..9621b545fada 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -2325,12 +2325,15 @@ void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) {
PathTexture* texture = mCaches.pathCache.get(path, paint);
if (!texture) return;
- const AutoTexture autoCleanup(texture);
const float x = texture->left - texture->offset;
const float y = texture->top - texture->offset;
drawPathTexture(texture, x, y, paint);
+
+ if (texture->cleanup) {
+ mCaches.pathCache.remove(path, paint);
+ }
mDirty = true;
}