| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrDashLinePathRenderer.h" | 8 #include "GrDashLinePathRenderer.h" |
| 9 | 9 |
| 10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
| 11 #include "GrAuditTrail.h" | 11 #include "GrAuditTrail.h" |
| 12 #include "effects/GrDashingEffect.h" | 12 #include "effects/GrDashingEffect.h" |
| 13 | 13 |
| 14 bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 14 bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
| 15 SkPoint pts[2]; | 15 SkPoint pts[2]; |
| 16 bool inverted; | 16 if (args.fShape->style().isDashed() && args.fShape->asLine(pts)) { |
| 17 if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted))
{ | |
| 18 // We should never have an inverse dashed case. | |
| 19 SkASSERT(!inverted); | |
| 20 return GrDashingEffect::CanDrawDashLine(pts, args.fShape->style(), *args
.fViewMatrix); | 17 return GrDashingEffect::CanDrawDashLine(pts, args.fShape->style(), *args
.fViewMatrix); |
| 21 } | 18 } |
| 22 return false; | 19 return false; |
| 23 } | 20 } |
| 24 | 21 |
| 25 bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { | 22 bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 26 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), | 23 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), |
| 27 "GrDashLinePathRenderer::onDrawPath"); | 24 "GrDashLinePathRenderer::onDrawPath"); |
| 28 bool useHWAA = args.fDrawContext->isUnifiedMultisampled(); | 25 bool useHWAA = args.fDrawContext->isUnifiedMultisampled(); |
| 29 GrDashingEffect::AAMode aaMode; | 26 GrDashingEffect::AAMode aaMode; |
| 30 if (useHWAA) { | 27 if (useHWAA) { |
| 31 // We ignore args.fAntiAlias here and force anti aliasing when using MSA
A. Otherwise, | 28 // We ignore args.fAntiAlias here and force anti aliasing when using MSA
A. Otherwise, |
| 32 // we can wind up with external edges antialiased and internal edges una
ntialiased. | 29 // we can wind up with external edges antialiased and internal edges una
ntialiased. |
| 33 aaMode = GrDashingEffect::AAMode::kCoverageWithMSAA; | 30 aaMode = GrDashingEffect::AAMode::kCoverageWithMSAA; |
| 34 } else if (args.fAntiAlias) { | 31 } else if (args.fAntiAlias) { |
| 35 aaMode = GrDashingEffect::AAMode::kCoverage; | 32 aaMode = GrDashingEffect::AAMode::kCoverage; |
| 36 } else { | 33 } else { |
| 37 aaMode = GrDashingEffect::AAMode::kNone; | 34 aaMode = GrDashingEffect::AAMode::kNone; |
| 38 } | 35 } |
| 39 SkPoint pts[2]; | 36 SkPoint pts[2]; |
| 40 SkAssertResult(args.fShape->asLine(pts, nullptr)); | 37 SkAssertResult(args.fShape->asLine(pts)); |
| 41 SkAutoTUnref<GrDrawBatch> batch(GrDashingEffect::CreateDashLineBatch(args.fC
olor, | 38 SkAutoTUnref<GrDrawBatch> batch(GrDashingEffect::CreateDashLineBatch(args.fC
olor, |
| 42 *args.f
ViewMatrix, | 39 *args.f
ViewMatrix, |
| 43 pts, | 40 pts, |
| 44 aaMode, | 41 aaMode, |
| 45 args.fS
hape->style())); | 42 args.fS
hape->style())); |
| 46 if (!batch) { | 43 if (!batch) { |
| 47 return false; | 44 return false; |
| 48 } | 45 } |
| 49 | 46 |
| 50 GrPipelineBuilder pipelineBuilder(*args.fPaint, useHWAA); | 47 GrPipelineBuilder pipelineBuilder(*args.fPaint, useHWAA); |
| 51 pipelineBuilder.setUserStencil(args.fUserStencilSettings); | 48 pipelineBuilder.setUserStencil(args.fUserStencilSettings); |
| 52 | 49 |
| 53 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); | 50 args.fDrawContext->drawBatch(pipelineBuilder, *args.fClip, batch); |
| 54 return true; | 51 return true; |
| 55 } | 52 } |
| OLD | NEW |