Make GrDashEffect take a AA mode enum.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2042923003

Review-Url: https://codereview.chromium.org/2042923003
This commit is contained in:
bsalomon 2016-06-07 08:10:46 -07:00 committed by Commit bot
parent 1f508fd0fe
commit af18fb49fb
3 changed files with 64 additions and 62 deletions

View File

@ -23,13 +23,22 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
"GrDashLinePathRenderer::onDrawPath"); "GrDashLinePathRenderer::onDrawPath");
bool msaaIsEnabled = args.fDrawContext->isUnifiedMultisampled(); bool msaaIsEnabled = args.fDrawContext->isUnifiedMultisampled();
GrDashingEffect::AAMode aaMode;
if (msaaIsEnabled) {
// We ignore args.fAntiAlias here and force anti aliasing when using MSAA. Otherwise,
// we can wind up with external edges antialiased and internal edges unantialiased.
aaMode = GrDashingEffect::AAMode::kCoverageWithMSAA;
} else if (args.fAntiAlias) {
aaMode = GrDashingEffect::AAMode::kCoverage;
} else {
aaMode = GrDashingEffect::AAMode::kNone;
}
SkPoint pts[2]; SkPoint pts[2];
SkAssertResult(args.fPath->isLine(pts)); SkAssertResult(args.fPath->isLine(pts));
SkAutoTUnref<GrDrawBatch> batch(GrDashingEffect::CreateDashLineBatch(args.fColor, SkAutoTUnref<GrDrawBatch> batch(GrDashingEffect::CreateDashLineBatch(args.fColor,
*args.fViewMatrix, *args.fViewMatrix,
pts, pts,
args.fAntiAlias, aaMode,
msaaIsEnabled,
*args.fStyle)); *args.fStyle));
if (!batch) { if (!batch) {
return false; return false;

View File

@ -26,6 +26,8 @@
#include "glsl/GrGLSLVarying.h" #include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h" #include "glsl/GrGLSLVertexShaderBuilder.h"
using AAMode = GrDashingEffect::AAMode;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Returns whether or not the gpu can fast path the dash line effect. // Returns whether or not the gpu can fast path the dash line effect.
@ -74,14 +76,6 @@ struct DashCircleVertex {
SkScalar fRadius; SkScalar fRadius;
SkScalar fCenterX; SkScalar fCenterX;
}; };
enum DashAAMode {
kBW_DashAAMode,
kEdgeAA_DashAAMode,
kMSAA_DashAAMode,
kDashAAModeCount,
};
}; };
static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale, static void calc_dash_scaling(SkScalar* parallelScale, SkScalar* perpScale,
@ -239,7 +233,7 @@ static void setup_dashed_rect_pos(const SkRect& rect, int idx, const SkMatrix& m
* position relative to the dashed line. * position relative to the dashed line.
*/ */
static GrGeometryProcessor* create_dash_gp(GrColor, static GrGeometryProcessor* create_dash_gp(GrColor,
DashAAMode aaMode, AAMode aaMode,
DashCap cap, DashCap cap,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
@ -247,7 +241,6 @@ static GrGeometryProcessor* create_dash_gp(GrColor,
class DashBatch : public GrVertexBatch { class DashBatch : public GrVertexBatch {
public: public:
DEFINE_BATCH_CLASS_ID DEFINE_BATCH_CLASS_ID
struct Geometry { struct Geometry {
SkMatrix fViewMatrix; SkMatrix fViewMatrix;
SkMatrix fSrcRotInv; SkMatrix fSrcRotInv;
@ -260,7 +253,7 @@ public:
GrColor fColor; GrColor fColor;
}; };
static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, AAMode aaMode,
bool fullDash) { bool fullDash) {
return new DashBatch(geometry, cap, aaMode, fullDash); return new DashBatch(geometry, cap, aaMode, fullDash);
} }
@ -278,7 +271,7 @@ public:
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
private: private:
DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, bool fullDash) DashBatch(const Geometry& geometry, SkPaint::Cap cap, AAMode aaMode, bool fullDash)
: INHERITED(ClassID()) { : INHERITED(ClassID()) {
fGeoData.push_back(geometry); fGeoData.push_back(geometry);
@ -359,7 +352,7 @@ private:
} }
// useAA here means Edge AA or MSAA // useAA here means Edge AA or MSAA
bool useAA = this->aaMode() != kBW_DashAAMode; bool useAA = this->aaMode() != AAMode::kNone;
bool fullDash = this->fullDash(); bool fullDash = this->fullDash();
// We do two passes over all of the dashes. First we setup the start, end, and bounds, // We do two passes over all of the dashes. First we setup the start, end, and bounds,
@ -486,9 +479,13 @@ private:
// For EdgeAA, we bloat in X & Y for both square and round caps. // For EdgeAA, we bloat in X & Y for both square and round caps.
// For MSAA, we don't bloat at all for square caps, and bloat in Y only for round caps. // For MSAA, we don't bloat at all for square caps, and bloat in Y only for round caps.
SkScalar devBloatX = this->aaMode() == kEdgeAA_DashAAMode ? 0.5f : 0.0f; SkScalar devBloatX = this->aaMode() == AAMode::kCoverage ? 0.5f : 0.0f;
SkScalar devBloatY = (SkPaint::kRound_Cap == cap && this->aaMode() == kMSAA_DashAAMode) SkScalar devBloatY;
? 0.5f : devBloatX; if (SkPaint::kRound_Cap == cap && this->aaMode() == AAMode::kCoverageWithMSAA) {
devBloatY = 0.5f;
} else {
devBloatY = devBloatX;
}
SkScalar bloatX = devBloatX / args.fParallelScale; SkScalar bloatX = devBloatX / args.fParallelScale;
SkScalar bloatY = devBloatY / args.fPerpendicularScale; SkScalar bloatY = devBloatY / args.fPerpendicularScale;
@ -665,7 +662,7 @@ private:
GrColor color() const { return fBatch.fColor; } GrColor color() const { return fBatch.fColor; }
bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; } bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; } const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
DashAAMode aaMode() const { return fBatch.fAAMode; } AAMode aaMode() const { return fBatch.fAAMode; }
bool fullDash() const { return fBatch.fFullDash; } bool fullDash() const { return fBatch.fFullDash; }
SkPaint::Cap cap() const { return fBatch.fCap; } SkPaint::Cap cap() const { return fBatch.fCap; }
bool coverageIgnored() const { return fBatch.fCoverageIgnored; } bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
@ -676,7 +673,7 @@ private:
bool fColorIgnored; bool fColorIgnored;
bool fCoverageIgnored; bool fCoverageIgnored;
SkPaint::Cap fCap; SkPaint::Cap fCap;
DashAAMode fAAMode; AAMode fAAMode;
bool fFullDash; bool fFullDash;
}; };
@ -689,8 +686,11 @@ private:
typedef GrVertexBatch INHERITED; typedef GrVertexBatch INHERITED;
}; };
static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2], GrDrawBatch* GrDashingEffect::CreateDashLineBatch(GrColor color,
bool useAA, const GrStyle& style, bool msaaRT) { const SkMatrix& viewMatrix,
const SkPoint pts[2],
AAMode aaMode,
const GrStyle& style) {
SkASSERT(GrDashingEffect::CanDrawDashLine(pts, style, viewMatrix)); SkASSERT(GrDashingEffect::CanDrawDashLine(pts, style, viewMatrix));
const SkScalar* intervals = style.dashIntervals(); const SkScalar* intervals = style.dashIntervals();
SkScalar phase = style.dashPhase(); SkScalar phase = style.dashPhase();
@ -728,11 +728,8 @@ static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons
offInterval -= strokeWidth; offInterval -= strokeWidth;
} }
DashAAMode aaMode = msaaRT ? kMSAA_DashAAMode :
useAA ? kEdgeAA_DashAAMode : kBW_DashAAMode;
// TODO we can do a real rect call if not using fulldash(ie no off interval, not using AA) // TODO we can do a real rect call if not using fulldash(ie no off interval, not using AA)
bool fullDash = offInterval > 0.f || aaMode != kBW_DashAAMode; bool fullDash = offInterval > 0.f || aaMode != AAMode::kNone;
geometry.fColor = color; geometry.fColor = color;
geometry.fViewMatrix = viewMatrix; geometry.fViewMatrix = viewMatrix;
@ -743,15 +740,6 @@ static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, cons
return DashBatch::Create(geometry, cap, aaMode, fullDash); return DashBatch::Create(geometry, cap, aaMode, fullDash);
} }
GrDrawBatch* GrDashingEffect::CreateDashLineBatch(GrColor color,
const SkMatrix& viewMatrix,
const SkPoint pts[2],
bool useAA,
bool msaaIsEnabled,
const GrStyle& style) {
return create_batch(color, viewMatrix, pts, useAA, style, msaaIsEnabled);
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
class GLDashingCircleEffect; class GLDashingCircleEffect;
@ -770,7 +758,7 @@ public:
typedef SkPathEffect::DashInfo DashInfo; typedef SkPathEffect::DashInfo DashInfo;
static GrGeometryProcessor* Create(GrColor, static GrGeometryProcessor* Create(GrColor,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
@ -782,7 +770,7 @@ public:
const Attribute* inCircleParams() const { return fInCircleParams; } const Attribute* inCircleParams() const { return fInCircleParams; }
DashAAMode aaMode() const { return fAAMode; } AAMode aaMode() const { return fAAMode; }
GrColor color() const { return fColor; } GrColor color() const { return fColor; }
@ -797,13 +785,13 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override; GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
private: private:
DashingCircleEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, DashingCircleEffect(GrColor, AAMode aaMode, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
GrColor fColor; GrColor fColor;
SkMatrix fLocalMatrix; SkMatrix fLocalMatrix;
bool fUsesLocalCoords; bool fUsesLocalCoords;
DashAAMode fAAMode; AAMode fAAMode;
const Attribute* fInPosition; const Attribute* fInPosition;
const Attribute* fInDashParams; const Attribute* fInDashParams;
const Attribute* fInCircleParams; const Attribute* fInCircleParams;
@ -896,7 +884,7 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashParams.fsIn()); fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", dashParams.fsIn());
fragBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn()); fragBuilder->codeAppendf("vec2 center = vec2(%s.y, 0.0);", circleParams.fsIn());
fragBuilder->codeAppend("float dist = length(center - fragPosShifted);"); fragBuilder->codeAppend("float dist = length(center - fragPosShifted);");
if (dce.aaMode() != kBW_DashAAMode) { if (dce.aaMode() != AAMode::kNone) {
fragBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn()); fragBuilder->codeAppendf("float diff = dist - %s.x;", circleParams.fsIn());
fragBuilder->codeAppend("diff = 1.0 - diff;"); fragBuilder->codeAppend("diff = 1.0 - diff;");
fragBuilder->codeAppend("float alpha = clamp(diff, 0.0, 1.0);"); fragBuilder->codeAppend("float alpha = clamp(diff, 0.0, 1.0);");
@ -925,14 +913,14 @@ void GLDashingCircleEffect::GenKey(const GrGeometryProcessor& gp,
uint32_t key = 0; uint32_t key = 0;
key |= dce.usesLocalCoords() && dce.localMatrix().hasPerspective() ? 0x1 : 0x0; key |= dce.usesLocalCoords() && dce.localMatrix().hasPerspective() ? 0x1 : 0x0;
key |= dce.colorIgnored() ? 0x2 : 0x0; key |= dce.colorIgnored() ? 0x2 : 0x0;
key |= dce.aaMode() << 8; key |= static_cast<uint32_t>(dce.aaMode()) << 8;
b->add32(key); b->add32(key);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
GrGeometryProcessor* DashingCircleEffect::Create(GrColor color, GrGeometryProcessor* DashingCircleEffect::Create(GrColor color,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords) { bool usesLocalCoords) {
return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords); return new DashingCircleEffect(color, aaMode, localMatrix, usesLocalCoords);
@ -948,7 +936,7 @@ GrGLSLPrimitiveProcessor* DashingCircleEffect::createGLSLInstance(const GrGLSLCa
} }
DashingCircleEffect::DashingCircleEffect(GrColor color, DashingCircleEffect::DashingCircleEffect(GrColor color,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords) bool usesLocalCoords)
: fColor(color) : fColor(color)
@ -965,7 +953,7 @@ DashingCircleEffect::DashingCircleEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
const GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) { const GrGeometryProcessor* DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount)); AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
return DashingCircleEffect::Create(GrRandomColor(d->fRandom), return DashingCircleEffect::Create(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom), aaMode, GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool()); d->fRandom->nextBool());
@ -989,7 +977,7 @@ public:
typedef SkPathEffect::DashInfo DashInfo; typedef SkPathEffect::DashInfo DashInfo;
static GrGeometryProcessor* Create(GrColor, static GrGeometryProcessor* Create(GrColor,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
@ -1001,7 +989,7 @@ public:
const Attribute* inRectParams() const { return fInRectParams; } const Attribute* inRectParams() const { return fInRectParams; }
DashAAMode aaMode() const { return fAAMode; } AAMode aaMode() const { return fAAMode; }
GrColor color() const { return fColor; } GrColor color() const { return fColor; }
@ -1016,13 +1004,13 @@ public:
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override; GrGLSLPrimitiveProcessor* createGLSLInstance(const GrGLSLCaps&) const override;
private: private:
DashingLineEffect(GrColor, DashAAMode aaMode, const SkMatrix& localMatrix, DashingLineEffect(GrColor, AAMode aaMode, const SkMatrix& localMatrix,
bool usesLocalCoords); bool usesLocalCoords);
GrColor fColor; GrColor fColor;
SkMatrix fLocalMatrix; SkMatrix fLocalMatrix;
bool fUsesLocalCoords; bool fUsesLocalCoords;
DashAAMode fAAMode; AAMode fAAMode;
const Attribute* fInPosition; const Attribute* fInPosition;
const Attribute* fInDashParams; const Attribute* fInDashParams;
const Attribute* fInRectParams; const Attribute* fInRectParams;
@ -1108,7 +1096,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(), inDashParams.fsIn(),
inDashParams.fsIn()); inDashParams.fsIn());
fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDashParams.fsIn()); fragBuilder->codeAppendf("vec2 fragPosShifted = vec2(xShifted, %s.y);", inDashParams.fsIn());
if (de.aaMode() == kEdgeAA_DashAAMode) { if (de.aaMode() == AAMode::kCoverage) {
// The amount of coverage removed in x and y by the edges is computed as a pair of negative // The amount of coverage removed in x and y by the edges is computed as a pair of negative
// numbers, xSub and ySub. // numbers, xSub and ySub.
fragBuilder->codeAppend("float xSub, ySub;"); fragBuilder->codeAppend("float xSub, ySub;");
@ -1120,7 +1108,7 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
// covered. // covered.
fragBuilder->codeAppendf( fragBuilder->codeAppendf(
"float alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));"); "float alpha = (1.0 + max(xSub, -1.0)) * (1.0 + max(ySub, -1.0));");
} else if (de.aaMode() == kMSAA_DashAAMode) { } else if (de.aaMode() == AAMode::kCoverageWithMSAA) {
// For MSAA, we don't modulate the alpha by the Y distance, since MSAA coverage will handle // For MSAA, we don't modulate the alpha by the Y distance, since MSAA coverage will handle
// AA on the the top and bottom edges. The shader is only responsible for intra-dash alpha. // AA on the the top and bottom edges. The shader is only responsible for intra-dash alpha.
fragBuilder->codeAppend("float xSub;"); fragBuilder->codeAppend("float xSub;");
@ -1157,14 +1145,14 @@ void GLDashingLineEffect::GenKey(const GrGeometryProcessor& gp,
uint32_t key = 0; uint32_t key = 0;
key |= de.usesLocalCoords() && de.localMatrix().hasPerspective() ? 0x1 : 0x0; key |= de.usesLocalCoords() && de.localMatrix().hasPerspective() ? 0x1 : 0x0;
key |= de.colorIgnored() ? 0x2 : 0x0; key |= de.colorIgnored() ? 0x2 : 0x0;
key |= de.aaMode() << 8; key |= static_cast<int>(de.aaMode()) << 8;
b->add32(key); b->add32(key);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
GrGeometryProcessor* DashingLineEffect::Create(GrColor color, GrGeometryProcessor* DashingLineEffect::Create(GrColor color,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords) { bool usesLocalCoords) {
return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords); return new DashingLineEffect(color, aaMode, localMatrix, usesLocalCoords);
@ -1180,7 +1168,7 @@ GrGLSLPrimitiveProcessor* DashingLineEffect::createGLSLInstance(const GrGLSLCaps
} }
DashingLineEffect::DashingLineEffect(GrColor color, DashingLineEffect::DashingLineEffect(GrColor color,
DashAAMode aaMode, AAMode aaMode,
const SkMatrix& localMatrix, const SkMatrix& localMatrix,
bool usesLocalCoords) bool usesLocalCoords)
: fColor(color) : fColor(color)
@ -1196,7 +1184,7 @@ DashingLineEffect::DashingLineEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) { const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d) {
DashAAMode aaMode = static_cast<DashAAMode>(d->fRandom->nextULessThan(kDashAAModeCount)); AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
return DashingLineEffect::Create(GrRandomColor(d->fRandom), return DashingLineEffect::Create(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom), aaMode, GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool()); d->fRandom->nextBool());
@ -1205,7 +1193,7 @@ const GrGeometryProcessor* DashingLineEffect::TestCreate(GrProcessorTestData* d)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static GrGeometryProcessor* create_dash_gp(GrColor color, static GrGeometryProcessor* create_dash_gp(GrColor color,
DashAAMode dashAAMode, AAMode aaMode,
DashCap cap, DashCap cap,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
bool usesLocalCoords) { bool usesLocalCoords) {
@ -1217,9 +1205,9 @@ static GrGeometryProcessor* create_dash_gp(GrColor color,
switch (cap) { switch (cap) {
case kRound_DashCap: case kRound_DashCap:
return DashingCircleEffect::Create(color, dashAAMode, invert, usesLocalCoords); return DashingCircleEffect::Create(color, aaMode, invert, usesLocalCoords);
case kNonRound_DashCap: case kNonRound_DashCap:
return DashingLineEffect::Create(color, dashAAMode, invert, usesLocalCoords); return DashingLineEffect::Create(color, aaMode, invert, usesLocalCoords);
} }
return nullptr; return nullptr;
} }
@ -1231,8 +1219,7 @@ static GrGeometryProcessor* create_dash_gp(GrColor color,
DRAW_BATCH_TEST_DEFINE(DashBatch) { DRAW_BATCH_TEST_DEFINE(DashBatch) {
GrColor color = GrRandomColor(random); GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random); SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
bool useAA = random->nextBool(); AAMode aaMode = static_cast<AAMode>(random->nextULessThan(GrDashingEffect::kAAModeCnt));
bool msaaRT = random->nextBool();
// We can only dash either horizontal or vertical lines // We can only dash either horizontal or vertical lines
SkPoint pts[2]; SkPoint pts[2];
@ -1294,7 +1281,7 @@ DRAW_BATCH_TEST_DEFINE(DashBatch) {
GrStyle style(p); GrStyle style(p);
return create_batch(color, viewMatrix, pts, useAA, style, msaaRT); return GrDashingEffect::CreateDashLineBatch(color, viewMatrix, pts, aaMode, style);
} }
#endif #endif

View File

@ -17,11 +17,17 @@ class GrDrawBatch;
class GrStyle; class GrStyle;
namespace GrDashingEffect { namespace GrDashingEffect {
enum class AAMode {
kNone,
kCoverage,
kCoverageWithMSAA,
};
static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1;
GrDrawBatch* CreateDashLineBatch(GrColor, GrDrawBatch* CreateDashLineBatch(GrColor,
const SkMatrix& viewMatrix, const SkMatrix& viewMatrix,
const SkPoint pts[2], const SkPoint pts[2],
bool useAA, AAMode,
bool msaaIsEnabled,
const GrStyle& style); const GrStyle& style);
bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
const SkMatrix& viewMatrix); const SkMatrix& viewMatrix);