| 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 | 8 |
| 9 #include "GrStencilAndCoverPathRenderer.h" | 9 #include "GrStencilAndCoverPathRenderer.h" |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } else { | 26 } else { |
| 27 return nullptr; | 27 return nullptr; |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider*
resourceProvider) | 31 GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrResourceProvider*
resourceProvider) |
| 32 : fResourceProvider(resourceProvider) { | 32 : fResourceProvider(resourceProvider) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
onst { | 35 bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
onst { |
| 36 // GrPath doesn't support hairline paths. Also, an arbitrary path effect cou
ld change | 36 // GrPath doesn't support hairline paths. |
| 37 // the style type to hairline. | 37 if (args.fShape->style().couldBeHairline()) { |
| 38 if (args.fStyle->hasNonDashPathEffect() || args.fStyle->strokeRec().isHairli
neStyle()) { | |
| 39 return false; | 38 return false; |
| 40 } | 39 } |
| 41 if (args.fHasUserStencilSettings) { | 40 if (args.fHasUserStencilSettings) { |
| 42 return false; | 41 return false; |
| 43 } | 42 } |
| 44 if (args.fAntiAlias) { | 43 if (args.fAntiAlias) { |
| 45 return args.fIsStencilBufferMSAA; | 44 return args.fIsStencilBufferMSAA; |
| 46 } else { | 45 } else { |
| 47 return true; // doesn't do per-path AA, relies on the target having MSAA | 46 return true; // doesn't do per-path AA, relies on the target having MSAA |
| 48 } | 47 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 } else { | 62 } else { |
| 64 SkASSERT(path->isEqualTo(skPath, style)); | 63 SkASSERT(path->isEqualTo(skPath, style)); |
| 65 } | 64 } |
| 66 return path.release(); | 65 return path.release(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { | 68 void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) { |
| 70 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 69 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 71 "GrStencilAndCoverPathRenderer::onStencilPath"); | 70 "GrStencilAndCoverPathRenderer::onStencilPath"); |
| 72 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled()); | 71 SkASSERT(!args.fIsAA || args.fDrawContext->isStencilBufferMultisampled()); |
| 72 SkPath path; |
| 73 args.fShape->asPath(&path); |
| 73 | 74 |
| 74 GrPaint paint; | 75 GrPaint paint; |
| 75 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 76 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
| 76 paint.setAntiAlias(args.fIsAA); | 77 paint.setAntiAlias(args.fIsAA); |
| 77 | 78 |
| 78 const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA); | 79 const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA); |
| 79 | 80 |
| 80 SkASSERT(!args.fPath->isInverseFillType()); | 81 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, GrStyle::SimpleF
ill())); |
| 81 SkAutoTUnref<GrPath> path(get_gr_path(fResourceProvider, *args.fPath, GrStyl
e::SimpleFill())); | 82 args.fDrawContext->drawContextPriv().stencilPath(pipelineBuilder, *args.fCli
p, |
| 82 args.fDrawContext->drawContextPriv().stencilPath(pipelineBuilder, | 83 *args.fViewMatrix, p, p->ge
tFillType()); |
| 83 *args.fClip, | |
| 84 *args.fViewMatrix, | |
| 85 path, | |
| 86 path->getFillType()); | |
| 87 } | 84 } |
| 88 | 85 |
| 89 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { | 86 bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 90 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 87 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 91 "GrStencilAndCoverPathRenderer::onDrawPath"); | 88 "GrStencilAndCoverPathRenderer::onDrawPath"); |
| 92 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu
ltisampled()); | 89 SkASSERT(!args.fPaint->isAntiAlias() || args.fDrawContext->isStencilBufferMu
ltisampled()); |
| 93 SkASSERT(!args.fStyle->strokeRec().isHairlineStyle()); | 90 SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle()); |
| 94 const SkPath& path = *args.fPath; | 91 |
| 95 const SkMatrix& viewMatrix = *args.fViewMatrix; | 92 const SkMatrix& viewMatrix = *args.fViewMatrix; |
| 96 | 93 |
| 97 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, *args.fStyle)); | 94 SkPath path; |
| 95 args.fShape->asPath(&path); |
| 96 |
| 97 SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, args.fShape->sty
le())); |
| 98 | 98 |
| 99 if (path.isInverseFillType()) { | 99 if (path.isInverseFillType()) { |
| 100 static constexpr GrUserStencilSettings kInvertedCoverPass( | 100 static constexpr GrUserStencilSettings kInvertedCoverPass( |
| 101 GrUserStencilSettings::StaticInit< | 101 GrUserStencilSettings::StaticInit< |
| 102 0x0000, | 102 0x0000, |
| 103 // We know our rect will hit pixels outside the clip and the use
r bits will be 0 | 103 // We know our rect will hit pixels outside the clip and the use
r bits will be 0 |
| 104 // outside the clip. So we can't just fill where the user bits a
re 0. We also need | 104 // outside the clip. So we can't just fill where the user bits a
re 0. We also need |
| 105 // to check that the clip bit is set. | 105 // to check that the clip bit is set. |
| 106 GrUserStencilTest::kEqualIfInClip, | 106 GrUserStencilTest::kEqualIfInClip, |
| 107 0xffff, | 107 0xffff, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (args.fAntiAlias) { | 170 if (args.fAntiAlias) { |
| 171 SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); | 171 SkASSERT(args.fDrawContext->isStencilBufferMultisampled()); |
| 172 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); | 172 pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag); |
| 173 } | 173 } |
| 174 | 174 |
| 175 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); | 175 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); |
| 176 } | 176 } |
| 177 | 177 |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| OLD | NEW |