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 shader builder. This is the stage that computes input geometry for the 16 * 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. insertFunction(const char * functionDefinition)23 void insertFunction(const char* functionDefinition) { 24 this->functions().append(functionDefinition); 25 } 26 using GrGLSLShaderBuilder::functions; 27 using GrGLSLShaderBuilder::code; 28 29 protected: GrGLSLVertexGeoBuilder(GrGLSLProgramBuilder * program)30 GrGLSLVertexGeoBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {} 31 32 void emitNormalizedSkPosition(const char* devPos, 33 GrSLType devPosType = GrSLType::kFloat2_GrSLType) { 34 this->emitNormalizedSkPosition(&this->code(), devPos, devPosType); 35 } 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: GrGLSLVertexBuilder(GrGLSLProgramBuilder * program)48 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 #endif 59