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