Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/gpu/glsl/GrGLSLVertexGeoBuilder.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2017 Google Inc.
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 GrGLSLVertexGeoBuilder_DEFINED
9
#define GrGLSLVertexGeoBuilder_DEFINED
10
11
#include "src/gpu/GrGeometryProcessor.h"
12
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
13
14
/**
15
 * Base class for vertex and geometry shader builders. This is the stage that computes input
16
 * geometry for the rasterizer.
17
 */
18
class GrGLSLVertexGeoBuilder : public GrGLSLShaderBuilder {
19
public:
20
    // Copies the given text verbatim to the function definitions section. Does not mangle the name.
21
    // 'functionDefinition' should be a fully valid SkSL function, complete with return type, name,
22
    // arguments, braces, and a body.
23
0
    void insertFunction(const char* functionDefinition) {
24
0
        this->functions().append(functionDefinition);
25
0
    }
26
    using GrGLSLShaderBuilder::functions;
27
    using GrGLSLShaderBuilder::code;
28
29
protected:
30
0
    GrGLSLVertexGeoBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
31
32
    void emitNormalizedSkPosition(const char* devPos,
33
0
                                  GrSLType devPosType = GrSLType::kFloat2_GrSLType) {
34
0
        this->emitNormalizedSkPosition(&this->code(), devPos, devPosType);
35
0
    }
36
37
    void emitNormalizedSkPosition(SkString* out, const char* devPos,
38
                                  GrSLType devPosType = GrSLType::kFloat2_GrSLType);
39
40
    friend class GrGeometryProcessor::ProgramImpl;
41
42
    using INHERITED = GrGLSLShaderBuilder;
43
};
44
45
46
class GrGLSLVertexBuilder : public GrGLSLVertexGeoBuilder {
47
public:
48
0
    GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
49
50
private:
51
    void onFinalize() override;
52
53
    friend class GrGLProgramBuilder;
54
55
    using INHERITED = GrGLSLVertexGeoBuilder;
56
};
57
58
59
class GrGLSLGeometryBuilder : public GrGLSLVertexGeoBuilder {
60
public:
61
0
    GrGLSLGeometryBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
62
63
    enum class InputType {
64
        kPoints,
65
        kLines,
66
        kTriangles,
67
    };
68
69
    enum class OutputType {
70
        kPoints,
71
        kLineStrip,
72
        kTriangleStrip
73
    };
74
75
    void configure(InputType, OutputType, int maxVertices, int numInvocations = 1);
76
0
    bool isConfigured() const { return fNumInvocations; }
77
78
0
    void emitVertex(const char* devPos, GrSLType devPosType = GrSLType::kFloat2_GrSLType) {
79
0
        this->emitVertex(&this->code(), devPos, devPosType);
80
0
    }
81
    void emitVertex(SkString* out, const char* devPos,
82
                    GrSLType devPosType = GrSLType::kFloat2_GrSLType);
83
84
    void endPrimitive();
85
86
private:
87
    void onFinalize() override;
88
89
    int fNumInvocations = 0;
90
91
    friend class GrGLProgramBuilder;
92
93
    using INHERITED = GrGLSLVertexGeoBuilder;
94
};
95
96
#endif