From 6c60831cfce24b0749f50f37231e0a56d8fd4b85 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Mon, 11 Apr 2016 17:53:34 +0900 Subject: 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 --- include/minikin/MinikinFont.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/minikin/MinikinFont.h') 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 -- cgit v1.2.3