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 // No Xfer processors that might do blending inside the shader. | |
70 // Coverage modulation for mixed samples is done *after* shading, so ble nding | |
71 // must occur in the ROP. | |
72 // TODO: Update Xfer processors to better support mixed samples. | |
73 if (GrRenderTarget::kStencil_SampleConfig == | |
74 pipelineBuilder->getRenderTarget()->sampleConfig() && | |
75 pipelineBuilder->willXPNeedDstCopy(*fGpu->caps(), GrProcOptInfo(), G rProcOptInfo())) { | |
76 return false; | |
77 } | |
78 | |
79 return pipelineBuilder->getRenderTarget()->isMultisampled( | |
80 GrRenderTarget::kStencil_BufferBit) && | |
81 pipelineBuilder->canTweakAlphaForCoverage(); | |
82 } else { | |
83 return true; // doesn't do per-path AA, relies on the target having MSAA | |
84 } | |
64 } | 85 } |
65 | 86 |
66 GrPathRenderer::StencilSupport | 87 GrPathRenderer::StencilSupport |
67 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 88 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
68 const GrPipelineBuilder*, | 89 const GrPipelineBuilder*, |
69 const SkPath&, | 90 const SkPath&, |
70 const SkStrokeRec&) const { | 91 const SkStrokeRec&) const { |
71 return GrPathRenderer::kStencilOnly_StencilSupport; | 92 return GrPathRenderer::kStencilOnly_StencilSupport; |
72 } | 93 } |
73 | 94 |
(...skipping 20 matching lines...) Expand all Loading... | |
94 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType())); | 115 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get FillType())); |
95 } | 116 } |
96 | 117 |
97 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 118 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
98 GrPipelineBuilder* pipelineBuilde r, | 119 GrPipelineBuilder* pipelineBuilde r, |
99 GrColor color, | 120 GrColor color, |
100 const SkMatrix& viewMatrix, | 121 const SkMatrix& viewMatrix, |
101 const SkPath& path, | 122 const SkPath& path, |
102 const SkStrokeRec& stroke, | 123 const SkStrokeRec& stroke, |
103 bool antiAlias) { | 124 bool antiAlias) { |
104 SkASSERT(!antiAlias); | |
105 SkASSERT(!stroke.isHairlineStyle()); | 125 SkASSERT(!stroke.isHairlineStyle()); |
106 | 126 |
107 SkASSERT(pipelineBuilder->getStencil().isDisabled()); | 127 SkASSERT(pipelineBuilder->getStencil().isDisabled()); |
108 | 128 |
109 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); | 129 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); |
110 | 130 |
111 if (path.isInverseFillType()) { | 131 if (path.isInverseFillType()) { |
112 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, | 132 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
113 kZero_StencilOp, | 133 kZero_StencilOp, |
114 kZero_StencilOp, | 134 kZero_StencilOp, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 0xffff, | 173 0xffff, |
154 0x0000, | 174 0x0000, |
155 0xffff); | 175 0xffff); |
156 | 176 |
157 pipelineBuilder->setStencil(kStencilPass); | 177 pipelineBuilder->setStencil(kStencilPass); |
158 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); | 178 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr ix)); |
159 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); | 179 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge tFillType())); |
160 } | 180 } |
161 | 181 |
162 pipelineBuilder->stencil()->setDisabled(); | 182 pipelineBuilder->stencil()->setDisabled(); |
183 if (antiAlias) { | |
184 SkASSERT(pipelineBuilder->getRenderTarget()->isMultisampled( | |
185 GrRenderTarget::kStencil_BufferBit)); | |
186 pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_StateBit); | |
Chris Dalton
2015/04/17 22:05:12
Sorry, I think I may have misled you about where t
| |
187 } | |
163 return true; | 188 return true; |
164 } | 189 } |
OLD | NEW |