summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.h
diff options
context:
space:
mode:
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
commitfe48f65922d4a3cc4aefe058cee5acec51504a20 (patch)
tree97ea23ae71dade1ef7bf783523bea9cda31dd042 /libs/hwui/TextureCache.h
parent50c5e4c36e494d092576d42cf2b406abab20510a (diff)
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/TextureCache.h')
-rw-r--r--libs/hwui/TextureCache.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index 27693df99b0f..f7707f7ae8e8 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -19,6 +19,8 @@
#include <SkBitmap.h>
+#include <utils/Vector.h>
+
#include "Debug.h"
#include "Texture.h"
#include "utils/GenerationCache.h"
@@ -64,11 +66,21 @@ public:
*/
Texture* get(SkBitmap* bitmap);
/**
- * Removes the texture associated with the specified bitmap. Returns NULL
- * if the texture cannot be found. Upon remove the texture is freed.
+ * Removes the texture associated with the specified bitmap.
+ * Upon remove the texture is freed.
*/
void remove(SkBitmap* bitmap);
/**
+ * Removes the texture associated with the specified bitmap. This is meant
+ * to be called from threads that are not the EGL context thread.
+ */
+ void removeDeferred(SkBitmap* bitmap);
+ /**
+ * Process deferred removals.
+ */
+ void clearGarbage();
+
+ /**
* Clears the cache. This causes all textures to be deleted.
*/
void clear();
@@ -109,10 +121,7 @@ private:
bool mDebugEnabled;
- /**
- * Used to access mCache and mSize. All methods are accessed from a single
- * thread except for remove().
- */
+ Vector<SkBitmap*> mGarbage;
mutable Mutex mLock;
}; // class TextureCache