Delete GrPathTessellationShader::MakeSimpleTriangleShader
We should have always used the default GP here. It makes for better
reuse, and shader that draws raw triangles isn't a "tessellation"
shader anyway.
Bug: skia:10419
Change-Id: Ia2ef2a83f5ed8917005e12b9f9a52c1d9f877575
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429956
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h
index 2d31725..a291e91 100644
--- a/src/gpu/GrProcessor.h
+++ b/src/gpu/GrProcessor.h
@@ -103,7 +103,6 @@
kTessellate_HardwareWedgeShader_ClassID,
kTessellate_HullShader_ClassID,
kTessellate_MiddleOutShader_ClassID,
- kTessellate_SimpleTriangleShader_ClassID,
kTessellationTestTriShader_ClassID,
kTestFP_ClassID,
kTestRectOp_ClassID,
diff --git a/src/gpu/tessellate/GrPathInnerTriangulateOp.cpp b/src/gpu/tessellate/GrPathInnerTriangulateOp.cpp
index be9875a..63466ce 100644
--- a/src/gpu/tessellate/GrPathInnerTriangulateOp.cpp
+++ b/src/gpu/tessellate/GrPathInnerTriangulateOp.cpp
@@ -7,6 +7,7 @@
#include "src/gpu/tessellate/GrPathInnerTriangulateOp.h"
+#include "src/gpu/GrDefaultGeoProcFactory.h"
#include "src/gpu/GrEagerVertexAllocator.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrInnerFanTriangulator.h"
@@ -184,22 +185,24 @@
clampType, &fColor);
}
-void GrPathInnerTriangulateOp::pushFanStencilProgram(const GrTessellationShader::ProgramArgs& args,
- const GrPipeline* pipelineForStencils,
- const GrUserStencilSettings* stencil) {
- SkASSERT(pipelineForStencils);
- auto shader = GrPathTessellationShader::MakeSimpleTriangleShader(args.fArena, fViewMatrix,
- SK_PMColor4fTRANSPARENT);
- fFanPrograms.push_back(GrTessellationShader::MakeProgram(args, shader, pipelineForStencils,
- stencil)); }
-
-void GrPathInnerTriangulateOp::pushFanFillProgram(const GrTessellationShader::ProgramArgs& args,
- const GrUserStencilSettings* stencil) {
- SkASSERT(fPipelineForFills);
- auto shader = GrPathTessellationShader::MakeSimpleTriangleShader(args.fArena, fViewMatrix,
- fColor);
- fFanPrograms.push_back(GrTessellationShader::MakeProgram(args, shader, fPipelineForFills,
- stencil));
+void GrPathInnerTriangulateOp::pushFanProgram(const GrTessellationShader::ProgramArgs& args,
+ const GrPipeline* pipeline,
+ const SkPMColor4f& color,
+ const GrUserStencilSettings* stencil) {
+ auto triangleGP = GrDefaultGeoProcFactory::Make(
+ args.fArena,
+ GrDefaultGeoProcFactory::Color(color),
+ GrDefaultGeoProcFactory::Coverage::kSolid_Type,
+ GrDefaultGeoProcFactory::LocalCoords::kUsePosition_Type,
+ fViewMatrix);
+ fFanPrograms.push_back(GrSimpleMeshDrawOpHelper::CreateProgramInfo(args.fArena,
+ pipeline,
+ args.fWriteView,
+ triangleGP,
+ GrPrimitiveType::kTriangles,
+ args.fXferBarrierFlags,
+ args.fColorLoadOp,
+ stencil));
}
void GrPathInnerTriangulateOp::prePreparePrograms(const GrTessellationShader::ProgramArgs& args,
@@ -260,15 +263,16 @@
// stencil buffer to fill the fan directly.
const GrUserStencilSettings* stencilPathSettings =
GrPathTessellationShader::StencilPathSettings(GrFillRuleForSkPath(fPath));
- this->pushFanStencilProgram(args, pipelineForStencils, stencilPathSettings);
+ this->pushFanProgram(args, pipelineForStencils, SK_PMColor4fTRANSPARENT,
+ stencilPathSettings);
if (doFill) {
- this->pushFanFillProgram(args,
- GrPathTessellationShader::TestAndResetStencilSettings());
+ this->pushFanProgram(args, fPipelineForFills, fColor,
+ GrPathTessellationShader::TestAndResetStencilSettings());
}
} else if (isLinear) {
// There are no outer curves! Ignore stencil and fill the path directly.
SkASSERT(!pipelineForStencils);
- this->pushFanFillProgram(args, &GrUserStencilSettings::kUnused);
+ this->pushFanProgram(args, fPipelineForFills, fColor, &GrUserStencilSettings::kUnused);
} else if (!fPipelineForFills->hasStencilClip()) {
// These are a twist on the standard Redbook stencil settings that allow us to fill the
// inner polygon directly to the final render target. By the time these programs
@@ -298,7 +302,7 @@
auto* stencil = (fPath.getFillType() == SkPathFillType::kWinding)
? &kFillOrIncrDecrStencil
: &kFillOrInvertStencil;
- this->pushFanFillProgram(args, stencil);
+ this->pushFanProgram(args, fPipelineForFills, fColor, stencil);
} else {
// This is the same idea as above, but we use two passes instead of one because there is
// a stencil clip. The stencil test isn't expressive enough to do the above tests and
@@ -336,13 +340,13 @@
0xffff>());
// Pass 2a: Directly fill fan samples whose stencil values (from curves) are zero.
- this->pushFanFillProgram(args, &kFillIfZeroAndInClip);
+ this->pushFanProgram(args, fPipelineForFills, fColor, &kFillIfZeroAndInClip);
// Pass 2b: Redbook counting on fan samples whose stencil values (from curves) != 0.
auto* stencil = (fPath.getFillType() == SkPathFillType::kWinding)
? &kIncrDecrStencilIfNonzero
: &kInvertStencilIfNonZero;
- this->pushFanStencilProgram(args, pipelineForStencils, stencil);
+ this->pushFanProgram(args, pipelineForStencils, SK_PMColor4fTRANSPARENT, stencil);
}
}
diff --git a/src/gpu/tessellate/GrPathInnerTriangulateOp.h b/src/gpu/tessellate/GrPathInnerTriangulateOp.h
index 3495858..9a4c77d 100644
--- a/src/gpu/tessellate/GrPathInnerTriangulateOp.h
+++ b/src/gpu/tessellate/GrPathInnerTriangulateOp.h
@@ -47,9 +47,10 @@
GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrClampType) override;
// These calls set up the stencil & fill programs we will use prior to preparing and executing.
- void pushFanStencilProgram(const GrTessellationShader::ProgramArgs&,
- const GrPipeline* pipelineForStencils, const GrUserStencilSettings*);
- void pushFanFillProgram(const GrTessellationShader::ProgramArgs&, const GrUserStencilSettings*);
+ void pushFanProgram(const GrTessellationShader::ProgramArgs&,
+ const GrPipeline* pipeline,
+ const SkPMColor4f& color,
+ const GrUserStencilSettings*);
void prePreparePrograms(const GrTessellationShader::ProgramArgs&, GrAppliedClip&&);
void onPrePrepare(GrRecordingContext*, const GrSurfaceProxyView&, GrAppliedClip*,
diff --git a/src/gpu/tessellate/GrPathStencilCoverOp.cpp b/src/gpu/tessellate/GrPathStencilCoverOp.cpp
index 7bc5dea..09ea443 100644
--- a/src/gpu/tessellate/GrPathStencilCoverOp.cpp
+++ b/src/gpu/tessellate/GrPathStencilCoverOp.cpp
@@ -7,6 +7,7 @@
#include "src/gpu/tessellate/GrPathStencilCoverOp.h"
+#include "src/gpu/GrDefaultGeoProcFactory.h"
#include "src/gpu/GrEagerVertexAllocator.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrOpFlushState.h"
@@ -114,10 +115,21 @@
// Large complex paths do better with a dedicated triangle shader for the inner fan.
// This takes less PCI bus bandwidth (6 floats per triangle instead of 8) and allows us
// to make sure it has an efficient middle-out topology.
- auto shader = GrPathTessellationShader::MakeSimpleTriangleShader(
- args.fArena, fViewMatrix, SK_PMColor4fTRANSPARENT);
- fStencilFanProgram = GrTessellationShader::MakeProgram(args, shader, stencilPipeline,
- stencilPathSettings);
+ auto triangleGP = GrDefaultGeoProcFactory::Make(
+ args.fArena,
+ GrDefaultGeoProcFactory::Color(SK_PMColor4fTRANSPARENT),
+ GrDefaultGeoProcFactory::Coverage::kSolid_Type,
+ GrDefaultGeoProcFactory::LocalCoords::kUnused_Type,
+ fViewMatrix);
+ fStencilFanProgram = GrSimpleMeshDrawOpHelper::CreateProgramInfo(
+ args.fArena,
+ stencilPipeline,
+ args.fWriteView,
+ triangleGP,
+ GrPrimitiveType::kTriangles,
+ args.fXferBarrierFlags,
+ args.fColorLoadOp,
+ stencilPathSettings);
fTessellator = GrPathCurveTessellator::Make(args.fArena, fViewMatrix,
SK_PMColor4fTRANSPARENT,
GrPathCurveTessellator::DrawInnerFan::kNo,
diff --git a/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp b/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp
index 30f3816..0eb89e4 100644
--- a/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp
+++ b/src/gpu/tessellate/shaders/GrPathTessellationShader.cpp
@@ -12,46 +12,6 @@
#include "src/gpu/glsl/GrGLSLVarying.h"
#include "src/gpu/glsl/GrGLSLVertexGeoBuilder.h"
-namespace {
-
-// Draws a simple array of triangles.
-class SimpleTriangleShader : public GrPathTessellationShader {
-public:
- SimpleTriangleShader(const SkMatrix& viewMatrix, SkPMColor4f color)
- : GrPathTessellationShader(kTessellate_SimpleTriangleShader_ClassID,
- GrPrimitiveType::kTriangles, 0, viewMatrix, color) {
- constexpr static Attribute kInputPointAttrib{"inputPoint", kFloat2_GrVertexAttribType,
- kFloat2_GrSLType};
- this->setVertexAttributes(&kInputPointAttrib, 1);
- }
-
-private:
- const char* name() const final { return "tessellate_SimpleTriangleShader"; }
- void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const final {}
- GrGLSLGeometryProcessor* createGLSLInstance(const GrShaderCaps&) const final;
-};
-
-GrGLSLGeometryProcessor* SimpleTriangleShader::createGLSLInstance(const GrShaderCaps&) const {
- class Impl : public GrPathTessellationShader::Impl {
- void emitVertexCode(const GrShaderCaps&, const GrPathTessellationShader&,
- GrGLSLVertexBuilder* v, GrGPArgs* gpArgs) override {
- v->codeAppend(R"(
- float2 localcoord = inputPoint;
- float2 vertexpos = AFFINE_MATRIX * localcoord + TRANSLATE;)");
- gpArgs->fLocalCoordVar.set(kFloat2_GrSLType, "localcoord");
- gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertexpos");
- }
- };
- return new Impl;
-}
-
-} // namespace
-
-GrPathTessellationShader* GrPathTessellationShader::MakeSimpleTriangleShader(
- SkArenaAlloc* arena, const SkMatrix& viewMatrix, const SkPMColor4f& color) {
- return arena->make<SimpleTriangleShader>(viewMatrix, color);
-}
-
const GrPipeline* GrPathTessellationShader::MakeStencilOnlyPipeline(
const ProgramArgs& args,
GrAAType aaType,
diff --git a/src/gpu/tessellate/shaders/GrPathTessellationShader.h b/src/gpu/tessellate/shaders/GrPathTessellationShader.h
index a2000b0..370f58c 100644
--- a/src/gpu/tessellate/shaders/GrPathTessellationShader.h
+++ b/src/gpu/tessellate/shaders/GrPathTessellationShader.h
@@ -15,11 +15,6 @@
// This is the base class for shaders in the GPU tessellator that fill paths.
class GrPathTessellationShader : public GrTessellationShader {
public:
- // Draws a simple array of triangles.
- static GrPathTessellationShader* MakeSimpleTriangleShader(SkArenaAlloc*,
- const SkMatrix& viewMatrix,
- const SkPMColor4f&);
-
// How many triangles are in a curve with 2^resolveLevel line segments?
constexpr static int NumCurveTrianglesAtResolveLevel(int resolveLevel) {
// resolveLevel=0 -> 0 line segments -> 0 triangles