Index: src/gpu/GrContext.cpp |
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp |
index 8d515bf09c295e1bb608b54c5b34f85ca2eb6453..06d579e8542d44dbd94945a20a6965e4589e50c2 100755 |
--- a/src/gpu/GrContext.cpp |
+++ b/src/gpu/GrContext.cpp |
@@ -1926,6 +1926,32 @@ GrPath* GrContext::createPath(const SkPath& inPath, const SkStrokeRec& stroke) { |
return path; |
} |
+GrPathRange* GrContext::createGlyphs(const SkTypeface* typeface, |
+ const SkDescriptor* desc, |
+ const SkStrokeRec& stroke) { |
+ static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain(); |
+ |
+ SkASSERT(fGpu->caps()->pathRenderingSupport()); |
+ |
+ 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), |
+ GrPathRange::resourceType(), 0); |
+ |
+ GrPathRange* glyphs = static_cast<GrPathRange*>(fResourceCache->find(resourceKey)); |
+ if (glyphs && (NULL == desc || glyphs->isEqualTo(*desc))) { |
+ glyphs->ref(); |
+ } else { |
+ glyphs = fGpu->createGlyphs(typeface, desc, stroke); |
+ fResourceCache->purgeAsNeeded(1, glyphs->gpuMemorySize()); |
+ fResourceCache->addResource(resourceKey, glyphs); |
+ } |
+ return glyphs; |
+} |
+ |
void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResource* resource) { |
fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize()); |
fResourceCache->addResource(resourceKey, resource); |