mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add purgeCaches() method
Expose a method to purge caches used for TextLayout, useful for low memory conditions. Change-Id: I92f41afe987b7be4af5ca0a0c50fb51be35a2758
This commit is contained in:
parent
e8bed5d3cc
commit
69f3585cf6
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user