From 4bcb7467a174ed03a67b0c62950c555813ddf00d Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 23 Feb 2012 17:08:38 -0800 Subject: Only recreate path textures when necessary When a drawPath command is recorded in a display list, a copy of the source path is made to preserve against possible modifications of the said source path. Copies are discarded when a display list is cleared, which usually happens on invalidate(). This means that even if a path is never modified, the texture generated to draw it on screen is destroyed every time an invalidate() is issued. This change fixes this problem by introducing a reference to the source path in the copy. If both the copy and the source path have the same genID, they are the same path and can share the same texture. Change-Id: I34849311c183e06336a1391d2d1568a087f973f6 --- libs/hwui/PathCache.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libs/hwui/PathCache.cpp') diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index e09c24381d9d..e363b73498df 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -83,6 +83,11 @@ void PathCache::clearGarbage() { } PathTexture* PathCache::get(SkPath* path, SkPaint* paint) { + const SkPath* sourcePath = path->getSourcePath(); + if (sourcePath && sourcePath->getGenerationID() == path->getGenerationID()) { + path = const_cast(sourcePath); + } + PathCacheEntry entry(path, paint); PathTexture* texture = mCache.get(entry); -- cgit v1.2.3-59-g8ed1b