summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2014-10-29 11:04:04 -0700
committerRaph Levien <raph@google.com>2014-12-03 12:48:20 -0800
commit13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3 (patch)
treec39913c6afd1baba7e33bcd3b1f6939c27141212 /include
parent69d4fba2f2b7bb2c248cc0e78cf277a6e44665f8 (diff)
downloadandroid_frameworks_minikin-13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3.tar.gz
android_frameworks_minikin-13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3.tar.bz2
android_frameworks_minikin-13f1aae02bacd475722bc8ea3fc2cf6abc1a82e3.zip
Move coverage bitmap from FontCollection to FontFamily
This will significantly reduce memory usage and also speed the creation of new font families. In particular, the coverage bitmaps for the fonts in the fallback stack will be computed once in the Zygote, rather than separately in each app process. Bug: 17756900 Change-Id: I66f5706bddd4658d78fe5b709f7251ca9d2ff4f8
Diffstat (limited to 'include')
-rw-r--r--include/minikin/FontCollection.h12
-rw-r--r--include/minikin/FontFamily.h7
2 files changed, 10 insertions, 9 deletions
diff --git a/include/minikin/FontCollection.h b/include/minikin/FontCollection.h
index 12700c6..ffdb4d1 100644
--- a/include/minikin/FontCollection.h
+++ b/include/minikin/FontCollection.h
@@ -21,7 +21,6 @@
#include <minikin/MinikinRefCounted.h>
#include <minikin/MinikinFont.h>
-#include <minikin/SparseBitSet.h>
#include <minikin/FontFamily.h>
namespace android {
@@ -52,17 +51,12 @@ private:
static const int kLogCharsPerPage = 8;
static const int kPageMask = (1 << kLogCharsPerPage) - 1;
- struct FontInstance {
- SparseBitSet* mCoverage;
- FontFamily* mFamily;
- };
-
struct Range {
size_t start;
size_t end;
};
- const FontInstance* getInstanceForChar(uint32_t ch, FontLanguage lang, int variant) const;
+ FontFamily* getFamilyForChar(uint32_t ch, FontLanguage lang, int variant) const;
// static for allocating unique id's
static uint32_t sNextId;
@@ -74,10 +68,10 @@ private:
uint32_t mMaxChar;
// This vector has ownership of the bitsets and typeface objects.
- std::vector<FontInstance> mInstances;
+ std::vector<FontFamily*> mFamilies;
// This vector contains pointers into mInstances
- std::vector<const FontInstance*> mInstanceVec;
+ std::vector<FontFamily*> mFamilyVec;
// These are offsets into mInstanceVec, one range per page
std::vector<Range> mRanges;
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index bcc2e3a..08c7a2c 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -23,6 +23,7 @@
#include <utils/TypeHelpers.h>
#include <minikin/MinikinRefCounted.h>
+#include <minikin/SparseBitSet.h>
namespace android {
@@ -139,6 +140,9 @@ public:
size_t getNumFonts() const;
MinikinFont* getFont(size_t index) const;
FontStyle getStyle(size_t index) const;
+
+ // Get Unicode coverage. Lifetime of returned bitset is same as receiver.
+ const SparseBitSet* getCoverage();
private:
void addFontLocked(MinikinFont* typeface, FontStyle style);
@@ -152,6 +156,9 @@ private:
FontLanguage mLang;
int mVariant;
std::vector<Font> mFonts;
+
+ SparseBitSet mCoverage;
+ bool mCoverageValid;
};
} // namespace android