| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLVertexShader_DEFINED | 8 #ifndef GrGLVertexShader_DEFINED |
| 9 #define GrGLVertexShader_DEFINED | 9 #define GrGLVertexShader_DEFINED |
| 10 | 10 |
| 11 #include "GrGLShaderBuilder.h" | 11 #include "GrGLShaderBuilder.h" |
| 12 | 12 |
| 13 class GrGLVarying; | 13 class GrGLVarying; |
| 14 | 14 |
| 15 class GrGLVertexBuilder : public GrGLShaderBuilder { | 15 class GrGLVertexBuilder : public GrGLShaderBuilder { |
| 16 public: | 16 public: |
| 17 GrGLVertexBuilder(GrGLProgramBuilder* program); | 17 GrGLVertexBuilder(GrGLProgramBuilder* program); |
| 18 | 18 |
| 19 void transformPositionToDeviceSpace(const char* pos3); |
| 20 |
| 19 /** | 21 /** |
| 20 * Are explicit local coordinates provided as input to the vertex shader. | 22 * Are explicit local coordinates provided as input to the vertex shader. |
| 21 */ | 23 */ |
| 22 bool hasLocalCoords() const { return (fLocalCoordsVar != fPositionVar); } | 24 bool hasLocalCoords() const { return (fLocalCoordsVar != fPositionVar); } |
| 23 | 25 |
| 24 /** Returns a vertex attribute that represents the local coords in the VS. T
his may be the same | 26 /** Returns a vertex attribute that represents the local coords in the VS. T
his may be the same |
| 25 as positionAttribute() or it may not be. It depends upon whether the ren
dering code | 27 as positionAttribute() or it may not be. It depends upon whether the ren
dering code |
| 26 specified explicit local coords or not in the GrDrawState. */ | 28 specified explicit local coords or not in the GrDrawState. */ |
| 27 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
} | 29 const GrGLShaderVar& localCoordsAttribute() const { return *fLocalCoordsVar;
} |
| 28 | 30 |
| 29 /** Returns a vertex attribute that represents the vertex position in the VS
. This is the | 31 /** Returns a vertex attribute that represents the vertex position in the VS
. This is the |
| 30 pre-matrix position and is commonly used by effects to compute texture c
oords via a matrix. | 32 pre-matrix position and is commonly used by effects to compute texture c
oords via a matrix. |
| 31 */ | 33 */ |
| 32 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } | 34 const GrGLShaderVar& positionAttribute() const { return *fPositionVar; } |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 /* | 37 /* |
| 36 * Internal call for GrGLProgramBuilder.addVarying | 38 * Internal call for GrGLProgramBuilder.addVarying |
| 37 */ | 39 */ |
| 38 void addVarying(const char* name, GrGLVarying*); | 40 void addVarying(const char* name, GrGLVarying*); |
| 39 | 41 |
| 40 /* | 42 /* |
| 41 * private helpers for compilation by GrGLProgramBuilder | 43 * private helpers for compilation by GrGLProgramBuilder |
| 42 */ | 44 */ |
| 45 //TODO GP itself should setup the uniform view matrix |
| 46 void setupUniformViewMatrix(); |
| 43 void setupLocalCoords(); | 47 void setupLocalCoords(); |
| 44 void transformGLToSkiaCoords(); | |
| 45 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr1* out); | 48 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr1* out); |
| 46 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); | 49 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); |
| 47 void emitAttributes(const GrGeometryProcessor& gp); | 50 void emitAttributes(const GrGeometryProcessor& gp); |
| 48 void transformSkiaToGLCoords(); | |
| 49 void bindVertexAttributes(GrGLuint programID); | 51 void bindVertexAttributes(GrGLuint programID); |
| 50 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; | 52 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; |
| 51 | 53 |
| 52 // an internal call which checks for uniquness of a var before adding it to
the list of inputs | 54 // an internal call which checks for uniquness of a var before adding it to
the list of inputs |
| 53 bool addAttribute(const GrShaderVar& var); | 55 bool addAttribute(const GrShaderVar& var); |
| 54 struct AttributePair { | 56 struct AttributePair { |
| 55 void set(int index, const SkString& name) { | 57 void set(int index, const SkString& name) { |
| 56 fIndex = index; fName = name; | 58 fIndex = index; fName = name; |
| 57 } | 59 } |
| 58 int fIndex; | 60 int fIndex; |
| 59 SkString fName; | 61 SkString fName; |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 GrGLShaderVar* fPositionVar; | 64 GrGLShaderVar* fPositionVar; |
| 63 GrGLShaderVar* fLocalCoordsVar; | 65 GrGLShaderVar* fLocalCoordsVar; |
| 66 const char* fRtAdjustName; |
| 64 int fEffectAttribOffset; | 67 int fEffectAttribOffset; |
| 65 | 68 |
| 66 friend class GrGLProgramBuilder; | 69 friend class GrGLProgramBuilder; |
| 67 | 70 |
| 68 typedef GrGLShaderBuilder INHERITED; | 71 typedef GrGLShaderBuilder INHERITED; |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 #endif | 74 #endif |
| OLD | NEW |