OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrSoftwarePathRenderer.h" | 8 #include "GrSoftwarePathRenderer.h" |
9 #include "GrAuditTrail.h" | 9 #include "GrAuditTrail.h" |
10 #include "GrClip.h" | 10 #include "GrClip.h" |
11 #include "GrPipelineBuilder.h" | |
12 #include "GrSWMaskHelper.h" | 11 #include "GrSWMaskHelper.h" |
13 #include "GrTextureProvider.h" | 12 #include "GrTextureProvider.h" |
14 #include "batches/GrRectBatchFactory.h" | 13 #include "batches/GrRectBatchFactory.h" |
15 | 14 |
16 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
17 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 16 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
18 // Pass on any style that applies. The caller will apply the style if a suit
able renderer is | 17 // Pass on any style that applies. The caller will apply the style if a suit
able renderer is |
19 // not found and try again with the new GrShape. | 18 // not found and try again with the new GrShape. |
20 return !args.fShape->style().applies() && SkToBool(fTexProvider); | 19 return !args.fShape->style().applies() && SkToBool(fTexProvider); |
21 } | 20 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 const GrPaint& paint, | 65 const GrPaint& paint, |
67 const GrUserStencilSettings& userSten
cilSettings, | 66 const GrUserStencilSettings& userSten
cilSettings, |
68 const GrClip& clip, | 67 const GrClip& clip, |
69 const SkMatrix& viewMatrix, | 68 const SkMatrix& viewMatrix, |
70 const SkRect& rect, | 69 const SkRect& rect, |
71 const SkMatrix& localMatrix) { | 70 const SkMatrix& localMatrix) { |
72 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.ge
tColor(), | 71 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(paint.ge
tColor(), |
73 viewMatr
ix, rect, | 72 viewMatr
ix, rect, |
74 nullptr,
&localMatrix)); | 73 nullptr,
&localMatrix)); |
75 | 74 |
76 GrPipelineBuilder pipelineBuilder(paint, drawContext->mustUseHWAA(paint)); | 75 drawContext->drawBatch(paint, clip, userStencilSettings, batch); |
77 pipelineBuilder.setUserStencil(&userStencilSettings); | |
78 | |
79 drawContext->drawBatch(pipelineBuilder, clip, batch); | |
80 } | 76 } |
81 | 77 |
82 void GrSoftwarePathRenderer::DrawAroundInvPath(GrDrawContext* drawContext, | 78 void GrSoftwarePathRenderer::DrawAroundInvPath(GrDrawContext* drawContext, |
83 const GrPaint& paint, | 79 const GrPaint& paint, |
84 const GrUserStencilSettings& user
StencilSettings, | 80 const GrUserStencilSettings& user
StencilSettings, |
85 const GrClip& clip, | 81 const GrClip& clip, |
86 const SkMatrix& viewMatrix, | 82 const SkMatrix& viewMatrix, |
87 const SkIRect& devClipBounds, | 83 const SkIRect& devClipBounds, |
88 const SkIRect& devPathBounds) { | 84 const SkIRect& devPathBounds) { |
89 SkMatrix invert; | 85 SkMatrix invert; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 inverseFilled = args.fShape->inverseFilled(); | 130 inverseFilled = args.fShape->inverseFilled(); |
135 | 131 |
136 SkIRect devShapeBounds, devClipBounds; | 132 SkIRect devShapeBounds, devClipBounds; |
137 if (!get_shape_and_clip_bounds(args.fDrawContext->width(), args.fDrawContext
->height(), | 133 if (!get_shape_and_clip_bounds(args.fDrawContext->width(), args.fDrawContext
->height(), |
138 *args.fClip, *args.fShape, | 134 *args.fClip, *args.fShape, |
139 *args.fViewMatrix, &devShapeBounds, &devClipB
ounds)) { | 135 *args.fViewMatrix, &devShapeBounds, &devClipB
ounds)) { |
140 if (inverseFilled) { | 136 if (inverseFilled) { |
141 DrawAroundInvPath(args.fDrawContext, *args.fPaint, *args.fUserStenci
lSettings, | 137 DrawAroundInvPath(args.fDrawContext, *args.fPaint, *args.fUserStenci
lSettings, |
142 *args.fClip, | 138 *args.fClip, |
143 *args.fViewMatrix, devClipBounds, devShapeBounds); | 139 *args.fViewMatrix, devClipBounds, devShapeBounds); |
144 | |
145 } | 140 } |
146 return true; | 141 return true; |
147 } | 142 } |
148 | 143 |
149 SkAutoTUnref<GrTexture> texture( | 144 SkAutoTUnref<GrTexture> texture( |
150 GrSWMaskHelper::DrawShapeMaskToTexture(fTexProvider, *args.fShape, d
evShapeBounds, | 145 GrSWMaskHelper::DrawShapeMaskToTexture(fTexProvider, *args.fShape, d
evShapeBounds, |
151 args.fAntiAlias, args.fViewMa
trix)); | 146 args.fAntiAlias, args.fViewMa
trix)); |
152 if (!texture) { | 147 if (!texture) { |
153 return false; | 148 return false; |
154 } | 149 } |
155 | 150 |
156 GrSWMaskHelper::DrawToTargetWithShapeMask(texture, args.fDrawContext, *args.
fPaint, | 151 GrSWMaskHelper::DrawToTargetWithShapeMask(texture, args.fDrawContext, *args.
fPaint, |
157 *args.fUserStencilSettings, | 152 *args.fUserStencilSettings, |
158 *args.fClip, *args.fViewMatrix, | 153 *args.fClip, *args.fViewMatrix, |
159 devShapeBounds); | 154 devShapeBounds); |
160 | 155 |
161 if (inverseFilled) { | 156 if (inverseFilled) { |
162 DrawAroundInvPath(args.fDrawContext, *args.fPaint, *args.fUserStencilSet
tings, | 157 DrawAroundInvPath(args.fDrawContext, *args.fPaint, *args.fUserStencilSet
tings, |
163 *args.fClip, | 158 *args.fClip, |
164 *args.fViewMatrix, devClipBounds, devShapeBounds); | 159 *args.fViewMatrix, devClipBounds, devShapeBounds); |
165 } | 160 } |
166 | 161 |
167 return true; | 162 return true; |
168 } | 163 } |
OLD | NEW |