blob: 38d486c79f75ddd964e9c4274b01ea6638ae82d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrDashLinePathRenderer.h"
#include "GrAuditTrail.h"
#include "GrGpu.h"
#include "ops/GrDashOp.h"
#include "ops/GrMeshDrawOp.h"
bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
SkPoint pts[2];
bool inverted;
if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted)) {
if (args.fAAType == GrAAType::kMixedSamples) {
return false;
}
// We should never have an inverse dashed case.
SkASSERT(!inverted);
return GrDashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix);
}
return false;
}
bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrDashLinePathRenderer::onDrawPath");
GrDashOp::AAMode aaMode = GrDashOp::AAMode::kNone;
switch (args.fAAType) {
case GrAAType::kNone:
break;
case GrAAType::kCoverage:
case GrAAType::kMixedSamples:
aaMode = GrDashOp::AAMode::kCoverage;
break;
case GrAAType::kMSAA:
// In this mode we will use aa between dashes but the outer border uses MSAA. Otherwise,
// we can wind up with external edges antialiased and internal edges unantialiased.
aaMode = GrDashOp::AAMode::kCoverageWithMSAA;
break;
}
SkPoint pts[2];
SkAssertResult(args.fShape->asLine(pts, nullptr));
std::unique_ptr<GrDrawOp> op =
GrDashOp::MakeDashLineOp(std::move(args.fPaint), *args.fViewMatrix, pts, aaMode,
args.fShape->style(), args.fUserStencilSettings);
if (!op) {
return false;
}
args.fRenderTargetContext->addDrawOp(*args.fClip, std::move(op));
return true;
}
|