diff --git a/engine/src/flutter/include/minikin/Layout.h b/engine/src/flutter/include/minikin/Layout.h index 1b91ad87fe0..e30f2f24968 100644 --- a/engine/src/flutter/include/minikin/Layout.h +++ b/engine/src/flutter/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/engine/src/flutter/libs/minikin/Layout.cpp b/engine/src/flutter/libs/minikin/Layout.cpp index 762a7dbbfa0..48db129cf77 100644 --- a/engine/src/flutter/libs/minikin/Layout.cpp +++ b/engine/src/flutter/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