diff options
author | Romain Guy <romainguy@google.com> | 2012-09-23 17:50:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-23 17:50:06 -0700 |
commit | 6b3292ce5b3908c7433503f64c852cf2b27718ed (patch) | |
tree | 00e7df2eaa335ed83aeb25ce187f67e0cdaccc3f /libs | |
parent | 916b2b5a932a3be1a1363ac1871e74ad8b314f00 (diff) | |
parent | 97dc9172b0e58979c63de0dedbab656399a62281 (diff) | |
download | frameworks_base-6b3292ce5b3908c7433503f64c852cf2b27718ed.zip frameworks_base-6b3292ce5b3908c7433503f64c852cf2b27718ed.tar.gz frameworks_base-6b3292ce5b3908c7433503f64c852cf2b27718ed.tar.bz2 |
Merge "Avoid deadlock when deleting layers Bug #7217459" into jb-mr1-dev
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 3 | ||||
-rw-r--r-- | libs/hwui/ResourceCache.cpp | 15 | ||||
-rw-r--r-- | libs/hwui/ResourceCache.h | 2 |
4 files changed, 18 insertions, 9 deletions
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 76b274b..fb525ee 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -50,6 +50,13 @@ Layer::~Layer() { deleteTexture(); } +void Layer::freeResourcesLocked() { + if (colorFilter) { + Caches::getInstance().resourceCache.decrementRefcountLocked(colorFilter); + colorFilter = NULL; + } +} + void Layer::setPaint(SkPaint* paint) { OpenGLRenderer::getAlphaAndModeDirect(paint, &alpha, &mode); } diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 420073a..d2cd440 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -45,10 +45,11 @@ class DisplayList; * A layer has dimensions and is backed by an OpenGL texture or FBO. */ struct Layer { - Layer(const uint32_t layerWidth, const uint32_t layerHeight); ~Layer(); + void freeResourcesLocked(); + /** * Sets this layer's region to a rectangle. Computes the appropriate * texture coordinates. diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp index 1c83ea4..18d8324 100644 --- a/libs/hwui/ResourceCache.cpp +++ b/libs/hwui/ResourceCache.cpp @@ -155,7 +155,7 @@ void ResourceCache::decrementRefcountLocked(void* resource) { } ref->refCount--; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -201,7 +201,7 @@ void ResourceCache::destructorLocked(SkPath* resource) { } ref->destroyed = true; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -223,7 +223,7 @@ void ResourceCache::destructorLocked(SkBitmap* resource) { } ref->destroyed = true; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -242,7 +242,7 @@ void ResourceCache::destructorLocked(SkiaShader* resource) { } ref->destroyed = true; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -261,7 +261,7 @@ void ResourceCache::destructorLocked(SkiaColorFilter* resource) { } ref->destroyed = true; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -284,7 +284,7 @@ void ResourceCache::recycleLocked(SkBitmap* resource) { } ref->recycled = true; if (ref->refCount == 0) { - deleteResourceReference(resource, ref); + deleteResourceReferenceLocked(resource, ref); } } @@ -292,7 +292,7 @@ void ResourceCache::recycleLocked(SkBitmap* resource) { * This method should only be called while the mLock mutex is held (that mutex is grabbed * by the various destructor() and recycle() methods which call this method). */ -void ResourceCache::deleteResourceReference(void* resource, ResourceReference* ref) { +void ResourceCache::deleteResourceReferenceLocked(void* resource, ResourceReference* ref) { if (ref->recycled && ref->resourceType == kBitmap) { ((SkBitmap*) resource)->setPixels(NULL, NULL); } @@ -326,6 +326,7 @@ void ResourceCache::deleteResourceReference(void* resource, ResourceReference* r break; case kLayer: { Layer* layer = (Layer*) resource; + layer->freeResourcesLocked(); delete layer; } break; diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h index 2053d96..a80670c 100644 --- a/libs/hwui/ResourceCache.h +++ b/libs/hwui/ResourceCache.h @@ -103,7 +103,7 @@ public: void recycleLocked(SkBitmap* resource); private: - void deleteResourceReference(void* resource, ResourceReference* ref); + void deleteResourceReferenceLocked(void* resource, ResourceReference* ref); void incrementRefcount(void* resource, ResourceType resourceType); void incrementRefcountLocked(void* resource, ResourceType resourceType); |