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 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord
Expr must match the | 66 /** Fetches an unfiltered texel from a sampler at integer coordinates. coord
Expr must match the |
67 dimensionality of the sampler and must be within the sampler's range. co
ordExpr is emitted | 67 dimensionality of the sampler and must be within the sampler's range. co
ordExpr is emitted |
68 exactly once, so expressions like "idx++" are acceptable. */ | 68 exactly once, so expressions like "idx++" are acceptable. */ |
69 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c
onst; | 69 void appendTexelFetch(SkString* out, SamplerHandle, const char* coordExpr) c
onst; |
70 | 70 |
71 /** Version of above that appends the result to the shader code instead.*/ | 71 /** Version of above that appends the result to the shader code instead.*/ |
72 void appendTexelFetch(SamplerHandle, const char* coordExpr); | 72 void appendTexelFetch(SamplerHandle, const char* coordExpr); |
73 | 73 |
74 /** | 74 /** |
75 * Adds a constant declaration to the top of the shader. | 75 * Adds a #define directive to the top of the shader. |
76 */ | 76 */ |
77 void defineConstant(const char* type, const char* name, const char* value) { | 77 void define(const char* macro, const char* replacement) { |
78 this->definitions().appendf("const %s %s = %s;\n", type, name, value); | 78 this->definitions().appendf("#define %s %s\n", macro, replacement); |
79 } | 79 } |
80 | 80 |
81 void defineConstant(const char* name, int value) { | 81 void define(const char* macro, int replacement) { |
82 this->definitions().appendf("const int %s = %i;\n", name, value); | 82 this->definitions().appendf("#define %s %i\n", macro, replacement); |
83 } | 83 } |
84 | 84 |
85 void defineConstant(const char* name, float value) { | 85 void definef(const char* macro, const char* replacement, ...) { |
86 this->definitions().appendf("const float %s = %f;\n", name, value); | 86 this->definitions().appendf("#define %s ", macro); |
87 } | |
88 | |
89 void defineConstantf(const char* type, const char* name, const char* fmt, ..
.) { | |
90 this->definitions().appendf("const %s %s = ", type, name); | |
91 va_list args; | 87 va_list args; |
92 va_start(args, fmt); | 88 va_start(args, replacement); |
93 this->definitions().appendVAList(fmt, args); | 89 this->definitions().appendVAList(replacement, args); |
94 va_end(args); | 90 va_end(args); |
95 this->definitions().append(";\n"); | 91 this->definitions().append("\n"); |
96 } | 92 } |
97 | 93 |
98 /** | 94 /** |
99 * Called by GrGLSLProcessors to add code to one of the shaders. | 95 * Called by GrGLSLProcessors to add code to one of the shaders. |
100 */ | 96 */ |
101 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { | 97 void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { |
102 va_list args; | 98 va_list args; |
103 va_start(args, format); | 99 va_start(args, format); |
104 this->code().appendVAList(format, args); | 100 this->code().appendVAList(format, args); |
105 va_end(args); | 101 va_end(args); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 int fCodeIndex; | 254 int fCodeIndex; |
259 bool fFinalized; | 255 bool fFinalized; |
260 | 256 |
261 friend class GrGLSLProgramBuilder; | 257 friend class GrGLSLProgramBuilder; |
262 friend class GrGLProgramBuilder; | 258 friend class GrGLProgramBuilder; |
263 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. | 259 friend class GrGLSLVaryingHandler; // to access noperspective interpolation
feature. |
264 friend class GrGLPathProgramBuilder; // to access fInputs. | 260 friend class GrGLPathProgramBuilder; // to access fInputs. |
265 friend class GrVkPipelineStateBuilder; | 261 friend class GrVkPipelineStateBuilder; |
266 }; | 262 }; |
267 #endif | 263 #endif |
OLD | NEW |