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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider*
resourceProvider) | 44 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider*
resourceProvider) |
45 : fResourceProvider(resourceProvider) { | 45 : fResourceProvider(resourceProvider) { |
46 } | 46 } |
47 | 47 |
48 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, | 48 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, |
49 const GrPipelineBuilder* pipelin
eBuilder, | 49 const GrPipelineBuilder* pipelin
eBuilder, |
50 const SkMatrix& viewMatrix, | 50 const SkMatrix& viewMatrix, |
51 const SkPath& path, | 51 const SkPath& path, |
52 const GrStrokeInfo& stroke, | 52 const GrStrokeInfo& stroke, |
53 bool antiAlias) const { | 53 bool antiAlias) const { |
54 return !stroke.isHairlineStyle() && | 54 if (stroke.isHairlineStyle()) { |
55 !antiAlias && // doesn't do per-path AA, relies on the target having MSA
A | 55 return false; |
56 pipelineBuilder->getStencil().isDisabled(); | 56 } |
| 57 if (!pipelineBuilder->getStencil().isDisabled()) { |
| 58 return false; |
| 59 } |
| 60 if (antiAlias) { |
| 61 return pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled()
; |
| 62 } else { |
| 63 return true; // doesn't do per-path AA, relies on the target having MSAA |
| 64 } |
57 } | 65 } |
58 | 66 |
59 GrPathRenderer::StencilSupport | 67 GrPathRenderer::StencilSupport |
60 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 68 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
61 const GrPipelineBuilder*, | 69 const GrPipelineBuilder*, |
62 const SkPath&, | 70 const SkPath&, |
63 const GrStrokeInfo&) const { | 71 const GrStrokeInfo&) const { |
64 return GrPathRenderer::kStencilOnly_StencilSupport; | 72 return GrPathRenderer::kStencilOnly_StencilSupport; |
65 } | 73 } |
66 | 74 |
(...skipping 26 matching lines...) Expand all Loading... |
93 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get
FillType())); | 101 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get
FillType())); |
94 } | 102 } |
95 | 103 |
96 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 104 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
97 GrPipelineBuilder* pipelineBuilde
r, | 105 GrPipelineBuilder* pipelineBuilde
r, |
98 GrColor color, | 106 GrColor color, |
99 const SkMatrix& viewMatrix, | 107 const SkMatrix& viewMatrix, |
100 const SkPath& path, | 108 const SkPath& path, |
101 const GrStrokeInfo& stroke, | 109 const GrStrokeInfo& stroke, |
102 bool antiAlias) { | 110 bool antiAlias) { |
103 SkASSERT(!antiAlias); | |
104 SkASSERT(!stroke.isHairlineStyle()); | 111 SkASSERT(!stroke.isHairlineStyle()); |
105 SkASSERT(pipelineBuilder->getStencil().isDisabled()); | 112 SkASSERT(pipelineBuilder->getStencil().isDisabled()); |
106 | 113 |
| 114 if (antiAlias) { |
| 115 SkASSERT(pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled
()); |
| 116 pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_Flag); |
| 117 } |
| 118 |
107 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke)); | 119 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke)); |
108 | 120 |
109 if (path.isInverseFillType()) { | 121 if (path.isInverseFillType()) { |
110 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, | 122 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
111 kZero_StencilOp, | 123 kZero_StencilOp, |
112 kZero_StencilOp, | 124 kZero_StencilOp, |
113 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 | 125 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 |
114 // outside the clip. So we can't just fill where the user bits are 0
. We also need to | 126 // outside the clip. So we can't just fill where the user bits are 0
. We also need to |
115 // check that the clip bit is set. | 127 // check that the clip bit is set. |
116 kEqualIfInClip_StencilFunc, | 128 kEqualIfInClip_StencilFunc, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 0xffff); | 165 0xffff); |
154 | 166 |
155 pipelineBuilder->setStencil(kStencilPass); | 167 pipelineBuilder->setStencil(kStencilPass); |
156 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); | 168 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); |
157 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); | 169 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); |
158 } | 170 } |
159 | 171 |
160 pipelineBuilder->stencil()->setDisabled(); | 172 pipelineBuilder->stencil()->setDisabled(); |
161 return true; | 173 return true; |
162 } | 174 } |
OLD | NEW |