summaryrefslogtreecommitdiffstats
path: root/include/minikin/MinikinFont.h
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2016-04-11 17:53:34 +0900
committerRaph Levien <raph@google.com>2016-04-11 13:33:35 -0700
commit6c60831cfce24b0749f50f37231e0a56d8fd4b85 (patch)
tree6f389a2979b0585148168a6e6ea1ad91ee655272 /include/minikin/MinikinFont.h
parent29abb82198868908ece4600284fa8b7d3ed73f3b (diff)
downloadandroid_frameworks_minikin-6c60831cfce24b0749f50f37231e0a56d8fd4b85.tar.gz
android_frameworks_minikin-6c60831cfce24b0749f50f37231e0a56d8fd4b85.tar.bz2
android_frameworks_minikin-6c60831cfce24b0749f50f37231e0a56d8fd4b85.zip
Fix minikin_unittests
This CL fixes following test cases in minikin_tests - FontFamilyTest.hasVariationSelectorTest - HbFontCacheTest.getHbFontLockedTest - HbFontCacheTest.purgeCacheTest For the fix of FontFamilyTest.hasVariationSelectorTest, removing virtual from GetUniqueId() in MinikinFont. After [1], MinikinFont's destructor started calling purgeHbCache() which calls virtual method, MinikinFont::GetUniqueId(). Fortunately, the SkTypeface::uniqueID() returns just internal value, so we can store it at the construction time and use it instead of calling SkTypeface::uniqueID() every time. This patch also changes purgeHbFont to purgeHbFontLocked, as all uses of it were already under global mutex. This change avoids deadlock on explicit unref, as when invoked by a Java finalizer from the Java object that holds a reference to the font. Some of the tests needed to change to using the ref counting protocol rather than explicitly destructing font objects, as well. [1] 9afcc6e2bd4d89e4e1deb6e18c3c4daca4e114fd Bug: 28105730 Bug: 28105688 Change-Id: Ie5983c4869147dacabdca81af1605066cd680b3f
Diffstat (limited to 'include/minikin/MinikinFont.h')
-rw-r--r--include/minikin/MinikinFont.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/minikin/MinikinFont.h b/include/minikin/MinikinFont.h
index 0298235..4951514 100644
--- a/include/minikin/MinikinFont.h
+++ b/include/minikin/MinikinFont.h
@@ -99,6 +99,8 @@ typedef void (*MinikinDestroyFunc) (void* data);
class MinikinFont : public MinikinRefCounted {
public:
+ MinikinFont(int32_t uniqueId) : mUniqueId(uniqueId) {}
+
virtual ~MinikinFont();
virtual float GetHorizontalAdvance(uint32_t glyph_id,
@@ -125,12 +127,14 @@ public:
return 0;
}
- virtual int32_t GetUniqueId() const = 0;
-
static uint32_t MakeTag(char c1, char c2, char c3, char c4) {
return ((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) |
((uint32_t)c3 << 8) | (uint32_t)c4;
}
+
+ int32_t GetUniqueId() const { return mUniqueId; }
+private:
+ const int32_t mUniqueId;
};
} // namespace android