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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 fGpu->unref(); | 53 fGpu->unref(); |
54 } | 54 } |
55 | 55 |
56 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, | 56 bool GrStencilAndCoverPathRenderer::canDrawPath(const GrDrawTarget* target, |
57 const GrPipelineBuilder* pipelin
eBuilder, | 57 const GrPipelineBuilder* pipelin
eBuilder, |
58 const SkMatrix& viewMatrix, | 58 const SkMatrix& viewMatrix, |
59 const SkPath& path, | 59 const SkPath& path, |
60 const GrStrokeInfo& stroke, | 60 const GrStrokeInfo& stroke, |
61 bool antiAlias) const { | 61 bool antiAlias) const { |
62 return !stroke.isHairlineStyle() && | 62 return !stroke.isHairlineStyle() && |
63 !stroke.isDashed() && | |
64 !antiAlias && // doesn't do per-path AA, relies on the target having MSA
A | 63 !antiAlias && // doesn't do per-path AA, relies on the target having MSA
A |
65 pipelineBuilder->getStencil().isDisabled(); | 64 pipelineBuilder->getStencil().isDisabled(); |
66 } | 65 } |
67 | 66 |
68 GrPathRenderer::StencilSupport | 67 GrPathRenderer::StencilSupport |
69 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, | 68 GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*, |
70 const GrPipelineBuilder*, | 69 const GrPipelineBuilder*, |
71 const SkPath&, | 70 const SkPath&, |
72 const GrStrokeInfo&) const { | 71 const GrStrokeInfo&) const { |
73 return GrPathRenderer::kStencilOnly_StencilSupport; | 72 return GrPathRenderer::kStencilOnly_StencilSupport; |
74 } | 73 } |
75 | 74 |
76 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec&
stroke) { | 75 static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const GrStrokeInfo&
stroke) { |
77 GrContext* ctx = gpu->getContext(); | 76 GrContext* ctx = gpu->getContext(); |
78 GrUniqueKey key; | 77 GrUniqueKey key; |
79 GrPath::ComputeKey(skPath, stroke, &key); | 78 GrPath::ComputeKey(skPath, stroke, &key); |
80 SkAutoTUnref<GrPath> path( | 79 SkAutoTUnref<GrPath> path( |
81 static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUnique
Key(key))); | 80 static_cast<GrPath*>(ctx->resourceProvider()->findAndRefResourceByUnique
Key(key))); |
82 if (NULL == path || !path->isEqualTo(skPath, stroke)) { | 81 if (NULL == path) { |
83 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); | 82 path.reset(gpu->pathRendering()->createPath(skPath, stroke)); |
84 ctx->resourceProvider()->assignUniqueKeyToResource(key, path); | 83 ctx->resourceProvider()->assignUniqueKeyToResource(key, path); |
| 84 } else { |
| 85 SkASSERT(path->isEqualTo(skPath, stroke)); |
85 } | 86 } |
86 return path.detach(); | 87 return path.detach(); |
87 } | 88 } |
88 | 89 |
89 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, | 90 void GrStencilAndCoverPathRenderer::onStencilPath(GrDrawTarget* target, |
90 GrPipelineBuilder* pipelineBui
lder, | 91 GrPipelineBuilder* pipelineBui
lder, |
91 const SkMatrix& viewMatrix, | 92 const SkMatrix& viewMatrix, |
92 const SkPath& path, | 93 const SkPath& path, |
93 const GrStrokeInfo& stroke) { | 94 const GrStrokeInfo& stroke) { |
94 SkASSERT(!path.isInverseFillType()); | 95 SkASSERT(!path.isInverseFillType()); |
95 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view
Matrix)); | 96 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(GrColor_WHITE, view
Matrix)); |
96 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); | 97 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); |
97 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get
FillType())); | 98 target->stencilPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.get
FillType())); |
98 } | 99 } |
99 | 100 |
100 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, | 101 bool GrStencilAndCoverPathRenderer::onDrawPath(GrDrawTarget* target, |
101 GrPipelineBuilder* pipelineBuilde
r, | 102 GrPipelineBuilder* pipelineBuilde
r, |
102 GrColor color, | 103 GrColor color, |
103 const SkMatrix& viewMatrix, | 104 const SkMatrix& viewMatrix, |
104 const SkPath& path, | 105 const SkPath& path, |
105 const GrStrokeInfo& stroke, | 106 const GrStrokeInfo& stroke, |
106 bool antiAlias) { | 107 bool antiAlias) { |
107 SkASSERT(!antiAlias); | 108 SkASSERT(!antiAlias); |
108 SkASSERT(!stroke.isHairlineStyle()); | 109 SkASSERT(!stroke.isHairlineStyle()); |
109 SkASSERT(!stroke.isDashed()); | |
110 SkASSERT(pipelineBuilder->getStencil().isDisabled()); | 110 SkASSERT(pipelineBuilder->getStencil().isDisabled()); |
111 | 111 |
112 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); | 112 SkAutoTUnref<GrPath> p(get_gr_path(fGpu, path, stroke)); |
113 | 113 |
114 if (path.isInverseFillType()) { | 114 if (path.isInverseFillType()) { |
115 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, | 115 GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
116 kZero_StencilOp, | 116 kZero_StencilOp, |
117 kZero_StencilOp, | 117 kZero_StencilOp, |
118 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 | 118 // We know our rect will hit pixels outside the clip and the user bi
ts will be 0 |
119 // outside the clip. So we can't just fill where the user bits are 0
. We also need to | 119 // outside the clip. So we can't just fill where the user bits are 0
. We also need to |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 0xffff); | 158 0xffff); |
159 | 159 |
160 pipelineBuilder->setStencil(kStencilPass); | 160 pipelineBuilder->setStencil(kStencilPass); |
161 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); | 161 SkAutoTUnref<GrPathProcessor> pp(GrPathProcessor::Create(color, viewMatr
ix)); |
162 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); | 162 target->drawPath(pipelineBuilder, pp, p, convert_skpath_filltype(path.ge
tFillType())); |
163 } | 163 } |
164 | 164 |
165 pipelineBuilder->stencil()->setDisabled(); | 165 pipelineBuilder->stencil()->setDisabled(); |
166 return true; | 166 return true; |
167 } | 167 } |
OLD | NEW |