OLD | NEW |
(Empty) | |
| 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 #include "GrGLShaderBuilder.h" |
| 11 |
| 12 class GrGLProgramBuilder; |
| 13 |
| 14 class GrGLVertexShaderBuilder : public GrGLFullShaderBuilder { |
| 15 public: |
| 16 GrGLVertexShaderBuilder(GrGLFullProgramBuilder* program); |
| 17 |
| 18 /* |
| 19 * Add attribute will push a new attribute onto the end. It will also asser
t if there is |
| 20 * a duplicate attribute |
| 21 */ |
| 22 bool addAttribute(GrSLType type, const char* name); |
| 23 |
| 24 bool addEffectAttribute(int attributeIndex, GrSLType type, const SkString& n
ame); |
| 25 |
| 26 /* |
| 27 * this call is only for GrGLProgramEffects' internal use |
| 28 */ |
| 29 void emitAttributes(const GrEffectStage& stage); |
| 30 |
| 31 /** |
| 32 * Are explicit local coordinates provided as input to the vertex shader. |
| 33 */ |
| 34 bool hasExplicitLocalCoords() const { return (fLocalCoordsVar != fPositionVa
r); } |
| 35 |
| 36 const SkString* getEffectAttributeName(int attributeIndex) const; |
| 37 |
| 38 /** Returns a vertex attribute that represents the local coords in the VS. T
his may be the same |
| 39 as positionAttribute() or it may not be. It depends upon whether the ren
dering code |
| 40 specified explicit local coords or not in the GrDrawState. */ |
| 41 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
} |
| 42 |
| 43 /** Returns a vertex attribute that represents the vertex position in the VS
. This is the |
| 44 pre-matrix position and is commonly used by effects to compute texture c
oords via a matrix. |
| 45 */ |
| 46 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } |
| 47 |
| 48 private: |
| 49 /* |
| 50 * Internal call for GrGLFullProgramBuilder.addVarying |
| 51 */ |
| 52 void addVarying(GrSLType type, |
| 53 const char* name, |
| 54 const char** vsOutName); |
| 55 |
| 56 /* |
| 57 * private helpers for compilation by GrGLProgramBuilder |
| 58 */ |
| 59 void bindProgramLocations(GrGLuint programId); |
| 60 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; |
| 61 void emitCodeBeforeEffects(GrGLSLExpr4* color, GrGLSLExpr4* coverage); |
| 62 void emitCodeAfterEffects(); |
| 63 |
| 64 struct AttributePair { |
| 65 void set(int index, const SkString& name) { |
| 66 fIndex = index; fName = name; |
| 67 } |
| 68 int fIndex; |
| 69 SkString fName; |
| 70 }; |
| 71 |
| 72 SkSTArray<10, AttributePair, true> fEffectAttributes; |
| 73 GrGLShaderVar* fPositionVar; |
| 74 GrGLShaderVar* fLocalCoordsVar; |
| 75 |
| 76 friend class GrGLFullProgramBuilder; |
| 77 |
| 78 typedef GrGLFullShaderBuilder INHERITED; |
| 79 }; |
| 80 |
| 81 #endif |
OLD | NEW |