| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, | 93 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, |
| 94 GrPipelineBuilder* pipelineBui
lder, | 94 GrPipelineBuilder* pipelineBui
lder, |
| 95 const SkMatrix& viewMatrix, | 95 const SkMatrix& viewMatrix, |
| 96 const SkPath& path, | 96 const SkPath& path, |
| 97 const GrStrokeInfo& stroke) { | 97 const GrStrokeInfo& stroke) { |
| 98 SkASSERT(!path.isInverseFillType()); | 98 SkASSERT(!path.isInverseFillType()); |
| 99 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view
Matrix)); | 99 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view
Matrix)); |
| 100 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke)); | 100 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, stroke)); |
| 101 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get
FillType())); | 101 target->stencilPath(*pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 104 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
| 105 GrPipelineBuilder* pipelineBuilde
r, | 105 GrPipelineBuilder* pipelineBuilde
r, |
| 106 GrColor color, | 106 GrColor color, |
| 107 const SkMatrix& viewMatrix, | 107 const SkMatrix& viewMatrix, |
| 108 const SkPath& path, | 108 const SkPath& path, |
| 109 const GrStrokeInfo& stroke, | 109 const GrStrokeInfo& stroke, |
| 110 bool antiAlias) { | 110 bool antiAlias) { |
| 111 SkASSERT(!stroke.isHairlineStyle()); | 111 SkASSERT(!stroke.isHairlineStyle()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 127 // check that the clip bit is set. | 127 // check that the clip bit is set. |
| 128 kEqualIfInClip_StencilFunc, | 128 kEqualIfInClip_StencilFunc, |
| 129 0xffff, | 129 0xffff, |
| 130 0x0000, | 130 0x0000, |
| 131 0xffff); | 131 0xffff); |
| 132 | 132 |
| 133 pipelineBuilder->setStencil(kInvertedStencilPass); | 133 pipelineBuilder->setStencil(kInvertedStencilPass); |
| 134 | 134 |
| 135 // fake inverse with a stencil and cover | 135 // fake inverse with a stencil and cover |
| 136 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE,
viewMatrix)); | 136 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE,
viewMatrix)); |
| 137 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path
.getFillType())); | 137 target->stencilPath(*pipelineBuilder, pp, p, convert_skpath_filltype(pat
h.getFillType())); |
| 138 | 138 |
| 139 SkMatrix invert = SkMatrix::I(); | 139 SkMatrix invert = SkMatrix::I(); |
| 140 SkRect bounds = | 140 SkRect bounds = |
| 141 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge
t()->width()), | 141 SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarge
t()->width()), |
| 142 SkIntToScalar(pipelineBuilder->getRenderTarget()->h
eight())); | 142 SkIntToScalar(pipelineBuilder->getRenderTarget()->h
eight())); |
| 143 SkMatrix vmi; | 143 SkMatrix vmi; |
| 144 // mapRect through persp matrix may not be correct | 144 // mapRect through persp matrix may not be correct |
| 145 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { | 145 if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) { |
| 146 vmi.mapRect(&bounds); | 146 vmi.mapRect(&bounds); |
| 147 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion | 147 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion |
| 148 // precision. | 148 // precision. |
| 149 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf; | 149 SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf; |
| 150 bounds.outset(bloat, bloat); | 150 bounds.outset(bloat, bloat); |
| 151 } else { | 151 } else { |
| 152 if (!viewMatrix.invert(&invert)) { | 152 if (!viewMatrix.invert(&invert)) { |
| 153 return false; | 153 return false; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi
ewMatrix; | 156 const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : vi
ewMatrix; |
| 157 target->drawBWRect(pipelineBuilder, color, viewM, bounds, NULL, &invert)
; | 157 target->drawBWRect(*pipelineBuilder, color, viewM, bounds, NULL, &invert
); |
| 158 } else { | 158 } else { |
| 159 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 159 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
| 160 kZero_StencilOp, | 160 kZero_StencilOp, |
| 161 kZero_StencilOp, | 161 kZero_StencilOp, |
| 162 kNotEqual_StencilFunc, | 162 kNotEqual_StencilFunc, |
| 163 0xffff, | 163 0xffff, |
| 164 0x0000, | 164 0x0000, |
| 165 0xffff); | 165 0xffff); |
| 166 | 166 |
| 167 pipelineBuilder->setStencil(kStencilPass); | 167 pipelineBuilder->setStencil(kStencilPass); |
| 168 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); | 168 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); |
| 169 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); | 169 target->drawPath(*pipelineBuilder, pp, p, convert_skpath_filltype(path.g
etFillType())); |
| 170 } | 170 } |
| 171 | 171 |
| 172 pipelineBuilder->stencil()->setDisabled(); | 172 pipelineBuilder->stencil()->setDisabled(); |
| 173 return true; | 173 return true; |
| 174 } | 174 } |
| OLD | NEW |