diff options
author | Raph Levien <raph@google.com> | 2014-06-25 15:58:24 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2014-06-25 23:02:52 +0000 |
commit | 22e41754f6470ff1f4c0e0a56d01f7f555b59e21 (patch) | |
tree | fb9a5be4da6e16e05a86c4598bc062b7a9b56c9d | |
parent | 3d28a3fcebfed4744d1ef0307a8bdc8fc01e364c (diff) | |
download | android_frameworks_minikin-22e41754f6470ff1f4c0e0a56d01f7f555b59e21.tar.gz android_frameworks_minikin-22e41754f6470ff1f4c0e0a56d01f7f555b59e21.tar.bz2 android_frameworks_minikin-22e41754f6470ff1f4c0e0a56d01f7f555b59e21.zip |
Add purgeCaches() method
Expose a method to purge caches used for TextLayout, useful for low
memory conditions.
Change-Id: I92f41afe987b7be4af5ca0a0c50fb51be35a2758
-rw-r--r-- | include/minikin/Layout.h | 3 | ||||
-rw-r--r-- | libs/minikin/Layout.cpp | 8 |
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 |