Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Unified Diff: src/gpu/GrStencilAndCoverPathRenderer.cpp

Issue 578563002: Remove createPath* from GrGpu and GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_glyphmemorypath
Patch Set: Simple quick change Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPathRendering.h ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrStencilAndCoverPathRenderer.cpp
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 55487905324512eef122c9e59989e549cf30d97c..5f55c1a21412eaa43c523f96afbe52049013dbb3 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -51,11 +51,22 @@ GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor
return GrPathRenderer::kStencilOnly_StencilSupport;
}
+static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
+ GrContext* ctx = gpu->getContext();
+ GrResourceKey resourceKey = GrPath::ComputeKey(skPath, stroke);
+ SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource(resourceKey)));
+ if (NULL == path || !path->isEqualTo(skPath, stroke)) {
+ path.reset(gpu->pathRendering()->createPath(skPath, stroke));
+ ctx->addResourceToCache(resourceKey, path);
+ }
+ return path.detach();
+}
+
void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path,
const SkStrokeRec& stroke,
GrDrawTarget* target) {
SkASSERT(!path.isInverseFillType());
- SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke));
+ SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
target->stencilPath(p, path.getFillType());
}
@@ -69,7 +80,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
GrDrawState* drawState = target->drawState();
SkASSERT(drawState->getStencil().isDisabled());
- SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke));
+ SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
if (path.isInverseFillType()) {
GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
« no previous file with comments | « src/gpu/GrPathRendering.h ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698