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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrPathRendering.h ('k') | src/gpu/GrStencilAndCoverTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrStencilAndCoverPathRenderer.h" 10 #include "GrStencilAndCoverPathRenderer.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 target->getDrawState().getStencil().isDisabled(); 44 target->getDrawState().getStencil().isDisabled();
45 } 45 }
46 46
47 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor t( 47 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor t(
48 const SkPath&, 48 const SkPath&,
49 const SkStrokeRec& , 49 const SkStrokeRec& ,
50 const GrDrawTarget*) con st { 50 const GrDrawTarget*) con st {
51 return GrPathRenderer::kStencilOnly_StencilSupport; 51 return GrPathRenderer::kStencilOnly_StencilSupport;
52 } 52 }
53 53
54 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
55 GrContext* ctx = gpu->getContext();
56 GrResourceKey resourceKey = GrPath::ComputeKey(skPath, stroke);
57 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (resourceKey)));
58 if (NULL == path || !path->isEqualTo(skPath, stroke)) {
59 path.reset(gpu->pathRendering()->createPath(skPath, stroke));
60 ctx->addResourceToCache(resourceKey, path);
61 }
62 return path.detach();
63 }
64
54 void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path, 65 void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path,
55 const SkStrokeRec& stroke, 66 const SkStrokeRec& stroke,
56 GrDrawTarget* target) { 67 GrDrawTarget* target) {
57 SkASSERT(!path.isInverseFillType()); 68 SkASSERT(!path.isInverseFillType());
58 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); 69 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
59 target->stencilPath(p, path.getFillType()); 70 target->stencilPath(p, path.getFillType());
60 } 71 }
61 72
62 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path, 73 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path,
63 const SkStrokeRec& stroke, 74 const SkStrokeRec& stroke,
64 GrDrawTarget* target, 75 GrDrawTarget* target,
65 bool antiAlias) { 76 bool antiAlias) {
66 SkASSERT(!antiAlias); 77 SkASSERT(!antiAlias);
67 SkASSERT(!stroke.isHairlineStyle()); 78 SkASSERT(!stroke.isHairlineStyle());
68 79
69 GrDrawState* drawState = target->drawState(); 80 GrDrawState* drawState = target->drawState();
70 SkASSERT(drawState->getStencil().isDisabled()); 81 SkASSERT(drawState->getStencil().isDisabled());
71 82
72 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); 83 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke));
73 84
74 if (path.isInverseFillType()) { 85 if (path.isInverseFillType()) {
75 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, 86 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
76 kZero_StencilOp, 87 kZero_StencilOp,
77 kZero_StencilOp, 88 kZero_StencilOp,
78 // We know our rect will hit pixels outside the clip and the user bi ts will be 0 89 // We know our rect will hit pixels outside the clip and the user bi ts will be 0
79 // outside the clip. So we can't just fill where the user bits are 0 . We also need to 90 // outside the clip. So we can't just fill where the user bits are 0 . We also need to
80 // check that the clip bit is set. 91 // check that the clip bit is set.
81 kEqualIfInClip_StencilFunc, 92 kEqualIfInClip_StencilFunc,
82 0xffff, 93 0xffff,
(...skipping 11 matching lines...) Expand all
94 0xffff); 105 0xffff);
95 106
96 *drawState->stencil() = kStencilPass; 107 *drawState->stencil() = kStencilPass;
97 } 108 }
98 109
99 target->drawPath(p, path.getFillType()); 110 target->drawPath(p, path.getFillType());
100 111
101 target->drawState()->stencil()->setDisabled(); 112 target->drawState()->stencil()->setDisabled();
102 return true; 113 return true;
103 } 114 }
OLDNEW
« 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