diff options
author | 2013-03-26 17:29:51 -0700 | |
---|---|---|
committer | 2013-03-26 17:29:51 -0700 | |
commit | 4500a8d5d7fbec9dba5e693212da160849e401ff (patch) | |
tree | 1022f0099762a9ef2058da7240a2809659527846 /libs/hwui/PathCache.cpp | |
parent | 96885eb480c5e0526fe2f77d30f6e551f3f3ceab (diff) |
Path precaching creates duplicate cache entries
Bug #8478275
Change-Id: Ib541ea051e42e01cc0d277790e9c09de38ef72ee
Diffstat (limited to 'libs/hwui/PathCache.cpp')
-rw-r--r-- | libs/hwui/PathCache.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 07c420721fa5..fdb10e2f2c55 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -262,12 +262,13 @@ PathTexture* PathCache::addTexture(const PathDescription& entry, const SkPath *p PathTexture* texture = createTexture(left, top, offset, width, height, path->getGenerationID()); - addTexture(entry, &bitmap, texture); + generateTexture(entry, &bitmap, texture); return texture; } -void PathCache::addTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture) { +void PathCache::generateTexture(const PathDescription& entry, SkBitmap* bitmap, + PathTexture* texture, bool addToCache) { generateTexture(*bitmap, texture); uint32_t size = texture->width * texture->height; @@ -278,7 +279,9 @@ void PathCache::addTexture(const PathDescription& entry, SkBitmap* bitmap, PathT if (mDebugEnabled) { ALOGD("Shape created, size = %d", size); } - mCache.put(entry, texture); + if (addToCache) { + mCache.put(entry, texture); + } } else { texture->cleanup = true; } @@ -414,7 +417,7 @@ PathTexture* PathCache::get(SkPath* path, SkPaint* paint) { // producing the bitmap, so let's wait SkBitmap* bitmap = task->getResult(); if (bitmap) { - addTexture(entry, bitmap, texture); + generateTexture(entry, bitmap, texture, false); texture->clearTask(); } else { ALOGW("Path too large to be rendered into a texture"); @@ -423,6 +426,8 @@ PathTexture* PathCache::get(SkPath* path, SkPaint* paint) { mCache.remove(entry); } } else if (path->getGenerationID() != texture->generation) { + // The size of the path might have changed so we first + // remove the entry from the cache mCache.remove(entry); texture = addTexture(entry, path, paint); } |