summaryrefslogtreecommitdiffstats
path: root/include/minikin/FontFamily.h
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2014-05-21 08:37:49 -0700
committerRaph Levien <raph@google.com>2014-05-27 15:39:33 +0000
commit4d4e6bc8118d15542f1f2a9218f0f7a91a29474f (patch)
treecdfd772d61a6eb71d7268f5d278e82202a247769 /include/minikin/FontFamily.h
parentd973b3926b3a34c19d3d6f309fae1138e782e4dc (diff)
downloadandroid_frameworks_minikin-4d4e6bc8118d15542f1f2a9218f0f7a91a29474f.tar.gz
android_frameworks_minikin-4d4e6bc8118d15542f1f2a9218f0f7a91a29474f.tar.bz2
android_frameworks_minikin-4d4e6bc8118d15542f1f2a9218f0f7a91a29474f.zip
Caching for layouts and harfbuzz faces
This patch adds caching for both layouts and for HarfBuzz face objects. The granularity of the cache for layouts is words, so it splits the input string at word boundaries (using a heuristic). There are is also some refactoring to reduce the amount of allocation and copying, and movement towards properly supporting contexts. The size of the caches is a fixed number of entries; thus, it is possible to consume a large amount of memory by filling the cache with lots of large strings. This should be refined towards a scheme that bounds the total memory used by the cache. This patch fixes bug 15237293 "Regression: Measure performance is significantly slower with minikin". Change-Id: Ie8176857e2d78656ce5479a7c04969819ef2718d
Diffstat (limited to 'include/minikin/FontFamily.h')
-rw-r--r--include/minikin/FontFamily.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index 82fcfe9..a4fe9cb 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -19,6 +19,8 @@
#include <vector>
+#include <utils/TypeHelpers.h>
+
#include <minikin/MinikinRefCounted.h>
namespace android {
@@ -31,16 +33,22 @@ public:
FontStyle(int weight = 4, bool italic = false) {
bits = (weight & kWeightMask) | (italic ? kItalicMask : 0);
}
- int getWeight() { return bits & kWeightMask; }
- bool getItalic() { return (bits & kItalicMask) != 0; }
- bool operator==(const FontStyle other) { return bits == other.bits; }
+ int getWeight() const { return bits & kWeightMask; }
+ bool getItalic() const { return (bits & kItalicMask) != 0; }
+ bool operator==(const FontStyle other) const { return bits == other.bits; }
// TODO: language, variant
+
+ hash_t hash() const { return bits; }
private:
static const int kWeightMask = 0xf;
static const int kItalicMask = 16;
uint32_t bits;
};
+inline hash_t hash_type(const FontStyle &style) {
+ return style.hash();
+}
+
class FontFamily : public MinikinRefCounted {
public:
~FontFamily();