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