From 24db3b1c35fb935660229da164fc5ad31977387f Mon Sep 17 00:00:00 2001 From: bsalomon Date: Fri, 23 Jan 2015 04:24:04 -0800 Subject: Add specialized content key class for resources. Review URL: https://codereview.chromium.org/858123002 --- src/gpu/GrStencilAndCoverTextContext.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/gpu/GrStencilAndCoverTextContext.cpp') 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(&builder[0]); + glyphKey->fChecksum = desc ? desc->getChecksum() : 0; + glyphKey->fTypeface = typeface ? typeface->uniqueID() : 0; + glyphKey->fStroke = GrPath::ComputeStrokeKey(stroke); + builder.finish(); SkAutoTUnref glyphs( - static_cast(ctx->findAndRefCachedResource(resourceKey))); + static_cast(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(); -- cgit v1.2.3