Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13ba4e47 authored by Raph Levien's avatar Raph Levien
Browse files

Fix for b7155617 race condition in TextLayoutCache.cpp

There was the possibility for a race between clearing the caches and
using fonts. This patch simply protects both under the same mLock held
by the TextLayoutCache object.

Change-Id: Ib366e16a9a9ba702a46bc078d1bc0602713991e5
parent 753e1280
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -78,8 +78,10 @@ void TextLayoutCache::operator()(TextLayoutCacheKey& text, sp<TextLayoutValue>&
/*
 * Cache clearing
 */
void TextLayoutCache::clear() {
void TextLayoutCache::purgeCaches() {
    AutoMutex _l(mLock);
    mCache.clear();
    mShaper->purgeCaches();
}

/*
@@ -965,8 +967,7 @@ sp<TextLayoutValue> TextLayoutEngine::getValue(const SkPaint* paint, const jchar

void TextLayoutEngine::purgeCaches() {
#if USE_TEXT_LAYOUT_CACHE
    mTextLayoutCache->clear();
    mShaper->purgeCaches();
    mTextLayoutCache->purgeCaches();
#if DEBUG_GLYPHS
    ALOGD("Purged TextLayoutEngine caches");
#endif
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ public:
    /**
     * Clear the cache
     */
    void clear();
    void purgeCaches();

private:
    TextLayoutShaper* mShaper;