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

Side by Side Diff: src/gpu/GrStencilAndCoverPathRenderer.cpp

Issue 1100073003: Extract gpu line dashing to GrDashLinePathRenderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address review comments Created 5 years, 7 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/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStrokeInfo.h » ('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"
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrPath.h" 14 #include "GrPath.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrRenderTargetPriv.h" 16 #include "GrRenderTargetPriv.h"
17 #include "SkStrokeRec.h" 17 #include "GrStrokeInfo.h"
18 18
19 /* 19 /*
20 * For now paths only natively support winding and even odd fill types 20 * For now paths only natively support winding and even odd fill types
21 */ 21 */
22 static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill) { 22 static GrPathRendering::FillType convert_skpath_filltype(SkPath::FillType fill) {
23 switch (fill) { 23 switch (fill) {
24 default: 24 default:
25 SkFAIL("Incomplete Switch\n"); 25 SkFAIL("Incomplete Switch\n");
26 case SkPath::kWinding_FillType: 26 case SkPath::kWinding_FillType:
27 case SkPath::kInverseWinding_FillType: 27 case SkPath::kInverseWinding_FillType:
(...skipping 21 matching lines...) Expand all
49 } 49 }
50 50
51 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { 51 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() {
52 fGpu->unref(); 52 fGpu->unref();
53 } 53 }
54 54
55 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, 55 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target,
56 const GrPipelineBuilder* pipelin eBuilder, 56 const GrPipelineBuilder* pipelin eBuilder,
57 const SkMatrix& viewMatrix, 57 const SkMatrix& viewMatrix,
58 const SkPath& path, 58 const SkPath& path,
59 const SkStrokeRec& stroke, 59 const GrStrokeInfo& stroke,
60 bool antiAlias) const { 60 bool antiAlias) const {
61 return !stroke.isHairlineStyle() && 61 return !stroke.getStrokeRec().isHairlineStyle() &&
62 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA 62 !stroke.isDashed() &&
63 pipelineBuilder->getStencil().isDisabled(); 63 !antiAlias && // doesn't do per-path AA, relies on the target having MSA A
64 pipelineBuilder->getStencil().isDisabled();
64 } 65 }
65 66
66 GrPathRenderer::StencilSupport 67 GrPathRenderer::StencilSupport
67 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, 68 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
68 const GrPipelineBuilder*, 69 const GrPipelineBuilder*,
69 const SkPath&, 70 const SkPath&,
70 const SkStrokeRec&) const { 71 const GrStrokeInfo&) const {
71 return GrPathRenderer::kStencilOnly_StencilSupport; 72 return GrPathRenderer::kStencilOnly_StencilSupport;
72 } 73 }
73 74
74 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) { 75 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
75 GrContext* ctx = gpu->getContext(); 76 GrContext* ctx = gpu->getContext();
76 GrUniqueKey key; 77 GrUniqueKey key;
77 GrPath::ComputeKey(skPath, stroke, &key); 78 GrPath::ComputeKey(skPath, stroke, &key);
78 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (key))); 79 SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource (key)));
79 if (NULL == path || !path->isEqualTo(skPath, stroke)) { 80 if (NULL == path || !path->isEqualTo(skPath, stroke)) {
80 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); 81 path.reset(gpu->pathRendering()->createPath(skPath, stroke));
81 ctx->addResourceToCache(key, path); 82 ctx->addResourceToCache(key, path);
82 } 83 }
83 return path.detach(); 84 return path.detach();
84 } 85 }
85 86
86 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, 87 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target,
87 GrPipelineBuilder* pipelineBui lder, 88 GrPipelineBuilder* pipelineBui lder,
88 const SkMatrix& viewMatrix, 89 const SkMatrix& viewMatrix,
89 const SkPath& path, 90 const SkPath& path,
90 const SkStrokeRec& stroke) { 91 const GrStrokeInfo& stroke) {
91 SkASSERT(!path.isInverseFillType()); 92 SkASSERT(!path.isInverseFillType());
92 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view Matrix)); 93 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view Matrix));
93 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); 94 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke.getStrokeRec()));
94 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType())); 95 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType()));
95 } 96 }
96 97
97 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, 98 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target,
98 GrPipelineBuilder* pipelineBuilde r, 99 GrPipelineBuilder* pipelineBuilde r,
99 GrColor color, 100 GrColor color,
100 const SkMatrix& viewMatrix, 101 const SkMatrix& viewMatrix,
101 const SkPath& path, 102 const SkPath& path,
102 const SkStrokeRec& stroke, 103 const GrStrokeInfo& stroke,
103 bool antiAlias) { 104 bool antiAlias) {
104 SkASSERT(!antiAlias); 105 SkASSERT(!antiAlias);
105 SkASSERT(!stroke.isHairlineStyle()); 106 SkASSERT(!stroke.getStrokeRec().isHairlineStyle());
106 107 SkASSERT(!stroke.isDashed());
107 SkASSERT(pipelineBuilder->getStencil().isDisabled()); 108 SkASSERT(pipelineBuilder->getStencil().isDisabled());
108 109
109 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); 110 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke.getStrokeRec()));
110 111
111 if (path.isInverseFillType()) { 112 if (path.isInverseFillType()) {
112 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, 113 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass,
113 kZero_StencilOp, 114 kZero_StencilOp,
114 kZero_StencilOp, 115 kZero_StencilOp,
115 // We know our rect will hit pixels outside the clip and the user bi ts will be 0 116 // We know our rect will hit pixels outside the clip and the user bi ts will be 0
116 // outside the clip. So we can't just fill where the user bits are 0 . We also need to 117 // outside the clip. So we can't just fill where the user bits are 0 . We also need to
117 // check that the clip bit is set. 118 // check that the clip bit is set.
118 kEqualIfInClip_StencilFunc, 119 kEqualIfInClip_StencilFunc,
119 0xffff, 120 0xffff,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 0xffff); 156 0xffff);
156 157
157 pipelineBuilder->setStencil(kStencilPass); 158 pipelineBuilder->setStencil(kStencilPass);
158 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); 159 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix));
159 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); 160 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType()));
160 } 161 }
161 162
162 pipelineBuilder->stencil()->setDisabled(); 163 pipelineBuilder->stencil()->setDisabled();
163 return true; 164 return true;
164 } 165 }
OLDNEW
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.h ('k') | src/gpu/GrStrokeInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698