Loading libs/hwui/PathCache.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -278,7 +279,9 @@ void PathCache::addTexture(const PathDescription& entry, SkBitmap* bitmap, PathT if (mDebugEnabled) { ALOGD("Shape created, size = %d", size); } if (addToCache) { mCache.put(entry, texture); } } else { texture->cleanup = true; } Loading Loading @@ -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"); Loading @@ -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); } Loading libs/hwui/PathCache.h +7 −6 Original line number Diff line number Diff line Loading @@ -253,7 +253,13 @@ private: PathTexture* addTexture(const PathDescription& entry, const SkPath *path, const SkPaint* paint); PathTexture* addTexture(const PathDescription& entry, SkBitmap* bitmap); void addTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture); /** * Generates the texture from a bitmap into the specified texture structure. */ void generateTexture(SkBitmap& bitmap, Texture* texture); void generateTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture, bool addToCache = true); PathTexture* get(const PathDescription& entry) { return mCache.get(entry); Loading Loading @@ -282,11 +288,6 @@ private: return true; } /** * Generates the texture from a bitmap into the specified texture structure. */ void generateTexture(SkBitmap& bitmap, Texture* texture); void init(); class PathTask: public Task<SkBitmap*> { Loading Loading
libs/hwui/PathCache.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -278,7 +279,9 @@ void PathCache::addTexture(const PathDescription& entry, SkBitmap* bitmap, PathT if (mDebugEnabled) { ALOGD("Shape created, size = %d", size); } if (addToCache) { mCache.put(entry, texture); } } else { texture->cleanup = true; } Loading Loading @@ -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"); Loading @@ -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); } Loading
libs/hwui/PathCache.h +7 −6 Original line number Diff line number Diff line Loading @@ -253,7 +253,13 @@ private: PathTexture* addTexture(const PathDescription& entry, const SkPath *path, const SkPaint* paint); PathTexture* addTexture(const PathDescription& entry, SkBitmap* bitmap); void addTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture); /** * Generates the texture from a bitmap into the specified texture structure. */ void generateTexture(SkBitmap& bitmap, Texture* texture); void generateTexture(const PathDescription& entry, SkBitmap* bitmap, PathTexture* texture, bool addToCache = true); PathTexture* get(const PathDescription& entry) { return mCache.get(entry); Loading Loading @@ -282,11 +288,6 @@ private: return true; } /** * Generates the texture from a bitmap into the specified texture structure. */ void generateTexture(SkBitmap& bitmap, Texture* texture); void init(); class PathTask: public Task<SkBitmap*> { Loading