1/* 2 * Copyright 2014 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 GrGLVertexShader_DEFINED 9#define GrGLVertexShader_DEFINED 10 11#include "GrGLShaderBuilder.h" 12#include "GrGeometryProcessor.h" 13 14class GrGLVarying; 15 16class GrGLVertexBuilder : public GrGLShaderBuilder { 17public: 18 GrGLVertexBuilder(GrGLProgramBuilder* program); 19 20 void transformToNormalizedDeviceSpace(const GrShaderVar& posVar); 21 void emitAttributes(const GrGeometryProcessor& gp); 22 23 void addAttribute(const GrGeometryProcessor::Attribute* attr) { 24 this->addAttribute(GrShaderVar(attr->fName, 25 GrVertexAttribTypeToSLType(attr->fType), 26 GrShaderVar::kAttribute_TypeModifier, 27 GrShaderVar::kNonArray, 28 attr->fPrecision)); 29 } 30 31private: 32 /* 33 * Internal call for GrGLProgramBuilder.addVarying 34 */ 35 void addVarying(const char* name, GrGLVarying*); 36 37 /* 38 * private helpers for compilation by GrGLProgramBuilder 39 */ 40 void bindVertexAttributes(GrGLuint programID); 41 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds); 42 43 // an internal call which checks for uniquness of a var before adding it to the list of inputs 44 bool addAttribute(const GrShaderVar& var); 45 46 const char* fRtAdjustName; 47 48 friend class GrGLProgramBuilder; 49 50 typedef GrGLShaderBuilder INHERITED; 51}; 52 53#endif 54