summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/minikin/Layout.h3
-rw-r--r--libs/minikin/Layout.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/include/minikin/Layout.h b/include/minikin/Layout.h
index 1b91ad8..e30f2f2 100644
--- a/include/minikin/Layout.h
+++ b/include/minikin/Layout.h
@@ -100,6 +100,9 @@ public:
void getBounds(MinikinRect* rect);
+ // Purge all caches, useful in low memory conditions
+ static void purgeCaches();
+
private:
// Find a face in the mFaces vector, or create a new entry
int findFace(FakedFont face, LayoutContext* ctx);
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp
index 762a7db..48db129 100644
--- a/libs/minikin/Layout.cpp
+++ b/libs/minikin/Layout.cpp
@@ -799,4 +799,12 @@ void Layout::getBounds(MinikinRect* bounds) {
bounds->set(mBounds);
}
+void Layout::purgeCaches() {
+ AutoMutex _l(gMinikinLock);
+ LayoutCache& layoutCache = LayoutEngine::getInstance().layoutCache;
+ layoutCache.mCache.clear();
+ HbFaceCache& hbCache = LayoutEngine::getInstance().hbFaceCache;
+ hbCache.mCache.clear();
+}
+
} // namespace android