blob: e2c3119c5e8d7d39c06b03ffa544f27f2b392f07 [file] [log] [blame]
Chris Daltonc17bf322017-10-24 10:59:03 -06001/*
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
Brian Salomonf95940b2021-08-09 15:56:24 -040011#include "src/gpu/GrGeometryProcessor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
Chris Daltonc17bf322017-10-24 10:59:03 -060013
14/**
Brian Osman99ddd2a2021-08-27 11:21:12 -040015 * Base class for vertex shader builder. This is the stage that computes input geometry for the
16 * rasterizer.
Chris Daltonc17bf322017-10-24 10:59:03 -060017 */
18class GrGLSLVertexGeoBuilder : public GrGLSLShaderBuilder {
Chris Dalton418eda22020-10-16 10:38:39 -060019public:
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 void insertFunction(const char* functionDefinition) {
24 this->functions().append(functionDefinition);
25 }
Chris Dalton7b807262020-12-10 10:22:50 -070026 using GrGLSLShaderBuilder::functions;
Chris Daltone73c0702021-05-15 14:17:22 -060027 using GrGLSLShaderBuilder::code;
Chris Dalton418eda22020-10-16 10:38:39 -060028
Chris Daltonc17bf322017-10-24 10:59:03 -060029protected:
30 GrGLSLVertexGeoBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
31
Brian Osman5d8b7e92020-09-21 17:51:25 -040032 void emitNormalizedSkPosition(const char* devPos,
Chris Daltonc17bf322017-10-24 10:59:03 -060033 GrSLType devPosType = GrSLType::kFloat2_GrSLType) {
Brian Osman5d8b7e92020-09-21 17:51:25 -040034 this->emitNormalizedSkPosition(&this->code(), devPos, devPosType);
Chris Daltonc17bf322017-10-24 10:59:03 -060035 }
36
Brian Osman5d8b7e92020-09-21 17:51:25 -040037 void emitNormalizedSkPosition(SkString* out, const char* devPos,
Chris Daltonc17bf322017-10-24 10:59:03 -060038 GrSLType devPosType = GrSLType::kFloat2_GrSLType);
39
Brian Salomonf95940b2021-08-09 15:56:24 -040040 friend class GrGeometryProcessor::ProgramImpl;
Chris Daltonc17bf322017-10-24 10:59:03 -060041
John Stiles7571f9e2020-09-02 22:42:33 -040042 using INHERITED = GrGLSLShaderBuilder;
Chris Daltonc17bf322017-10-24 10:59:03 -060043};
44
45
46class GrGLSLVertexBuilder : public GrGLSLVertexGeoBuilder {
47public:
48 GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {}
49
50private:
51 void onFinalize() override;
52
53 friend class GrGLProgramBuilder;
54
John Stiles7571f9e2020-09-02 22:42:33 -040055 using INHERITED = GrGLSLVertexGeoBuilder;
Chris Daltonc17bf322017-10-24 10:59:03 -060056};
57
Chris Daltonc17bf322017-10-24 10:59:03 -060058#endif