diff options
author | 2015-02-09 06:38:28 -0800 | |
---|---|---|
committer | 2015-02-09 06:38:28 -0800 | |
commit | b4c29ac173e6f8844327338687248b98bc94132d (patch) | |
tree | 8f52c3ac31b3caacea0447801f3c1e53819b5519 /src/core/SkGlyphCache.h | |
parent | 4e534d05b7b062966b61d98662712a3a8657495e (diff) |
Make the glyph array entries inline.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/4c08f16b252a55e438a61f26e5581394ed177da1
Review URL: https://codereview.chromium.org/885903002
Diffstat (limited to 'src/core/SkGlyphCache.h')
-rw-r--r-- | src/core/SkGlyphCache.h | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index b335d29d2d..8805085468 100644 --- a/src/core/SkGlyphCache.h +++ b/src/core/SkGlyphCache.h @@ -187,32 +187,48 @@ private: kFull_MetricsType }; - SkGlyph* lookupMetrics(uint32_t id, MetricsType); + // Return the SkGlyph* associated with MakeID. The id parameter is the combined glyph/x/y + // id generated by MakeID. If it is just a glyph id then x and y are assuemd to be zero. + SkGlyph* lookupByCombinedID(uint32_t id, MetricsType type); + + // Return a SkGlyph* associated with unicode id and position x and y. + SkGlyph* lookupByChar(SkUnichar id, MetricsType type, SkFixed x = 0, SkFixed y = 0); + + // Return the index of id in the fGlyphArray. If it does + // not exist, create a new one using MaetricsType. + uint16_t lookupMetrics(uint32_t id, MetricsType type); static bool DetachProc(const SkGlyphCache*, void*) { return true; } - SkGlyphCache* fNext, *fPrev; - SkDescriptor* fDesc; - SkScalerContext* fScalerContext; + SkGlyphCache* fNext, *fPrev; + SkDescriptor* fDesc; + SkScalerContext* fScalerContext; SkPaint::FontMetrics fFontMetrics; enum { - kHashBits = 8, - kHashCount = 1 << kHashBits, - kHashMask = kHashCount - 1 + kHashBits = 8, + kHashCount = 1 << kHashBits, + kHashMask = kHashCount - 1, + kSentinelGlyphIndex = 0, + kSentinelGlyphID = 0 }; - SkGlyph* fGlyphHash[kHashCount]; - SkTDArray<SkGlyph*> fGlyphArray; - SkChunkAlloc fGlyphAlloc; + + // A quick lookup to avoid the binary search looking for glyphs in fGlyphArray. + uint16_t fGlyphHash[kHashCount]; + SkTDArray<SkGlyph> fGlyphArray; + SkChunkAlloc fGlyphAlloc; struct CharGlyphRec { uint32_t fID; // unichar + subpixel - SkGlyph* fGlyph; + uint16_t fGlyphIndex; }; + // no reason to use the same kHashCount as fGlyphHash, but we do for now // Dynamically allocated when chars are encountered. SkAutoTArray<CharGlyphRec> fCharToGlyphHash; - + + // The id arg is a combined id generated by MakeID. CharGlyphRec* getCharGlyphRec(uint32_t id); + void adjustCaches(int insertion_index); static inline unsigned ID2HashIndex(uint32_t h) { return SkChecksum::CheapMix(h) & kHashMask; |