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, SkSLType devPosType = SkSLType::kFloat2) { 33 this->emitNormalizedSkPosition(&this->code(), devPos, devPosType); 34 } 35 36 void emitNormalizedSkPosition(SkString* out, const char* devPos, 37 SkSLType devPosType = SkSLType::kFloat2); 38 39 friend class GrGeometryProcessor::ProgramImpl; 40 41 using INHERITED = GrGLSLShaderBuilder; 42 }; 43 44 45 class GrGLSLVertexBuilder : public GrGLSLVertexGeoBuilder { 46 public: GrGLSLVertexBuilder(GrGLSLProgramBuilder * program)47 GrGLSLVertexBuilder(GrGLSLProgramBuilder* program) : INHERITED(program) {} 48 49 private: 50 void onFinalize() override; 51 52 friend class GrGLProgramBuilder; 53 54 using INHERITED = GrGLSLVertexGeoBuilder; 55 }; 56 57 #endif 58