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 GrGLShaderBuilder_DEFINED | 8 #ifndef GrGLShaderBuilder_DEFINED |
9 #define GrGLShaderBuilder_DEFINED | 9 #define GrGLShaderBuilder_DEFINED |
10 | 10 |
11 #include "gl/GrGLProgramDesc.h" | 11 #include "gl/GrGLProgramDesc.h" |
12 #include "gl/GrGLProgramEffects.h" | 12 #include "gl/GrGLProgramEffects.h" |
13 #include "gl/GrGLSL.h" | 13 #include "gl/GrGLSL.h" |
14 #include "gl/GrGLProgramDataManager.h" | 14 #include "gl/GrGLProgramDataManager.h" |
15 #include "GrBackendEffectFactory.h" | 15 #include "GrBackendProcessorFactory.h" |
16 #include "GrColor.h" | 16 #include "GrColor.h" |
17 #include "GrEffect.h" | 17 #include "GrProcessor.h" |
18 #include "SkTypes.h" | 18 #include "SkTypes.h" |
19 | 19 |
20 #include <stdarg.h> | 20 #include <stdarg.h> |
21 | 21 |
22 class GrGLContextInfo; | 22 class GrGLContextInfo; |
23 class GrEffectStage; | 23 class GrProcessorStage; |
24 class GrGLProgramDesc; | 24 class GrGLProgramDesc; |
25 class GrGLProgramBuilder; | 25 class GrGLProgramBuilder; |
26 class GrGLFullProgramBuilder; | 26 class GrGLFullProgramBuilder; |
27 | 27 |
28 /** | 28 /** |
29 base class for all shaders builders | 29 base class for all shaders builders |
30 */ | 30 */ |
31 class GrGLShaderBuilder { | 31 class GrGLShaderBuilder { |
32 public: | 32 public: |
33 typedef GrGLEffect::TransformedCoordsArray TransformedCoordsArray; | 33 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; |
34 typedef GrGLEffect::TextureSampler TextureSampler; | 34 typedef GrGLProcessor::TextureSampler TextureSampler; |
35 GrGLShaderBuilder(GrGLProgramBuilder* program); | 35 GrGLShaderBuilder(GrGLProgramBuilder* program); |
36 | 36 |
37 void addInput(GrGLShaderVar i) { fInputs.push_back(i); } | 37 void addInput(GrGLShaderVar i) { fInputs.push_back(i); } |
38 void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); } | 38 void addOutput(GrGLShaderVar i) { fOutputs.push_back(i); } |
39 | 39 |
40 /* | 40 /* |
41 * We put texture lookups in the base class because it is TECHNICALLY possib
le to do texture | 41 * We put texture lookups in the base class because it is TECHNICALLY possib
le to do texture |
42 * lookups in any kind of shader. However, for the time being using these c
alls on non-fragment | 42 * lookups in any kind of shader. However, for the time being using these c
alls on non-fragment |
43 * shaders will result in a shader compilation error as texture sampler unif
orms are only | 43 * shaders will result in a shader compilation error as texture sampler unif
orms are only |
44 * visible to the fragment shader. It would not be hard to change this beha
vior, if someone | 44 * visible to the fragment shader. It would not be hard to change this beha
vior, if someone |
(...skipping 23 matching lines...) Expand all Loading... |
68 void appendTextureLookupAndModulate(const char* modulation, | 68 void appendTextureLookupAndModulate(const char* modulation, |
69 const TextureSampler&, | 69 const TextureSampler&, |
70 const char* coordName, | 70 const char* coordName, |
71 GrSLType coordType = kVec2f_GrSLType); | 71 GrSLType coordType = kVec2f_GrSLType); |
72 | 72 |
73 /** If texture swizzling is available using tex parameters then it is prefer
red over mangling | 73 /** If texture swizzling is available using tex parameters then it is prefer
red over mangling |
74 the generated shader code. This potentially allows greater reuse of cach
ed shaders. */ | 74 the generated shader code. This potentially allows greater reuse of cach
ed shaders. */ |
75 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa
ps& caps); | 75 static const GrGLenum* GetTexParamSwizzle(GrPixelConfig config, const GrGLCa
ps& caps); |
76 | 76 |
77 /** | 77 /** |
78 * Called by GrGLEffects to add code to one of the shaders. | 78 * Called by GrGLProcessors to add code to one of the shaders. |
79 */ | 79 */ |
80 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { | 80 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
81 va_list args; | 81 va_list args; |
82 va_start(args, format); | 82 va_start(args, format); |
83 fCode.appendVAList(format, args); | 83 fCode.appendVAList(format, args); |
84 va_end(args); | 84 va_end(args); |
85 } | 85 } |
86 | 86 |
87 void codeAppend(const char* str) { fCode.append(str); } | 87 void codeAppend(const char* str) { fCode.append(str); } |
88 | 88 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 public: | 165 public: |
166 GrGLFullShaderBuilder(GrGLFullProgramBuilder* program); | 166 GrGLFullShaderBuilder(GrGLFullProgramBuilder* program); |
167 | 167 |
168 GrGLFullProgramBuilder* fullProgramBuilder() { return fFullProgramBuilder; } | 168 GrGLFullProgramBuilder* fullProgramBuilder() { return fFullProgramBuilder; } |
169 protected: | 169 protected: |
170 GrGLFullProgramBuilder* fFullProgramBuilder; | 170 GrGLFullProgramBuilder* fFullProgramBuilder; |
171 private: | 171 private: |
172 typedef GrGLShaderBuilder INHERITED; | 172 typedef GrGLShaderBuilder INHERITED; |
173 }; | 173 }; |
174 #endif | 174 #endif |
OLD | NEW |