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 GrGLSLShaderBuilder_DEFINED | 8 #ifndef GrGLSLShaderBuilder_DEFINED |
9 #define GrGLSLShaderBuilder_DEFINED | 9 #define GrGLSLShaderBuilder_DEFINED |
10 | 10 |
11 #include "GrAllocator.h" | 11 #include "GrAllocator.h" |
12 #include "glsl/GrGLSLShaderVar.h" | 12 #include "glsl/GrGLSLShaderVar.h" |
13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
14 | 14 |
15 #include <stdarg.h> | 15 #include <stdarg.h> |
16 | 16 |
17 class GrGLSLProgramBuilder; | 17 class GrGLSLProgramBuilder; |
18 class GrGLSLTextureSampler; | 18 class GrGLSLSampler; |
19 | 19 |
20 /** | 20 /** |
21 base class for all shaders builders | 21 base class for all shaders builders |
22 */ | 22 */ |
23 class GrGLSLShaderBuilder { | 23 class GrGLSLShaderBuilder { |
24 public: | 24 public: |
25 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); | 25 GrGLSLShaderBuilder(GrGLSLProgramBuilder* program); |
26 virtual ~GrGLSLShaderBuilder() {} | 26 virtual ~GrGLSLShaderBuilder() {} |
27 | 27 |
28 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or | 28 /** Appends a 2D texture sample with projection if necessary. coordType must
either be Vec2f or |
29 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle | 29 Vec3f. The latter is interpreted as projective texture coords. The vec l
ength and swizzle |
30 order of the result depends on the GrTextureAccess associated with the G
rGLSLTextureSampler. | 30 order of the result depends on the GrTextureAccess associated with the G
rGLSLSampler. |
31 */ | 31 */ |
32 void appendTextureLookup(SkString* out, | 32 void appendTextureLookup(SkString* out, |
33 const GrGLSLTextureSampler&, | 33 const GrGLSLSampler&, |
34 const char* coordName, | 34 const char* coordName, |
35 GrSLType coordType = kVec2f_GrSLType) const; | 35 GrSLType coordType = kVec2f_GrSLType) const; |
36 | 36 |
37 /** Version of above that appends the result to the fragment shader code ins
tead.*/ | 37 /** Version of above that appends the result to the fragment shader code ins
tead.*/ |
38 void appendTextureLookup(const GrGLSLTextureSampler&, | 38 void appendTextureLookup(const GrGLSLSampler&, |
39 const char* coordName, | 39 const char* coordName, |
40 GrSLType coordType = kVec2f_GrSLType); | 40 GrSLType coordType = kVec2f_GrSLType); |
41 | 41 |
42 | 42 |
43 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is | 43 /** Does the work of appendTextureLookup and modulates the result by modulat
ion. The result is |
44 always a vec4. modulation and the swizzle specified by GrGLSLTextureSamp
ler must both be | 44 always a vec4. modulation and the swizzle specified by GrGLSLSampler mus
t both be |
45 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough | 45 vec4 or float. If modulation is "" or nullptr it this function acts as t
hough |
46 appendTextureLookup were called. */ | 46 appendTextureLookup were called. */ |
47 void appendTextureLookupAndModulate(const char* modulation, | 47 void appendTextureLookupAndModulate(const char* modulation, |
48 const GrGLSLTextureSampler&, | 48 const GrGLSLSampler&, |
49 const char* coordName, | 49 const char* coordName, |
50 GrSLType coordType = kVec2f_GrSLType); | 50 GrSLType coordType = kVec2f_GrSLType); |
51 | 51 |
52 /** | 52 /** |
53 * Adds a #define directive to the top of the shader. | 53 * Adds a #define directive to the top of the shader. |
54 */ | 54 */ |
55 void define(const char* macro, const char* replacement) { | 55 void define(const char* macro, const char* replacement) { |
56 this->definitions().appendf("#define %s %s\n", macro, replacement); | 56 this->definitions().appendf("#define %s %s\n", macro, replacement); |
57 } | 57 } |
58 | 58 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 int fCodeIndex; | 220 int fCodeIndex; |
221 bool fFinalized; | 221 bool fFinalized; |
222 | 222 |
223 friend class GrGLSLProgramBuilder; | 223 friend class GrGLSLProgramBuilder; |
224 friend class GrGLProgramBuilder; | 224 friend class GrGLProgramBuilder; |
225 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. | 225 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. |
226 friend class GrGLPathProgramBuilder; // to access fInputs. | 226 friend class GrGLPathProgramBuilder; // to access fInputs. |
227 friend class GrVkPipelineStateBuilder; | 227 friend class GrVkPipelineStateBuilder; |
228 }; | 228 }; |
229 #endif | 229 #endif |
OLD | NEW |