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
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 0193f43..ae2e55d 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -21,6 +21,8 @@
#include <SkPaint.h>
#include <SkPath.h>
+#include <utils/Vector.h>
+
#include "Debug.h"
#include "Texture.h"
#include "utils/Compare.h"
@@ -146,6 +148,15 @@
* Removes an entry.
*/
void remove(SkPath* path);
+ /**
+ * Removes the specified path. This is meant to be called from threads
+ * that are not the EGL context thread.
+ */
+ void removeDeferred(SkPath* path);
+ /**
+ * Process deferred removals.
+ */
+ void clearGarbage();
/**
* Sets the maximum size of the cache in bytes.
@@ -166,6 +177,8 @@
*/
void generateTexture(SkBitmap& bitmap, Texture* texture);
+ void removeTexture(PathTexture* texture);
+
PathTexture* addTexture(const PathCacheEntry& entry, const SkPath *path, const SkPaint* paint);
void init();
@@ -178,10 +191,7 @@
bool mDebugEnabled;
- /**
- * Used to access mCache and mSize. All methods are accessed from a single
- * thread except for remove().
- */
+ Vector<SkPath*> mGarbage;
mutable Mutex mLock;
}; // class PathCache