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/Caches.cpp b/libs/hwui/Caches.cpp
index 24ec4e8..75b07de 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -170,8 +170,11 @@
             patchCache.clear();
             dropShadowCache.clear();
             gradientCache.clear();
+            fontRenderer.clear();
             // fall through
         case kFlushMode_Moderate:
+            fontRenderer.flush();
+            textureCache.flush();
             pathCache.clear();
             roundRectShapeCache.clear();
             circleShapeCache.clear();