OSDN Git Service

hwui : fix memory leak due to duplicate in shadow cache
authorMykola Kondratenko <mykola.kondratenko@sonymobile.com>
Thu, 12 Mar 2015 14:20:38 +0000 (15:20 +0100)
committerHenrik Baard <henrik.baard@sonymobile.com>
Tue, 17 Mar 2015 07:57:41 +0000 (08:57 +0100)
New ShadowTask with the ShadowDescription key that already
exists in the shadow LruCache will leak as it is not being
added.

Fix adds check for the existing key that is common in the hwui
code but missing for the TessellationCache::precacheShadow
function.

Change-Id: I37fd5ec82f8b8da5d1ec0f2ab9fd04c5f8534367

libs/hwui/TessellationCache.cpp

index bc956be..1d6b7cc 100644 (file)
@@ -380,6 +380,7 @@ void TessellationCache::precacheShadows(const Matrix4* drawTransform, const Rect
         const Vector3& lightCenter, float lightRadius) {
     ShadowDescription key(casterPerimeter, drawTransform);
 
+    if (mShadowCache.get(key)) return;
     sp<ShadowTask> task = new ShadowTask(drawTransform, localClip, opaque,
             casterPerimeter, transformXY, transformZ, lightCenter, lightRadius);
     if (mShadowProcessor == NULL) {