From ee648e517f09cccf59010a7423240a38aaeb2c04 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Tue, 9 Dec 2014 10:54:16 -0500 Subject: Remove unnecessary/erroneous reference counting The SkBitmap* used by HWUI holds a reference to the PixelRef (which in turn holds the colorTable) so keeping an additional ref is not only unnecessary, but also potentially problematic. If a bitmap changes its pixelRef after it has been added to a displayList, then we end up with unbalanced ref/unref calls that cause the newly added PixelRef to be unref'd and prematurely deleted, while the original PixelRef is leaked. bug: 18659976 Change-Id: I34a06152e7bb2d733249a207dafd36b9b5dc0712 --- libs/hwui/ResourceCache.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'libs/hwui') diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp index 717ce9a..31bd637 100644 --- a/libs/hwui/ResourceCache.cpp +++ b/libs/hwui/ResourceCache.cpp @@ -68,8 +68,6 @@ void ResourceCache::incrementRefcount(void* resource, ResourceType resourceType) } void ResourceCache::incrementRefcount(const SkBitmap* bitmapResource) { - bitmapResource->pixelRef()->globalRef(); - SkSafeRef(bitmapResource->getColorTable()); incrementRefcount((void*) bitmapResource, kBitmap); } @@ -92,8 +90,6 @@ void ResourceCache::incrementRefcountLocked(void* resource, ResourceType resourc } void ResourceCache::incrementRefcountLocked(const SkBitmap* bitmapResource) { - bitmapResource->pixelRef()->globalRef(); - SkSafeRef(bitmapResource->getColorTable()); incrementRefcountLocked((void*) bitmapResource, kBitmap); } @@ -111,8 +107,6 @@ void ResourceCache::decrementRefcount(void* resource) { } void ResourceCache::decrementRefcount(const SkBitmap* bitmapResource) { - bitmapResource->pixelRef()->globalUnref(); - SkSafeUnref(bitmapResource->getColorTable()); decrementRefcount((void*) bitmapResource); } @@ -138,8 +132,6 @@ void ResourceCache::decrementRefcountLocked(void* resource) { } void ResourceCache::decrementRefcountLocked(const SkBitmap* bitmapResource) { - bitmapResource->pixelRef()->globalUnref(); - SkSafeUnref(bitmapResource->getColorTable()); decrementRefcountLocked((void*) bitmapResource); } -- cgit v1.1