| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 ctx->addResourceToCache(resourceKey, path); | 78 ctx->addResourceToCache(resourceKey, path); |
| 79 } | 79 } |
| 80 return path.detach(); | 80 return path.detach(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, | 83 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, |
| 84 GrDrawState* drawState, | 84 GrDrawState* drawState, |
| 85 const SkPath& path, | 85 const SkPath& path, |
| 86 const SkStrokeRec& stroke) { | 86 const SkStrokeRec& stroke) { |
| 87 SkASSERT(!path.isInverseFillType()); | 87 SkASSERT(!path.isInverseFillType()); |
| 88 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE)); |
| 88 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); | 89 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); |
| 89 target->stencilPath(drawState, p, convert_skpath_filltype(path.getFillType()
)); | 90 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFillTy
pe())); |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 93 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
| 93 GrDrawState* drawState, | 94 GrDrawState* drawState, |
| 94 GrColor color, | 95 GrColor color, |
| 95 const SkPath& path, | 96 const SkPath& path, |
| 96 const SkStrokeRec& stroke, | 97 const SkStrokeRec& stroke, |
| 97 bool antiAlias) { | 98 bool antiAlias) { |
| 98 SkASSERT(!antiAlias); | 99 SkASSERT(!antiAlias); |
| 99 SkASSERT(!stroke.isHairlineStyle()); | 100 SkASSERT(!stroke.isHairlineStyle()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 // outside the clip. So we can't just fill where the user bits are 0
. We also need to | 111 // outside the clip. So we can't just fill where the user bits are 0
. We also need to |
| 111 // check that the clip bit is set. | 112 // check that the clip bit is set. |
| 112 kEqualIfInClip_StencilFunc, | 113 kEqualIfInClip_StencilFunc, |
| 113 0xffff, | 114 0xffff, |
| 114 0x0000, | 115 0x0000, |
| 115 0xffff); | 116 0xffff); |
| 116 | 117 |
| 117 drawState->setStencil(kInvertedStencilPass); | 118 drawState->setStencil(kInvertedStencilPass); |
| 118 | 119 |
| 119 // fake inverse with a stencil and cover | 120 // fake inverse with a stencil and cover |
| 120 target->stencilPath(drawState, p, convert_skpath_filltype(path.getFillTy
pe())); | 121 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE))
; |
| 122 target->stencilPath(drawState, pp, p, convert_skpath_filltype(path.getFi
llType())); |
| 121 | 123 |
| 122 GrDrawState::AutoViewMatrixRestore avmr; | 124 GrDrawState::AutoViewMatrixRestore avmr; |
| 123 SkRect bounds = SkRect::MakeLTRB(0, 0, | 125 SkRect bounds = SkRect::MakeLTRB(0, 0, |
| 124 SkIntToScalar(drawState->getRenderTarge
t()->width()), | 126 SkIntToScalar(drawState->getRenderTarge
t()->width()), |
| 125 SkIntToScalar(drawState->getRenderTarge
t()->height())); | 127 SkIntToScalar(drawState->getRenderTarge
t()->height())); |
| 126 SkMatrix vmi; | 128 SkMatrix vmi; |
| 127 // mapRect through persp matrix may not be correct | 129 // mapRect through persp matrix may not be correct |
| 128 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { | 130 if (!drawState->getViewMatrix().hasPerspective() && drawState->getViewIn
verse(&vmi)) { |
| 129 vmi.mapRect(&bounds); | 131 vmi.mapRect(&bounds); |
| 130 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion | 132 // theoretically could set bloat = 0, instead leave it because of ma
trix inversion |
| 131 // precision. | 133 // precision. |
| 132 SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_Scala
rHalf; | 134 SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_Scala
rHalf; |
| 133 bounds.outset(bloat, bloat); | 135 bounds.outset(bloat, bloat); |
| 134 } else { | 136 } else { |
| 135 avmr.setIdentity(drawState); | 137 avmr.setIdentity(drawState); |
| 136 } | 138 } |
| 137 target->drawSimpleRect(drawState, color, bounds); | 139 target->drawSimpleRect(drawState, color, bounds); |
| 138 } else { | 140 } else { |
| 139 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 141 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
| 140 kZero_StencilOp, | 142 kZero_StencilOp, |
| 141 kZero_StencilOp, | 143 kZero_StencilOp, |
| 142 kNotEqual_StencilFunc, | 144 kNotEqual_StencilFunc, |
| 143 0xffff, | 145 0xffff, |
| 144 0x0000, | 146 0x0000, |
| 145 0xffff); | 147 0xffff); |
| 146 | 148 |
| 147 drawState->setStencil(kStencilPass); | 149 drawState->setStencil(kStencilPass); |
| 148 target->drawPath(drawState, color, p, convert_skpath_filltype(path.getFi
llType())); | 150 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color)); |
| 151 target->drawPath(drawState, pp, p, convert_skpath_filltype(path.getFillT
ype())); |
| 149 } | 152 } |
| 150 | 153 |
| 151 drawState->stencil()->setDisabled(); | 154 drawState->stencil()->setDisabled(); |
| 152 return true; | 155 return true; |
| 153 } | 156 } |
| OLD | NEW |