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