OLD | NEW |
---|---|
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 SkStrokeRec& stroke, |
60 bool antiAlias) const { | 60 bool antiAlias) const { |
61 return !stroke.isHairlineStyle() && | 61 |
62 !antiAlias && // doesn't do per-path AA, relies on the target having MSAA | 62 if (stroke.isHairlineStyle()) { |
63 pipelineBuilder->getStencil().isDisabled(); | 63 return false; |
64 } | |
65 if (!pipelineBuilder->getStencil().isDisabled()) { | |
66 return false; | |
67 } | |
68 if (antiAlias) { | |
69 return pipelineBuilder->getRenderTarget()->isMultisampled( | |
70 GrRenderTarget::kStencilBuffer_PipelineStage) && | |
71 pipelineBuilder->canTweakAlphaForCoverage(); | |
72 } else { | |
73 return true; // doesn't do per-path AA, relies on the target having MSAA | |
74 } | |
64 } | 75 } |
65 | 76 |
66 GrPathRenderer::StencilSupport | 77 GrPathRenderer::StencilSupport |
67 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 78 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
68 const GrPipelineBuilder*, | 79 const GrPipelineBuilder*, |
69 const SkPath&, | 80 const SkPath&, |
70 const SkStrokeRec&) const { | 81 const SkStrokeRec&) const { |
71 return GrPathRenderer::kStencilOnly_StencilSupport; | 82 return GrPathRenderer::kStencilOnly_StencilSupport; |
72 } | 83 } |
73 | 84 |
(...skipping 20 matching lines...) Expand all Loading... | |
94 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType())); | 105 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType())); |
95 } | 106 } |
96 | 107 |
97 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 108 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
98 GrPipelineBuilder* pipelineBuilde r, | 109 GrPipelineBuilder* pipelineBuilde r, |
99 GrColor color, | 110 GrColor color, |
100 const SkMatrix& viewMatrix, | 111 const SkMatrix& viewMatrix, |
101 const SkPath& path, | 112 const SkPath& path, |
102 const SkStrokeRec& stroke, | 113 const SkStrokeRec& stroke, |
103 bool antiAlias) { | 114 bool antiAlias) { |
104 SkASSERT(!antiAlias); | |
105 SkASSERT(!stroke.isHairlineStyle()); | 115 SkASSERT(!stroke.isHairlineStyle()); |
106 | 116 |
107 SkASSERT(pipelineBuilder->getStencil().isDisabled()); | 117 SkASSERT(pipelineBuilder->getStencil().isDisabled()); |
108 | 118 |
109 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); | 119 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); |
110 | 120 |
111 if (path.isInverseFillType()) { | 121 if (path.isInverseFillType()) { |
112 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, | 122 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
113 kZero_StencilOp, | 123 kZero_StencilOp, |
114 kZero_StencilOp, | 124 kZero_StencilOp, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 0xffff, | 163 0xffff, |
154 0x0000, | 164 0x0000, |
155 0xffff); | 165 0xffff); |
156 | 166 |
157 pipelineBuilder->setStencil(kStencilPass); | 167 pipelineBuilder->setStencil(kStencilPass); |
158 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); | 168 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); |
159 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); | 169 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); |
160 } | 170 } |
161 | 171 |
162 pipelineBuilder->stencil()->setDisabled(); | 172 pipelineBuilder->stencil()->setDisabled(); |
173 if (antiAlias) { | |
174 SkASSERT(pipelineBuilder->getRenderTarget()->isMultisampled( | |
175 GrRenderTarget::kAnywhere_PipelineStage)); | |
Chris Dalton
2015/03/20 07:01:45
Here we should also check GrRenderTarget::kStencil
| |
176 pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_StateBit); | |
177 } | |
163 return true; | 178 return true; |
164 } | 179 } |
OLD | NEW |