Memory optimizations for libhwui
Bug #5566149
Lazily initialize font renderers
Keep 60% of the texture cache when an app goes to the background
Delete least used font renderer when going to the background
Delete all font renderers on full memory trim
Change-Id: I3c2454d46dc1107ec0f0f72a9ce69cbbcc8825e7
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index f7707f7..ce924b4 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -98,6 +98,17 @@
*/
uint32_t getSize();
+ /**
+ * Partially flushes the cache. The amount of memory freed by a flush
+ * is defined by the flush rate.
+ */
+ void flush();
+ /**
+ * Indicates the percentage of the cache to retain when a
+ * memory trim is requested (see Caches::flush).
+ */
+ void setFlushRate(float flushRate);
+
private:
/**
* Generates the texture from a bitmap into the specified texture structure.
@@ -119,6 +130,8 @@
uint32_t mMaxSize;
GLint mMaxTextureSize;
+ float mFlushRate;
+
bool mDebugEnabled;
Vector<SkBitmap*> mGarbage;