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 GrGLProgramBuilder; |
14 | 14 |
| 15 // TODO we only actually ever need to return a GrGLShaderBuilder for this guy, n
one of the below |
| 16 // functions need to be part of VertexShaderBuilder's public interface |
15 class GrGLVertexBuilder : public GrGLShaderBuilder { | 17 class GrGLVertexBuilder : public GrGLShaderBuilder { |
16 public: | 18 public: |
17 GrGLVertexBuilder(GrGLProgramBuilder* program); | 19 GrGLVertexBuilder(GrGLProgramBuilder* program); |
18 | 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: | |
35 /* | 36 /* |
36 * Internal call for GrGLProgramBuilder.addVarying | 37 * Internal call for GrGLProgramBuilder.addVarying |
37 */ | 38 */ |
38 void addVarying(const char* name, GrGLVarying*); | 39 SkString* addVarying(GrSLType type, const char* name, const char** vsOutName
); |
39 | 40 |
40 /* | 41 /* |
41 * private helpers for compilation by GrGLProgramBuilder | 42 * private helpers for compilation by GrGLProgramBuilder |
42 */ | 43 */ |
43 void setupLocalCoords(); | 44 void setupLocalCoords(); |
44 void transformGLToSkiaCoords(); | 45 void transformGLToSkiaCoords(); |
45 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); | 46 void setupBuiltinVertexAttribute(const char* inName, GrGLSLExpr4* out); |
46 void emitAttributes(const GrGeometryProcessor& gp); | 47 void emitAttributes(const GrGeometryProcessor& gp); |
47 void transformSkiaToGLCoords(); | 48 void transformSkiaToGLCoords(); |
48 void bindVertexAttributes(GrGLuint programID); | 49 void bindVertexAttributes(GrGLuint programID); |
49 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; | 50 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader
Ids) const; |
50 | 51 |
| 52 private: |
51 // an internal call which checks for uniquness of a var before adding it to
the list of inputs | 53 // an internal call which checks for uniquness of a var before adding it to
the list of inputs |
52 bool addAttribute(const GrShaderVar& var); | 54 bool addAttribute(const GrShaderVar& var); |
53 struct AttributePair { | 55 struct AttributePair { |
54 void set(int index, const SkString& name) { | 56 void set(int index, const SkString& name) { |
55 fIndex = index; fName = name; | 57 fIndex = index; fName = name; |
56 } | 58 } |
57 int fIndex; | 59 int fIndex; |
58 SkString fName; | 60 SkString fName; |
59 }; | 61 }; |
60 | 62 |
61 GrGLShaderVar* fPositionVar; | 63 GrGLShaderVar* fPositionVar; |
62 GrGLShaderVar* fLocalCoordsVar; | 64 GrGLShaderVar* fLocalCoordsVar; |
63 int fEffectAttribOffset; | 65 int fEffectAttribOffset; |
64 | 66 |
65 friend class GrGLProgramBuilder; | |
66 | |
67 typedef GrGLShaderBuilder INHERITED; | 67 typedef GrGLShaderBuilder INHERITED; |
68 }; | 68 }; |
69 | 69 |
70 #endif | 70 #endif |
OLD | NEW |