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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 resourceProvider->assignUniqueKeyToResource(key, path); | 72 resourceProvider->assignUniqueKeyToResource(key, path); |
73 } | 73 } |
74 } else { | 74 } else { |
75 SkASSERT(path->isEqualTo(skPath, stroke)); | 75 SkASSERT(path->isEqualTo(skPath, stroke)); |
76 } | 76 } |
77 return path.detach(); | 77 return path.detach(); |
78 } | 78 } |
79 | 79 |
80 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { | 80 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { |
81 SkASSERT(!args.fPath->isInverseFillType()); | 81 SkASSERT(!args.fPath->isInverseFillType()); |
82 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, *arg
s.fViewMatrix)); | |
83 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, *args.fSt
roke)); | 82 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, *args.fPath, *args.fSt
roke)); |
84 args.fTarget->stencilPath(*args.fPipelineBuilder, pp, p, | 83 args.fTarget->stencilPath(*args.fPipelineBuilder, *args.fViewMatrix, p, |
85 convert_skpath_filltype(args.fPath->getFillType())
); | 84 convert_skpath_filltype(args.fPath->getFillType())
); |
86 } | 85 } |
87 | 86 |
88 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { | 87 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { |
89 SkASSERT(!args.fStroke->isHairlineStyle()); | 88 SkASSERT(!args.fStroke->isHairlineStyle()); |
90 const SkPath& path = *args.fPath; | 89 const SkPath& path = *args.fPath; |
91 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder; | 90 GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder; |
92 const SkMatrix& viewMatrix = *args.fViewMatrix; | 91 const SkMatrix& viewMatrix = *args.fViewMatrix; |
93 | 92 |
94 SkASSERT(pipelineBuilder->getStencil().isDisabled()); | 93 SkASSERT(pipelineBuilder->getStencil().isDisabled()); |
(...skipping 13 matching lines...) Expand all Loading... |
108 // outside the clip. So we can't just fill where the user bits are 0
. We also need to | 107 // outside the clip. So we can't just fill where the user bits are 0
. We also need to |
109 // check that the clip bit is set. | 108 // check that the clip bit is set. |
110 kEqualIfInClip_StencilFunc, | 109 kEqualIfInClip_StencilFunc, |
111 0xffff, | 110 0xffff, |
112 0x0000, | 111 0x0000, |
113 0xffff); | 112 0xffff); |
114 | 113 |
115 pipelineBuilder->setStencil(kInvertedStencilPass); | 114 pipelineBuilder->setStencil(kInvertedStencilPass); |
116 | 115 |
117 // fake inverse with a stencil and cover | 116 // fake inverse with a stencil and cover |
118 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE,
viewMatrix)); | 117 args.fTarget->stencilPath(*pipelineBuilder, viewMatrix, p, |
119 args.fTarget->stencilPath(*pipelineBuilder, pp, p, | |
120 convert_skpath_filltype(path.getFillType())); | 118 convert_skpath_filltype(path.getFillType())); |
121 | 119 |
122 SkMatrix invert = SkMatrix::I(); | 120 SkMatrix invert = SkMatrix::I(); |
123 SkRect bounds = | 121 SkRect bounds = |
124 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge
t()->width()), | 122 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge
t()->width()), |
125 SkIntToScalar(pipelineBuilder->getRenderTarget()->h
eight())); | 123 SkIntToScalar(pipelineBuilder->getRenderTarget()->h
eight())); |
126 SkMatrix vmi; | 124 SkMatrix vmi; |
127 // mapRect through persp matrix may not be correct | 125 // mapRect through persp matrix may not be correct |
128 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { | 126 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { |
129 vmi.mapRect(&bounds); | 127 vmi.mapRect(&bounds); |
(...skipping 11 matching lines...) Expand all Loading... |
141 } else { | 139 } else { |
142 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 140 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
143 kZero_StencilOp, | 141 kZero_StencilOp, |
144 kKeep_StencilOp, | 142 kKeep_StencilOp, |
145 kNotEqual_StencilFunc, | 143 kNotEqual_StencilFunc, |
146 0xffff, | 144 0xffff, |
147 0x0000, | 145 0x0000, |
148 0xffff); | 146 0xffff); |
149 | 147 |
150 pipelineBuilder->setStencil(kStencilPass); | 148 pipelineBuilder->setStencil(kStencilPass); |
151 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(args.fColor, vi
ewMatrix)); | 149 args.fTarget->drawPath(*pipelineBuilder, viewMatrix, args.fColor, p, |
152 args.fTarget->drawPath(*pipelineBuilder, pp, p, | |
153 convert_skpath_filltype(path.getFillType())); | 150 convert_skpath_filltype(path.getFillType())); |
154 } | 151 } |
155 | 152 |
156 pipelineBuilder->stencil()->setDisabled(); | 153 pipelineBuilder->stencil()->setDisabled(); |
157 return true; | 154 return true; |
158 } | 155 } |
OLD | NEW |