diff options
author | Seigo Nonaka <nona@google.com> | 2016-02-03 19:41:00 +0900 |
---|---|---|
committer | Seigo Nonaka <nona@google.com> | 2016-02-04 12:26:10 +0900 |
commit | 89e80237bc27af084c9ff316d4f47abf426eced8 (patch) | |
tree | 5cc5b0dfe051ec5bc97de2f90ece3bed98f51e0f /include | |
parent | e5f01d0e954b1cace4ff000d63e383f8b1888a1f (diff) | |
download | android_frameworks_minikin-89e80237bc27af084c9ff316d4f47abf426eced8.tar.gz android_frameworks_minikin-89e80237bc27af084c9ff316d4f47abf426eced8.tar.bz2 android_frameworks_minikin-89e80237bc27af084c9ff316d4f47abf426eced8.zip |
Improve Paint.hasGlyph performance by caching hb_font_t
It turned out that hb_font_t creation is not a lightweight operation.
Especially, Paint.hasGlyph creates hb_font_t for all existing fonts
every time. To improve the performance, cache hb_font_t instead
of hb_face_t.
Note that to calculate horizontal advance, MinikinPaint needs to be
associated with hb_font_t by calling hb_font_set_funcs. With this patch,
hb_font_set_funcs may be called multiple times for the same hb_font_t
object. However this is not an issue since MinikinPaint is unique
during layout.
Bug: 26784699
Change-Id: I516498ae9f0127d700fc9829327e9789845a1416
Diffstat (limited to 'include')
-rw-r--r-- | include/minikin/FontCollection.h | 3 | ||||
-rw-r--r-- | include/minikin/FontFamily.h | 11 |
2 files changed, 2 insertions, 12 deletions
diff --git a/include/minikin/FontCollection.h b/include/minikin/FontCollection.h index 294692f..3a63c07 100644 --- a/include/minikin/FontCollection.h +++ b/include/minikin/FontCollection.h @@ -53,9 +53,6 @@ public: uint32_t getId() const; - // Calls each managed font family's FontFamily::purgeHbFontCache method. - // Caller should acquire a lock before calling the method. - void purgeFontFamilyHbFontCache() const; private: static const int kLogCharsPerPage = 8; static const int kPageMask = (1 << kLogCharsPerPage) - 1; diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h index aa2e0ac..2b59160 100644 --- a/include/minikin/FontFamily.h +++ b/include/minikin/FontFamily.h @@ -100,11 +100,11 @@ struct FakedFont { class FontFamily : public MinikinRefCounted { public: - FontFamily() : mHbFont(nullptr) { } + FontFamily() {} FontFamily(int variant); - FontFamily(uint32_t langId, int variant) : mLangId(langId), mVariant(variant), mHbFont(nullptr) { + FontFamily(uint32_t langId, int variant) : mLangId(langId), mVariant(variant) { } ~FontFamily(); @@ -131,11 +131,6 @@ public: // Caller should acquire a lock before calling the method. bool hasVariationSelector(uint32_t codepoint, uint32_t variationSelector); - // Purges cached mHbFont. - // hb_font_t keeps a reference to hb_face_t which is managed by HbFaceCache. Thus, - // it is good to purge hb_font_t once it is no longer necessary. - // Caller should acquire a lock before calling the method. - void purgeHbFontCache(); private: void addFontLocked(MinikinFont* typeface, FontStyle style); @@ -152,8 +147,6 @@ private: SparseBitSet mCoverage; bool mCoverageValid; - - hb_font_t* mHbFont; }; } // namespace android |