Do not embed glyph image data in SkGlyphCache.

Instead of allocating memory for glyph images eagerly by embedding
the memory in the glyph cache, allocate memory dynamically on need.

TBR=bungeman@google.com

BUG=chromium:684366

Change-Id: If32bbc4d2608c976b93868feb519dcfa1212ce59
Reviewed-on: https://skia-review.googlesource.com/7433
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2017-01-24 11:01:59 -05:00 committed by Skia Commit-Bot
parent 7717d4a343
commit 80d22ea13a

View File

@ -237,18 +237,16 @@ private:
SkTHashTable<SkGlyph, SkPackedGlyphID, SkGlyph::HashTraits> fGlyphMap;
// so we don't grow our arrays a lot
static constexpr size_t kMinGlyphCount = 16;
static constexpr size_t kMinGlyphImageSize = (16*2);
static constexpr size_t kMinAllocAmount
= ((sizeof(SkGlyph) + kMinGlyphImageSize) * kMinGlyphCount);
static constexpr size_t kMinGlyphCount = 8;
static constexpr size_t kMinGlyphImageSize = 16 /* height */ * 8 /* width */;
static constexpr size_t kMinAllocAmount = kMinGlyphImageSize * kMinGlyphCount;
char storage[kMinAllocAmount];
SkArenaAlloc fAlloc {storage};
SkArenaAlloc fAlloc {kMinAllocAmount};
std::unique_ptr<CharGlyphRec[]> fPackedUnicharIDToPackedGlyphID;
// used to track (approx) how much ram is tied-up in this cache
size_t fMemoryUsed;
size_t fMemoryUsed;
};
class SkAutoGlyphCache : public std::unique_ptr<SkGlyphCache, SkGlyphCache::AttachCacheFunctor> {