Restructure path tessellation shaders
Merges the GrStrokePathShader and GrFillPathShader classes together.
Creates a new base class called GrPathTessellationShader. Now they all
have a uniform color and can all be draw to stencil and color both.
This is necessary cleanup in general, but will also allow us to create
a convex tessellation op that bypasses the stencil buffer.
Bug: skia:10419
Change-Id: Ifc492c94d3de044a36bd9ea95b1d5aa22e007905
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413696
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/samplecode/SamplePathTessellators.cpp b/samplecode/SamplePathTessellators.cpp
index 62a61d4..b753f6e 100644
--- a/samplecode/SamplePathTessellators.cpp
+++ b/samplecode/SamplePathTessellators.cpp
@@ -14,8 +14,8 @@
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrSurfaceDrawContext.h"
+#include "src/gpu/tessellate/GrPathTessellationShader.h"
#include "src/gpu/tessellate/GrPathTessellator.h"
-#include "src/gpu/tessellate/GrStencilPathShader.h"
namespace {
@@ -66,28 +66,30 @@
const GrXferProcessor::DstProxyView&, GrXferBarrierFlags,
GrLoadOp colorLoadOp) override {}
void onPrepare(GrOpFlushState* flushState) override {
+ constexpr static SkPMColor4f kCyan = {0,1,1,1};
auto alloc = flushState->allocator();
switch (fMode) {
case Mode::kCurveMiddleOut:
fTessellator = GrPathIndirectTessellator::Make(
- alloc, fMatrix, fPath, GrPathTessellator::DrawInnerFan::kYes);
+ alloc, fPath, fMatrix, kCyan, GrPathTessellator::DrawInnerFan::kYes);
break;
case Mode::kWedgeTessellate:
- fTessellator = GrPathWedgeTessellator::Make(alloc, fMatrix);
+ fTessellator = GrPathWedgeTessellator::Make(alloc, fMatrix, kCyan);
break;
case Mode::kCurveTessellate:
fTessellator = GrPathOuterCurveTessellator::Make(
- alloc, fMatrix, GrPathTessellator::DrawInnerFan::kYes);
+ alloc, fMatrix, kCyan, GrPathTessellator::DrawInnerFan::kYes);
break;
}
fTessellator->prepare(flushState, this->bounds(), fPath);
auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState, std::move(fProcessors),
fPipelineFlags);
- fProgram = GrPathShader::MakeProgram({alloc, flushState->writeView(),
- &flushState->dstProxyView(),
- flushState->renderPassBarriers(), GrLoadOp::kClear,
- &flushState->caps()}, fTessellator->shader(), pipeline,
- &GrUserStencilSettings::kUnused);
+ fProgram = GrTessellationShader::MakeProgram({alloc, flushState->writeView(),
+ &flushState->dstProxyView(),
+ flushState->renderPassBarriers(),
+ GrLoadOp::kClear, &flushState->caps()},
+ fTessellator->shader(), pipeline,
+ &GrUserStencilSettings::kUnused);
}
void onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) override {
flushState->bindPipeline(*fProgram, chainBounds);