1/*
2 * Copyright 2020 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrPathShader_DEFINED
9#define GrPathShader_DEFINED
10
11#include "src/gpu/GrGeometryProcessor.h"
12#include "src/gpu/GrOpFlushState.h"
13#include "src/gpu/GrOpsRenderPass.h"
14#include "src/gpu/GrProgramInfo.h"
15
16 // This is a common base class for shaders in the GPU tessellator.
17class GrPathShader : public GrGeometryProcessor {
18public:
19 GrPathShader(ClassID classID, const SkMatrix& viewMatrix, GrPrimitiveType primitiveType,
20 int tessellationPatchVertexCount)
21 : GrGeometryProcessor(classID)
22 , fViewMatrix(viewMatrix)
23 , fPrimitiveType(primitiveType)
24 , fTessellationPatchVertexCount(tessellationPatchVertexCount) {
25 if (fTessellationPatchVertexCount) {
26 this->setWillUseTessellationShaders();
27 }
28 }
29
30 const SkMatrix& viewMatrix() const { return fViewMatrix; }
31
32 // This subclass is used to simplify the argument list for constructing GrProgramInfo from a
33 // GrPathShader.
34 class ProgramInfo : public GrProgramInfo {
35 public:
36 ProgramInfo(const GrSurfaceProxyView* view, const GrPipeline* pipeline,
37 const GrPathShader* shader)
38 : ProgramInfo(view->asRenderTargetProxy(), view->origin(), pipeline, shader) {
39 }
40 ProgramInfo(const GrRenderTargetProxy* proxy, GrSurfaceOrigin origin,
41 const GrPipeline* pipeline, const GrPathShader* shader)
42 : GrProgramInfo(proxy->numSamples(), proxy->numStencilSamples(),
43 proxy->backendFormat(), origin, pipeline, shader,
44 shader->fPrimitiveType, shader->fTessellationPatchVertexCount) {
45 }
46 };
47
48private:
49 const SkMatrix fViewMatrix;
50 const GrPrimitiveType fPrimitiveType;
51 const int fTessellationPatchVertexCount;
52
53 class Impl;
54};
55
56#endif
57