summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2015-11-10 23:20:03 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-11-10 23:20:03 +0000
commit37bf3ec9d2fb3dfdccfe043e51723e4e543f0703 (patch)
treebf733341a7a586f01bb1e9c91c2327813b61b935 /libs
parent8d8515e708f0cebf69587750bbb3abcb315cc61e (diff)
parent2e4f67c388aff0def50dd619388624f1dbe359ad (diff)
Merge "Fix HWUI Path Cache dangling pointer"
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp5
-rw-r--r--libs/hwui/PathCache.cpp7
-rw-r--r--libs/hwui/PathCache.h1
3 files changed, 12 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;
}
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 3af640f76365..3236f6f7c24d 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -400,6 +400,13 @@ PathTexture* PathCache::get(const SkPath* path, const SkPaint* paint) {
return texture;
}
+void PathCache::remove(const SkPath* path, const SkPaint* paint)
+{
+ PathDescription entry(kShapePath, paint);
+ entry.shape.path.mGenerationID = path->getGenerationID();
+ mCache.remove(entry);
+}
+
void PathCache::precache(const SkPath* path, const SkPaint* paint) {
if (!Caches::getInstance().tasks.canRunTasks()) {
return;
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 70148631db34..c529915988d9 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -201,6 +201,7 @@ public:
PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
bool useCenter, const SkPaint* paint);
PathTexture* get(const SkPath* path, const SkPaint* paint);
+ void remove(const SkPath* path, const SkPaint* paint);
/**
* Removes the specified path. This is meant to be called from threads