OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrStencilAndCoverTextContext.h" | 8 #include "GrStencilAndCoverTextContext.h" |
9 #include "GrBitmapTextContext.h" | 9 #include "GrBitmapTextContext.h" |
10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 pos += scalarsPerPosition; | 198 pos += scalarsPerPosition; |
199 } | 199 } |
200 | 200 |
201 this->finish(); | 201 this->finish(); |
202 } | 202 } |
203 | 203 |
204 static GrPathRange* get_gr_glyphs(GrContext* ctx, | 204 static GrPathRange* get_gr_glyphs(GrContext* ctx, |
205 const SkTypeface* typeface, | 205 const SkTypeface* typeface, |
206 const SkDescriptor* desc, | 206 const SkDescriptor* desc, |
207 const SkStrokeRec& stroke) { | 207 const SkStrokeRec& stroke) { |
208 static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); | 208 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); |
209 | 209 GrContentKey key; |
210 GrCacheID::Key key; | 210 GrContentKey::Builder builder(&key, kDomain, 4); |
211 uint64_t* keyData = key.fData64; | 211 struct GlyphKey { |
212 keyData[0] = desc ? desc->getChecksum() : 0; | 212 uint32_t fChecksum; |
213 keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0); | 213 uint32_t fTypeface; |
214 keyData[1] = GrPath::ComputeStrokeKey(stroke); | 214 uint64_t fStroke; |
215 GrResourceKey resourceKey = GrResourceKey(GrCacheID(gGlyphsDomain, key), 0); | 215 }; |
| 216 GlyphKey* glyphKey = reinterpret_cast<GlyphKey*>(&builder[0]); |
| 217 glyphKey->fChecksum = desc ? desc->getChecksum() : 0; |
| 218 glyphKey->fTypeface = typeface ? typeface->uniqueID() : 0; |
| 219 glyphKey->fStroke = GrPath::ComputeStrokeKey(stroke); |
| 220 builder.finish(); |
216 | 221 |
217 SkAutoTUnref<GrPathRange> glyphs( | 222 SkAutoTUnref<GrPathRange> glyphs( |
218 static_cast<GrPathRange*>(ctx->findAndRefCachedResource(resourceKey))); | 223 static_cast<GrPathRange*>(ctx->findAndRefCachedResource(key))); |
219 if (NULL == glyphs || (NULL != desc && !glyphs->isEqualTo(*desc))) { | 224 if (NULL == glyphs || (NULL != desc && !glyphs->isEqualTo(*desc))) { |
220 glyphs.reset(ctx->getGpu()->pathRendering()->createGlyphs(typeface, desc
, stroke)); | 225 glyphs.reset(ctx->getGpu()->pathRendering()->createGlyphs(typeface, desc
, stroke)); |
221 ctx->addResourceToCache(resourceKey, glyphs); | 226 ctx->addResourceToCache(key, glyphs); |
222 } | 227 } |
223 | 228 |
224 return glyphs.detach(); | 229 return glyphs.detach(); |
225 } | 230 } |
226 | 231 |
227 void GrStencilAndCoverTextContext::init(const GrPaint& paint, | 232 void GrStencilAndCoverTextContext::init(const GrPaint& paint, |
228 const SkPaint& skPaint, | 233 const SkPaint& skPaint, |
229 size_t textByteLength, | 234 size_t textByteLength, |
230 RenderMode renderMode, | 235 RenderMode renderMode, |
231 const SkMatrix& viewMatrix) { | 236 const SkMatrix& viewMatrix) { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 457 |
453 SkGlyphCache::AttachCache(fGlyphCache); | 458 SkGlyphCache::AttachCache(fGlyphCache); |
454 fGlyphCache = NULL; | 459 fGlyphCache = NULL; |
455 | 460 |
456 fPipelineBuilder.stencil()->setDisabled(); | 461 fPipelineBuilder.stencil()->setDisabled(); |
457 fStateRestore.set(NULL); | 462 fStateRestore.set(NULL); |
458 fViewMatrix = fContextInitialMatrix; | 463 fViewMatrix = fContextInitialMatrix; |
459 GrTextContext::finish(); | 464 GrTextContext::finish(); |
460 } | 465 } |
461 | 466 |
OLD | NEW |