diff options
author | bsalomon <bsalomon@google.com> | 2015-01-23 04:24:04 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-23 04:24:05 -0800 |
commit | 24db3b1c35fb935660229da164fc5ad31977387f (patch) | |
tree | be22e794f54605ff37ef09df79b3e0869572b053 /src/gpu/GrStencilAndCoverTextContext.cpp | |
parent | f98f2bb0e72df68320f707c8584e3c877ce98ec3 (diff) |
Add specialized content key class for resources.
Review URL: https://codereview.chromium.org/858123002
Diffstat (limited to 'src/gpu/GrStencilAndCoverTextContext.cpp')
-rw-r--r-- | src/gpu/GrStencilAndCoverTextContext.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp index c29dca6d0a..2f2f1f8ebd 100644 --- a/src/gpu/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/GrStencilAndCoverTextContext.cpp @@ -205,20 +205,25 @@ static GrPathRange* get_gr_glyphs(GrContext* ctx, const SkTypeface* typeface, const SkDescriptor* desc, const SkStrokeRec& stroke) { - static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); - - GrCacheID::Key key; - uint64_t* keyData = key.fData64; - keyData[0] = desc ? desc->getChecksum() : 0; - keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0); - keyData[1] = GrPath::ComputeStrokeKey(stroke); - GrResourceKey resourceKey = GrResourceKey(GrCacheID(gGlyphsDomain, key), 0); + static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); + GrContentKey key; + GrContentKey::Builder builder(&key, kDomain, 4); + struct GlyphKey { + uint32_t fChecksum; + uint32_t fTypeface; + uint64_t fStroke; + }; + GlyphKey* glyphKey = reinterpret_cast<GlyphKey*>(&builder[0]); + glyphKey->fChecksum = desc ? desc->getChecksum() : 0; + glyphKey->fTypeface = typeface ? typeface->uniqueID() : 0; + glyphKey->fStroke = GrPath::ComputeStrokeKey(stroke); + builder.finish(); SkAutoTUnref<GrPathRange> glyphs( - static_cast<GrPathRange*>(ctx->findAndRefCachedResource(resourceKey))); + static_cast<GrPathRange*>(ctx->findAndRefCachedResource(key))); if (NULL == glyphs || (NULL != desc && !glyphs->isEqualTo(*desc))) { glyphs.reset(ctx->getGpu()->pathRendering()->createGlyphs(typeface, desc, stroke)); - ctx->addResourceToCache(resourceKey, glyphs); + ctx->addResourceToCache(key, glyphs); } return glyphs.detach(); |