diff options
author | Romain Guy <romainguy@google.com> | 2010-11-11 15:36:56 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-11-11 15:36:56 -0800 |
commit | fe48f65922d4a3cc4aefe058cee5acec51504a20 (patch) | |
tree | 97ea23ae71dade1ef7bf783523bea9cda31dd042 /libs/hwui/GradientCache.h | |
parent | 50c5e4c36e494d092576d42cf2b406abab20510a (diff) | |
download | frameworks_base-fe48f65922d4a3cc4aefe058cee5acec51504a20.zip frameworks_base-fe48f65922d4a3cc4aefe058cee5acec51504a20.tar.gz frameworks_base-fe48f65922d4a3cc4aefe058cee5acec51504a20.tar.bz2 |
Free resources only from the GL context thread.
Bug #3179882
Resources were freed following garbage collections on a worker thread.
This worker thread had no EGL context, which would cause the renderer
to incorrectly assume that the memory was liberated.
Change-Id: Ifdb51f94ddf42641e8654522787bfac532976c7c
Diffstat (limited to 'libs/hwui/GradientCache.h')
-rw-r--r-- | libs/hwui/GradientCache.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h index c9553f4..30da462 100644 --- a/libs/hwui/GradientCache.h +++ b/libs/hwui/GradientCache.h @@ -19,6 +19,8 @@ #include <SkShader.h> +#include <utils/Vector.h> + #include "Texture.h" #include "utils/GenerationCache.h" @@ -53,11 +55,20 @@ public: */ Texture* get(SkShader* shader); /** - * Removes the texture associated with the specified shader. Returns NULL - * if the texture cannot be found. Upon remove the texture is freed. + * Removes the texture associated with the specified shader. + * Upon remove the texture is freed. */ void remove(SkShader* shader); /** + * Removes the texture associated with the specified shader. This is meant + * to be called from threads that are not the EGL context thread. + */ + void removeDeferred(SkShader* shader); + /** + * Process deferred removals. + */ + void clearGarbage(); + /** * Clears the cache. This causes all textures to be deleted. */ void clear(); @@ -83,10 +94,7 @@ private: uint32_t mSize; uint32_t mMaxSize; - /** - * Used to access mCache and mSize. All methods are accessed from a single - * thread except for remove(). - */ + Vector<SkShader*> mGarbage; mutable Mutex mLock; }; // class GradientCache |