aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/gpu.gni4
-rw-r--r--src/gpu/GrBatchTest.cpp11
-rw-r--r--src/gpu/SkGpuDevice.cpp2
-rw-r--r--src/gpu/batches/GrDashLinePathRenderer.cpp14
-rw-r--r--src/gpu/batches/GrDashOp.cpp (renamed from src/gpu/effects/GrDashingEffect.cpp)151
-rw-r--r--src/gpu/batches/GrDashOp.h31
-rw-r--r--src/gpu/batches/GrPLSPathRenderer.cpp29
-rw-r--r--src/gpu/batches/GrTessellatingPathRenderer.cpp53
-rw-r--r--src/gpu/effects/GrDashingEffect.h36
9 files changed, 155 insertions, 176 deletions
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 23ee07eac6..3dc7c21c28 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -249,6 +249,8 @@ skia_gpu_sources = [
"$_src/gpu/batches/GrCopySurfaceOp.h",
"$_src/gpu/batches/GrDashLinePathRenderer.cpp",
"$_src/gpu/batches/GrDashLinePathRenderer.h",
+ "$_src/gpu/batches/GrDashOp.cpp",
+ "$_src/gpu/batches/GrDashOp.h",
"$_src/gpu/batches/GrDefaultPathRenderer.cpp",
"$_src/gpu/batches/GrDefaultPathRenderer.h",
"$_src/gpu/batches/GrDiscardOp.h",
@@ -305,8 +307,6 @@ skia_gpu_sources = [
"$_src/gpu/effects/GrBicubicEffect.h",
"$_src/gpu/effects/GrBitmapTextGeoProc.cpp",
"$_src/gpu/effects/GrBitmapTextGeoProc.h",
- "$_src/gpu/effects/GrDashingEffect.cpp",
- "$_src/gpu/effects/GrDashingEffect.h",
"$_src/gpu/effects/GrDisableColorXP.cpp",
"$_src/gpu/effects/GrDisableColorXP.h",
"$_src/gpu/effects/GrDistanceFieldGeoProc.cpp",
diff --git a/src/gpu/GrBatchTest.cpp b/src/gpu/GrBatchTest.cpp
index 53306f7be4..562c56990d 100644
--- a/src/gpu/GrBatchTest.cpp
+++ b/src/gpu/GrBatchTest.cpp
@@ -19,15 +19,16 @@ DRAW_BATCH_TEST_EXTERN(AAFlatteningConvexPathOp)
DRAW_BATCH_TEST_EXTERN(AAHairlineOp);
DRAW_BATCH_TEST_EXTERN(AAStrokeRectOp);
DRAW_BATCH_TEST_EXTERN(AnalyticRectOp);
-DRAW_BATCH_TEST_EXTERN(DashBatch);
+DRAW_BATCH_TEST_EXTERN(DashOp);
DRAW_BATCH_TEST_EXTERN(DefaultPathOp);
DRAW_BATCH_TEST_EXTERN(CircleOp);
DRAW_BATCH_TEST_EXTERN(DIEllipseOp);
DRAW_BATCH_TEST_EXTERN(EllipseOp);
DRAW_BATCH_TEST_EXTERN(GrDrawAtlasOp);
DRAW_BATCH_TEST_EXTERN(NonAAStrokeRectOp);
+DRAW_BATCH_TEST_EXTERN(PLSPathOp);
DRAW_BATCH_TEST_EXTERN(RRectOp);
-DRAW_BATCH_TEST_EXTERN(TesselatingPathBatch);
+DRAW_BATCH_TEST_EXTERN(TesselatingPathOp);
DRAW_BATCH_TEST_EXTERN(TextBlobBatch);
DRAW_BATCH_TEST_EXTERN(VerticesOp);
@@ -40,15 +41,17 @@ static BatchTestFunc gTestBatches[] = {
DRAW_BATCH_TEST_ENTRY(AAHairlineOp),
DRAW_BATCH_TEST_ENTRY(AAStrokeRectOp),
DRAW_BATCH_TEST_ENTRY(AnalyticRectOp),
- DRAW_BATCH_TEST_ENTRY(DashBatch),
+ DRAW_BATCH_TEST_ENTRY(DashOp),
DRAW_BATCH_TEST_ENTRY(DefaultPathOp),
DRAW_BATCH_TEST_ENTRY(CircleOp),
DRAW_BATCH_TEST_ENTRY(DIEllipseOp),
DRAW_BATCH_TEST_ENTRY(EllipseOp),
DRAW_BATCH_TEST_ENTRY(GrDrawAtlasOp),
DRAW_BATCH_TEST_ENTRY(NonAAStrokeRectOp),
+ // This currently hits an assert when the GrDisableColorXPFactory is randomly selected.
+ // DRAW_BATCH_TEST_ENTRY(PLSPathOp),
DRAW_BATCH_TEST_ENTRY(RRectOp),
- DRAW_BATCH_TEST_ENTRY(TesselatingPathBatch),
+ DRAW_BATCH_TEST_ENTRY(TesselatingPathOp),
DRAW_BATCH_TEST_ENTRY(TextBlobBatch),
DRAW_BATCH_TEST_ENTRY(VerticesOp)
};
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index a623dd1fdb..8adc76e2eb 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -42,9 +42,7 @@
#include "SkTLazy.h"
#include "SkUtils.h"
#include "SkVertState.h"
-#include "batches/GrRectOpFactory.h"
#include "effects/GrBicubicEffect.h"
-#include "effects/GrDashingEffect.h"
#include "effects/GrSimpleTextureEffect.h"
#include "effects/GrTextureDomain.h"
#include "text/GrTextUtils.h"
diff --git a/src/gpu/batches/GrDashLinePathRenderer.cpp b/src/gpu/batches/GrDashLinePathRenderer.cpp
index 1bda9d5dfe..94bf26c7a3 100644
--- a/src/gpu/batches/GrDashLinePathRenderer.cpp
+++ b/src/gpu/batches/GrDashLinePathRenderer.cpp
@@ -10,7 +10,7 @@
#include "GrAuditTrail.h"
#include "GrGpu.h"
#include "GrPipelineBuilder.h"
-#include "effects/GrDashingEffect.h"
+#include "batches/GrDashOp.h"
bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
SkPoint pts[2];
@@ -21,7 +21,7 @@ bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
}
// We should never have an inverse dashed case.
SkASSERT(!inverted);
- return GrDashingEffect::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix);
+ return GrDashOp::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix);
}
return false;
}
@@ -29,24 +29,24 @@ bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
"GrDashLinePathRenderer::onDrawPath");
- GrDashingEffect::AAMode aaMode = GrDashingEffect::AAMode::kNone;
+ GrDashOp::AAMode aaMode = GrDashOp::AAMode::kNone;
switch (args.fAAType) {
case GrAAType::kNone:
break;
case GrAAType::kCoverage:
case GrAAType::kMixedSamples:
- aaMode = GrDashingEffect::AAMode::kCoverage;
+ 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 = GrDashingEffect::AAMode::kCoverageWithMSAA;
+ aaMode = GrDashOp::AAMode::kCoverageWithMSAA;
break;
}
SkPoint pts[2];
SkAssertResult(args.fShape->asLine(pts, nullptr));
- sk_sp<GrDrawOp> op(GrDashingEffect::CreateDashLineBatch(
- args.fPaint->getColor(), *args.fViewMatrix, pts, aaMode, args.fShape->style()));
+ sk_sp<GrDrawOp> op = GrDashOp::MakeDashLineOp(
+ args.fPaint->getColor(), *args.fViewMatrix, pts, aaMode, args.fShape->style());
if (!op) {
return false;
}
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/batches/GrDashOp.cpp
index 4f85bf48d3..266cf4a880 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/batches/GrDashOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrDashingEffect.h"
+#include "GrDashOp.h"
#include "GrBatchTest.h"
#include "GrCaps.h"
@@ -26,13 +26,13 @@
#include "glsl/GrGLSLVarying.h"
#include "glsl/GrGLSLVertexShaderBuilder.h"
-using AAMode = GrDashingEffect::AAMode;
+using AAMode = GrDashOp::AAMode;
///////////////////////////////////////////////////////////////////////////////
// Returns whether or not the gpu can fast path the dash line effect.
-bool GrDashingEffect::CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
- const SkMatrix& viewMatrix) {
+bool GrDashOp::CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
+ const SkMatrix& viewMatrix) {
// Pts must be either horizontal or vertical in src space
if (pts[0].fX != pts[1].fX && pts[0].fY != pts[1].fY) {
return false;
@@ -238,10 +238,10 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor,
const SkMatrix& localMatrix,
bool usesLocalCoords);
-class DashBatch final : public GrMeshDrawOp {
+class DashOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- struct Geometry {
+ struct LineData {
SkMatrix fViewMatrix;
SkMatrix fSrcRotInv;
SkPoint fPtsRot[2];
@@ -250,19 +250,18 @@ public:
SkScalar fIntervals[2];
SkScalar fParallelScale;
SkScalar fPerpendicularScale;
- GrColor fColor;
};
- static GrDrawOp* Create(const Geometry& geometry, SkPaint::Cap cap, AAMode aaMode,
- bool fullDash) {
- return new DashBatch(geometry, cap, aaMode, fullDash);
+ static sk_sp<GrDrawOp> Make(const LineData& geometry, GrColor color, SkPaint::Cap cap,
+ AAMode aaMode, bool fullDash) {
+ return sk_sp<GrDrawOp>(new DashOp(geometry, color, cap, aaMode, fullDash));
}
- const char* name() const override { return "DashBatch"; }
+ const char* name() const override { return "DashOp"; }
SkString dumpInfo() const override {
SkString string;
- for (const auto& geo : fGeoData) {
+ for (const auto& geo : fLines) {
string.appendf("Pt0: [%.2f, %.2f], Pt1: [%.2f, %.2f], Width: %.2f, Ival0: %.2f, "
"Ival1 : %.2f, Phase: %.2f\n",
geo.fPtsRot[0].fX, geo.fPtsRot[0].fY,
@@ -280,21 +279,14 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one geometry bundle
- color->setKnownFourComponents(fGeoData[0].fColor);
+ color->setKnownFourComponents(fColor);
coverage->setUnknownSingleComponent();
}
- SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
-
private:
- DashBatch(const Geometry& geometry, SkPaint::Cap cap, AAMode aaMode, bool fullDash)
- : INHERITED(ClassID()) {
- fGeoData.push_back(geometry);
-
- fBatch.fAAMode = aaMode;
- fBatch.fCap = cap;
- fBatch.fFullDash = fullDash;
+ DashOp(const LineData& geometry, GrColor color, SkPaint::Cap cap, AAMode aaMode, bool fullDash)
+ : INHERITED(ClassID()), fColor(color), fCap(cap), fAAMode(aaMode), fFullDash(fullDash) {
+ fLines.push_back(geometry);
// compute bounds
SkScalar halfStrokeWidth = 0.5f * geometry.fSrcStrokeWidth;
@@ -304,7 +296,7 @@ private:
bounds.outset(xBloat, halfStrokeWidth);
// Note, we actually create the combined matrix here, and save the work
- SkMatrix& combinedMatrix = fGeoData[0].fSrcRotInv;
+ SkMatrix& combinedMatrix = fLines[0].fSrcRotInv;
combinedMatrix.postConcat(geometry.fViewMatrix);
IsZeroArea zeroArea = geometry.fSrcStrokeWidth ? IsZeroArea::kNo : IsZeroArea::kYes;
@@ -315,19 +307,16 @@ private:
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
// Handle any color overrides
if (!overrides.readsColor()) {
- fGeoData[0].fColor = GrColor_ILLEGAL;
+ fColor = GrColor_ILLEGAL;
}
- overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
+ overrides.getOverrideColorIfSet(&fColor);
- // setup batch properties
- fBatch.fColorIgnored = !overrides.readsColor();
- fBatch.fColor = fGeoData[0].fColor;
- fBatch.fUsesLocalCoords = overrides.readsLocalCoords();
- fBatch.fCoverageIgnored = !overrides.readsCoverage();
+ fUsesLocalCoords = overrides.readsLocalCoords();
+ fCoverageIgnored = !overrides.readsCoverage();
}
struct DashDraw {
- DashDraw(const Geometry& geo) {
+ DashDraw(const LineData& geo) {
memcpy(fPtsRot, geo.fPtsRot, sizeof(geo.fPtsRot));
memcpy(fIntervals, geo.fIntervals, sizeof(geo.fIntervals));
fPhase = geo.fPhase;
@@ -347,7 +336,7 @@ private:
};
void onPrepareDraws(Target* target) const override {
- int instanceCount = fGeoData.count();
+ int instanceCount = fLines.count();
SkPaint::Cap cap = this->cap();
bool isRoundCap = SkPaint::kRound_Cap == cap;
DashCap capType = isRoundCap ? kRound_DashCap : kNonRound_DashCap;
@@ -387,7 +376,7 @@ private:
int rectOffset = 0;
rects.push_back_n(3 * instanceCount);
for (int i = 0; i < instanceCount; i++) {
- const Geometry& args = fGeoData[i];
+ const LineData& args = fLines[i];
DashDraw& draw = draws.push_back(args);
@@ -589,7 +578,7 @@ private:
int curVIdx = 0;
int rectIndex = 0;
for (int i = 0; i < instanceCount; i++) {
- const Geometry& geom = fGeoData[i];
+ const LineData& geom = fLines[i];
if (!draws[i].fLineDone) {
if (fullDash) {
@@ -647,7 +636,7 @@ private:
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
- DashBatch* that = t->cast<DashBatch>();
+ DashOp* that = t->cast<DashOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
return false;
@@ -675,51 +664,46 @@ private:
return false;
}
- fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
+ fLines.push_back_n(that->fLines.count(), that->fLines.begin());
this->joinBounds(*that);
return true;
}
- GrColor color() const { return fBatch.fColor; }
- bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
- const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
- AAMode aaMode() const { return fBatch.fAAMode; }
- bool fullDash() const { return fBatch.fFullDash; }
- SkPaint::Cap cap() const { return fBatch.fCap; }
- bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
-
- struct BatchTracker {
- GrColor fColor;
- bool fUsesLocalCoords;
- bool fColorIgnored;
- bool fCoverageIgnored;
- SkPaint::Cap fCap;
- AAMode fAAMode;
- bool fFullDash;
- };
+ GrColor color() const { return fColor; }
+ bool usesLocalCoords() const { return fUsesLocalCoords; }
+ const SkMatrix& viewMatrix() const { return fLines[0].fViewMatrix; }
+ AAMode aaMode() const { return fAAMode; }
+ bool fullDash() const { return fFullDash; }
+ SkPaint::Cap cap() const { return fCap; }
+ bool coverageIgnored() const { return fCoverageIgnored; }
static const int kVertsPerDash = 4;
static const int kIndicesPerDash = 6;
- BatchTracker fBatch;
- SkSTArray<1, Geometry, true> fGeoData;
+ GrColor fColor;
+ bool fUsesLocalCoords;
+ bool fCoverageIgnored;
+ SkPaint::Cap fCap;
+ AAMode fAAMode;
+ bool fFullDash;
+ SkSTArray<1, LineData, true> fLines;
typedef GrMeshDrawOp INHERITED;
};
-GrDrawOp* GrDashingEffect::CreateDashLineBatch(GrColor color,
- const SkMatrix& viewMatrix,
- const SkPoint pts[2],
- AAMode aaMode,
- const GrStyle& style) {
- SkASSERT(GrDashingEffect::CanDrawDashLine(pts, style, viewMatrix));
+sk_sp<GrDrawOp> GrDashOp::MakeDashLineOp(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkPoint pts[2],
+ AAMode aaMode,
+ const GrStyle& style) {
+ SkASSERT(GrDashOp::CanDrawDashLine(pts, style, viewMatrix));
const SkScalar* intervals = style.dashIntervals();
SkScalar phase = style.dashPhase();
SkPaint::Cap cap = style.strokeRec().getCap();
- DashBatch::Geometry geometry;
- geometry.fSrcStrokeWidth = style.strokeRec().getWidth();
+ DashOp::LineData lineData;
+ lineData.fSrcStrokeWidth = style.strokeRec().getWidth();
// the phase should be normalized to be [0, sum of all intervals)
SkASSERT(phase >= 0 && phase < intervals[0] + intervals[1]);
@@ -727,24 +711,24 @@ GrDrawOp* GrDashingEffect::CreateDashLineBatch(GrColor color,
// Rotate the src pts so they are aligned horizontally with pts[0].fX < pts[1].fX
if (pts[0].fY != pts[1].fY || pts[0].fX > pts[1].fX) {
SkMatrix rotMatrix;
- align_to_x_axis(pts, &rotMatrix, geometry.fPtsRot);
- if(!rotMatrix.invert(&geometry.fSrcRotInv)) {
+ align_to_x_axis(pts, &rotMatrix, lineData.fPtsRot);
+ if (!rotMatrix.invert(&lineData.fSrcRotInv)) {
SkDebugf("Failed to create invertible rotation matrix!\n");
return nullptr;
}
} else {
- geometry.fSrcRotInv.reset();
- memcpy(geometry.fPtsRot, pts, 2 * sizeof(SkPoint));
+ lineData.fSrcRotInv.reset();
+ memcpy(lineData.fPtsRot, pts, 2 * sizeof(SkPoint));
}
// Scale corrections of intervals and stroke from view matrix
- calc_dash_scaling(&geometry.fParallelScale, &geometry.fPerpendicularScale, viewMatrix,
- geometry.fPtsRot);
+ calc_dash_scaling(&lineData.fParallelScale, &lineData.fPerpendicularScale, viewMatrix,
+ lineData.fPtsRot);
- SkScalar offInterval = intervals[1] * geometry.fParallelScale;
- SkScalar strokeWidth = geometry.fSrcStrokeWidth * geometry.fPerpendicularScale;
+ SkScalar offInterval = intervals[1] * lineData.fParallelScale;
+ SkScalar strokeWidth = lineData.fSrcStrokeWidth * lineData.fPerpendicularScale;
- if (SkPaint::kSquare_Cap == cap && 0 != geometry.fSrcStrokeWidth) {
+ if (SkPaint::kSquare_Cap == cap && 0 != lineData.fSrcStrokeWidth) {
// add cap to on interveal and remove from off interval
offInterval -= strokeWidth;
}
@@ -752,13 +736,12 @@ GrDrawOp* GrDashingEffect::CreateDashLineBatch(GrColor color,
// 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 != AAMode::kNone;
- geometry.fColor = color;
- geometry.fViewMatrix = viewMatrix;
- geometry.fPhase = phase;
- geometry.fIntervals[0] = intervals[0];
- geometry.fIntervals[1] = intervals[1];
+ lineData.fViewMatrix = viewMatrix;
+ lineData.fPhase = phase;
+ lineData.fIntervals[0] = intervals[0];
+ lineData.fIntervals[1] = intervals[1];
- return DashBatch::Create(geometry, cap, aaMode, fullDash);
+ return DashOp::Make(lineData, color, cap, aaMode, fullDash);
}
//////////////////////////////////////////////////////////////////////////////
@@ -968,7 +951,7 @@ DashingCircleEffect::DashingCircleEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect);
sk_sp<GrGeometryProcessor> DashingCircleEffect::TestCreate(GrProcessorTestData* d) {
- AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
+ AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
return DashingCircleEffect::Make(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool());
@@ -1195,7 +1178,7 @@ DashingLineEffect::DashingLineEffect(GrColor color,
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect);
sk_sp<GrGeometryProcessor> DashingLineEffect::TestCreate(GrProcessorTestData* d) {
- AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashingEffect::kAAModeCnt));
+ AAMode aaMode = static_cast<AAMode>(d->fRandom->nextULessThan(GrDashOp::kAAModeCnt));
return DashingLineEffect::Make(GrRandomColor(d->fRandom),
aaMode, GrTest::TestMatrix(d->fRandom),
d->fRandom->nextBool());
@@ -1227,10 +1210,10 @@ static sk_sp<GrGeometryProcessor> make_dash_gp(GrColor color,
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(DashBatch) {
+DRAW_BATCH_TEST_DEFINE(DashOp) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixPreservesRightAngles(random);
- AAMode aaMode = static_cast<AAMode>(random->nextULessThan(GrDashingEffect::kAAModeCnt));
+ AAMode aaMode = static_cast<AAMode>(random->nextULessThan(GrDashOp::kAAModeCnt));
// We can only dash either horizontal or vertical lines
SkPoint pts[2];
@@ -1292,7 +1275,7 @@ DRAW_BATCH_TEST_DEFINE(DashBatch) {
GrStyle style(p);
- return GrDashingEffect::CreateDashLineBatch(color, viewMatrix, pts, aaMode, style);
+ return GrDashOp::MakeDashLineOp(color, viewMatrix, pts, aaMode, style).release();
}
#endif
diff --git a/src/gpu/batches/GrDashOp.h b/src/gpu/batches/GrDashOp.h
new file mode 100644
index 0000000000..ff04f91af5
--- /dev/null
+++ b/src/gpu/batches/GrDashOp.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrDashOp_DEFINED
+#define GrDashOp_DEFINED
+
+#include "GrColor.h"
+#include "GrTypesPriv.h"
+#include "SkPathEffect.h"
+
+class GrDrawOp;
+class GrStyle;
+
+namespace GrDashOp {
+enum class AAMode {
+ kNone,
+ kCoverage,
+ kCoverageWithMSAA,
+};
+static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1;
+
+sk_sp<GrDrawOp> MakeDashLineOp(GrColor, const SkMatrix& viewMatrix, const SkPoint pts[2], AAMode,
+ const GrStyle& style);
+bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style, const SkMatrix& viewMatrix);
+}
+
+#endif
diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp
index 083e111638..d6f3574ca2 100644
--- a/src/gpu/batches/GrPLSPathRenderer.cpp
+++ b/src/gpu/batches/GrPLSPathRenderer.cpp
@@ -763,20 +763,14 @@ bool GrPLSPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
path.getFillType() == SkPath::FillType::kWinding_FillType;
}
-class PLSPathBatch final : public GrMeshDrawOp {
+class PLSPathOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- PLSPathBatch(GrColor color, const SkPath& path, const SkMatrix& viewMatrix)
- : INHERITED(ClassID())
- , fColor(color)
- , fPath(path)
- , fViewMatrix(viewMatrix) {
- // compute bounds
- this->setTransformedBounds(path.getBounds(), fViewMatrix, HasAABloat::kYes,
- IsZeroArea::kNo);
+ static sk_sp<GrDrawOp> Make(GrColor color, const SkPath& path, const SkMatrix& viewMatrix) {
+ return sk_sp<GrDrawOp>(new PLSPathOp(color, path, viewMatrix));
}
- const char* name() const override { return "PLSBatch"; }
+ const char* name() const override { return "PLSPathOp"; }
SkString dumpInfo() const override {
SkString string;
@@ -789,7 +783,6 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one geometry bundle
color->setKnownFourComponents(fColor);
coverage->setUnknownSingleComponent();
overrides->fUsePLSDstRead = true;
@@ -802,7 +795,6 @@ public:
}
overrides.getOverrideColorIfSet(&fColor);
- // setup batch properties
fUsesLocalCoords = overrides.readsLocalCoords();
}
@@ -915,6 +907,13 @@ public:
}
private:
+ PLSPathOp(GrColor color, const SkPath& path, const SkMatrix& viewMatrix)
+ : INHERITED(ClassID()), fColor(color), fPath(path), fViewMatrix(viewMatrix) {
+ // compute bounds
+ this->setTransformedBounds(path.getBounds(), fViewMatrix, HasAABloat::kYes,
+ IsZeroArea::kNo);
+ }
+
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
return false;
}
@@ -935,7 +934,7 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkPath path;
args.fShape->asPath(&path);
- sk_sp<GrDrawOp> op(new PLSPathBatch(args.fPaint->getColor(), path, *args.fViewMatrix));
+ sk_sp<GrDrawOp> op = PLSPathOp::Make(args.fPaint->getColor(), path, *args.fViewMatrix);
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
@@ -949,12 +948,12 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) {
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(PLSPathBatch) {
+DRAW_BATCH_TEST_DEFINE(PLSPathOp) {
GrColor color = GrRandomColor(random);
SkMatrix vm = GrTest::TestMatrixInvertible(random);
SkPath path = GrTest::TestPathConvex(random);
- return new PLSPathBatch(color, path, vm);
+ return PLSPathOp::Make(color, path, vm).release();
}
#endif
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index 6b39276c07..faca060580 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -156,19 +156,20 @@ bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
return true;
}
-class TessellatingPathBatch final : public GrMeshDrawOp {
+class TessellatingPathOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- static GrDrawOp* Create(const GrColor& color,
- const GrShape& shape,
- const SkMatrix& viewMatrix,
- SkIRect devClipBounds,
- bool antiAlias) {
- return new TessellatingPathBatch(color, shape, viewMatrix, devClipBounds, antiAlias);
+ static sk_sp<GrDrawOp> Make(const GrColor& color,
+ const GrShape& shape,
+ const SkMatrix& viewMatrix,
+ SkIRect devClipBounds,
+ bool antiAlias) {
+ return sk_sp<GrDrawOp>(
+ new TessellatingPathOp(color, shape, viewMatrix, devClipBounds, antiAlias));
}
- const char* name() const override { return "TessellatingPathBatch"; }
+ const char* name() const override { return "TessellatingPathOp"; }
SkString dumpInfo() const override {
SkString string;
@@ -322,17 +323,17 @@ private:
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
- TessellatingPathBatch(const GrColor& color,
- const GrShape& shape,
- const SkMatrix& viewMatrix,
- const SkIRect& devClipBounds,
- bool antiAlias)
- : INHERITED(ClassID())
- , fColor(color)
- , fShape(shape)
- , fViewMatrix(viewMatrix)
- , fDevClipBounds(devClipBounds)
- , fAntiAlias(antiAlias) {
+ TessellatingPathOp(const GrColor& color,
+ const GrShape& shape,
+ const SkMatrix& viewMatrix,
+ const SkIRect& devClipBounds,
+ bool antiAlias)
+ : INHERITED(ClassID())
+ , fColor(color)
+ , fShape(shape)
+ , fViewMatrix(viewMatrix)
+ , fDevClipBounds(devClipBounds)
+ , fAntiAlias(antiAlias) {
SkRect devBounds;
viewMatrix.mapRect(&devBounds, shape.bounds());
if (shape.inverseFilled()) {
@@ -360,11 +361,11 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
args.fClip->getConservativeBounds(args.fRenderTargetContext->width(),
args.fRenderTargetContext->height(),
&clipBoundsI);
- sk_sp<GrDrawOp> op(TessellatingPathBatch::Create(args.fPaint->getColor(),
- *args.fShape,
- *args.fViewMatrix,
- clipBoundsI,
- GrAAType::kCoverage == args.fAAType));
+ sk_sp<GrDrawOp> op = TessellatingPathOp::Make(args.fPaint->getColor(),
+ *args.fShape,
+ *args.fViewMatrix,
+ clipBoundsI,
+ GrAAType::kCoverage == args.fAAType);
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, std::move(op));
@@ -375,7 +376,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(TesselatingPathBatch) {
+DRAW_BATCH_TEST_DEFINE(TesselatingPathOp) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkPath path = GrTest::TestPath(random);
@@ -388,7 +389,7 @@ DRAW_BATCH_TEST_DEFINE(TesselatingPathBatch) {
GrTest::TestStyle(random, &style);
} while (!style.isSimpleFill());
GrShape shape(path, style);
- return TessellatingPathBatch::Create(color, shape, viewMatrix, devClipBounds, antiAlias);
+ return TessellatingPathOp::Make(color, shape, viewMatrix, devClipBounds, antiAlias).release();
}
#endif
diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h
deleted file mode 100644
index eccdafde3b..0000000000
--- a/src/gpu/effects/GrDashingEffect.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrDashingEffect_DEFINED
-#define GrDashingEffect_DEFINED
-
-#include "GrColor.h"
-#include "GrTypesPriv.h"
-#include "SkPathEffect.h"
-
-class GrClip;
-class GrDrawOp;
-class GrStyle;
-
-namespace GrDashingEffect {
- enum class AAMode {
- kNone,
- kCoverage,
- kCoverageWithMSAA,
- };
- static const int kAAModeCnt = static_cast<int>(AAMode::kCoverageWithMSAA) + 1;
-
- GrDrawOp* CreateDashLineBatch(GrColor,
- const SkMatrix& viewMatrix,
- const SkPoint pts[2],
- AAMode,
- const GrStyle& style);
- bool CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
- const SkMatrix& viewMatrix);
-}
-
-#endif