aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2017-01-24 11:01:59 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-24 16:45:59 +0000
commit80d22ea13a549cc70a44eca1407933a1efdaeddc (patch)
tree9049b788fac872ac4a915f5ae4df4f9bfc107aee /src
parent7717d4a343bad38017c91459f1637868844bda47 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkGlyphCache.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/core/SkGlyphCache.h b/src/core/SkGlyphCache.h
index ab1c9ba89f..4140bc5cd8 100644
--- a/src/core/SkGlyphCache.h
+++ b/src/core/SkGlyphCache.h
@@ -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> {