diff options
author | 2015-02-27 07:22:48 -0800 | |
---|---|---|
committer | 2015-02-27 07:22:48 -0800 | |
commit | e70de9e4f0b7bf73f7cd1a20dbabcb233ffbb7f1 (patch) | |
tree | 5a0d85a81aafd177425ee74cae31324bacd2054b /src/core/SkGlyphCache.h | |
parent | 574290f61a47bd1ce1f9e2d941533bda9c8f03fe (diff) |
Make the glyph array entries inline.
Perf Reports
bin/c --match nytimes --config 8888
desk_nytimes.skp_1_mpd 1.41ms -> 1.38ms 0.98x
desk_nytimes.skp_1 1.94ms -> 1.87ms 0.97x
bin/c --match nytimes --config gpu
desk_nytimes.skp_1_mpd 1.63ms -> 1.59ms 0.97x
desk_nytimes.skp_1 1.56ms -> 1.5ms 0.97x
Here are results from mac instruments:
--match nytimes --config gpu --samples 10000 --skps /Users/herb/src/skia/skps
Inline:
Total Samples Running Time Self Symbol Name
94335 94335.0ms 98.3% 0.0 start
2365 2365.0ms 2.4% 2365.0 SkGlyphCache::getGlyphIDMetrics(unsigned short, int, int)
975 975.0ms 1.0% 975.0 SkGlyphCache::lookupMetrics(unsigned int, SkGlyphCache::MetricsType)
Clean:
Total Samples Running Time Self Symbol Name
96833 96833.0ms 97.3% 0.0 start
3418 3418.0ms 3.4% 3418.0 SkGlyphCache::getGlyphIDMetrics(unsigned short, int, int)
1961 1961.0ms 1.9% 1961.0 SkGlyphCache::lookupMetrics(unsigned int, SkGlyphCache::MetricsType)
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/4c08f16b252a55e438a61f26e5581394ed177da1
Committed: https://skia.googlesource.com/skia/+/b4c29ac173e6f8844327338687248b98bc94132d
Review URL: https://codereview.chromium.org/885903002
Diffstat (limited to 'src/core/SkGlyphCache.h')
-rw-r--r-- | src/core/SkGlyphCache.h | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h index b335d29d2d..200655bb41 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 MetricsType. + 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; @@ -221,7 +237,6 @@ private: // used to track (approx) how much ram is tied-up in this cache size_t fMemoryUsed; - #ifdef SK_GLYPHCACHE_TRACK_HASH_STATS int fHashHitCount; int fHashMissCount; |