| 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 16 matching lines...) Expand all Loading... |
| 27 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrGpu* gpu) { | 27 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrGpu* gpu) { |
| 28 SkASSERT(gpu->caps()->pathRenderingSupport()); | 28 SkASSERT(gpu->caps()->pathRenderingSupport()); |
| 29 fGpu = gpu; | 29 fGpu = gpu; |
| 30 gpu->ref(); | 30 gpu->ref(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { | 33 GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { |
| 34 fGpu->unref(); | 34 fGpu->unref(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool GrStencilAndCoverPathRenderer::canDrawPath(const SkPath& path, | 37 bool GrStencilAndCoverPathRenderer::canDrawPath(const SkStrokeRec& stroke, |
| 38 const SkStrokeRec& stroke, | |
| 39 const GrDrawTarget* target, | 38 const GrDrawTarget* target, |
| 40 bool antiAlias) const { | 39 bool antiAlias) const { |
| 41 return !stroke.isHairlineStyle() && | 40 return !stroke.isHairlineStyle() && |
| 42 !antiAlias && // doesn't do per-path AA, relies on the target having
MSAA | 41 !antiAlias && // doesn't do per-path AA, relies on the target having
MSAA |
| 43 NULL != target->getDrawState().getRenderTarget()->getStencilBuffer()
&& | 42 NULL != target->getDrawState().getRenderTarget()->getStencilBuffer()
&& |
| 44 target->getDrawState().getStencil().isDisabled(); | 43 target->getDrawState().getStencil().isDisabled(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor
t( | 46 GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSuppor
t( |
| 48 const SkPath&, | |
| 49 const SkStrokeRec& , | 47 const SkStrokeRec& , |
| 50 const GrDrawTarget*) con
st { | 48 const GrDrawTarget*) con
st { |
| 51 return GrPathRenderer::kStencilOnly_StencilSupport; | 49 return GrPathRenderer::kStencilOnly_StencilSupport; |
| 52 } | 50 } |
| 53 | 51 |
| 54 void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path, | 52 void GrStencilAndCoverPathRenderer::onStencilPath(const SkStrokeRec& stroke, |
| 55 const SkStrokeRec& stroke, | |
| 56 GrDrawTarget* target) { | 53 GrDrawTarget* target) { |
| 57 SkASSERT(!path.isInverseFillType()); | 54 SkASSERT(!this->path().isInverseFillType()); |
| 58 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); | 55 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(this->path(), stroke))
; |
| 59 target->stencilPath(p, path.getFillType()); | 56 target->stencilPath(p, this->path().getFillType()); |
| 60 } | 57 } |
| 61 | 58 |
| 62 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path, | 59 bool GrStencilAndCoverPathRenderer::onDrawPath(const SkStrokeRec& stroke, |
| 63 const SkStrokeRec& stroke, | |
| 64 GrDrawTarget* target, | 60 GrDrawTarget* target, |
| 65 bool antiAlias) { | 61 bool antiAlias) { |
| 66 SkASSERT(!antiAlias); | 62 SkASSERT(!antiAlias); |
| 67 SkASSERT(!stroke.isHairlineStyle()); | 63 SkASSERT(!stroke.isHairlineStyle()); |
| 68 | 64 |
| 69 GrDrawState* drawState = target->drawState(); | 65 GrDrawState* drawState = target->drawState(); |
| 70 SkASSERT(drawState->getStencil().isDisabled()); | 66 SkASSERT(drawState->getStencil().isDisabled()); |
| 71 | 67 |
| 72 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); | 68 SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(this->path(), stroke))
; |
| 73 | 69 |
| 74 if (path.isInverseFillType()) { | 70 if (this->path().isInverseFillType()) { |
| 75 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, | 71 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
| 76 kZero_StencilOp, | 72 kZero_StencilOp, |
| 77 kZero_StencilOp, | 73 kZero_StencilOp, |
| 78 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 | 74 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 |
| 79 // outside the clip. So we can't just fill where the user bits are 0
. We also need to | 75 // outside the clip. So we can't just fill where the user bits are 0
. We also need to |
| 80 // check that the clip bit is set. | 76 // check that the clip bit is set. |
| 81 kEqualIfInClip_StencilFunc, | 77 kEqualIfInClip_StencilFunc, |
| 82 0xffff, | 78 0xffff, |
| 83 0x0000, | 79 0x0000, |
| 84 0xffff); | 80 0xffff); |
| 85 | 81 |
| 86 *drawState->stencil() = kInvertedStencilPass; | 82 *drawState->stencil() = kInvertedStencilPass; |
| 87 } else { | 83 } else { |
| 88 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, | 84 GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
| 89 kZero_StencilOp, | 85 kZero_StencilOp, |
| 90 kZero_StencilOp, | 86 kZero_StencilOp, |
| 91 kNotEqual_StencilFunc, | 87 kNotEqual_StencilFunc, |
| 92 0xffff, | 88 0xffff, |
| 93 0x0000, | 89 0x0000, |
| 94 0xffff); | 90 0xffff); |
| 95 | 91 |
| 96 *drawState->stencil() = kStencilPass; | 92 *drawState->stencil() = kStencilPass; |
| 97 } | 93 } |
| 98 | 94 |
| 99 target->drawPath(p, path.getFillType()); | 95 target->drawPath(p, this->path().getFillType()); |
| 100 | 96 |
| 101 target->drawState()->stencil()->setDisabled(); | 97 target->drawState()->stencil()->setDisabled(); |
| 102 return true; | 98 return true; |
| 103 } | 99 } |
| OLD | NEW |