Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: src/gpu/glsl/GrGLSLShaderBuilder.h

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: changed <iostream> to <ostream> Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderVar.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLShaderBuilder.h
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.h b/src/gpu/glsl/GrGLSLShaderBuilder.h
index a6ff96dd1b08e52540b96bc0507a33da62c3fd1f..f59edb4553b07ffa528549e436286c3d01a00850 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -72,23 +72,27 @@ public:
void appendTexelFetch(SamplerHandle, const char* coordExpr);
/**
- * Adds a #define directive to the top of the shader.
+ * Adds a constant declaration to the top of the shader.
*/
- void define(const char* macro, const char* replacement) {
- this->definitions().appendf("#define %s %s\n", macro, replacement);
+ void defineConstant(const char* type, const char* name, const char* value) {
+ this->definitions().appendf("const %s %s = %s;\n", type, name, value);
}
- void define(const char* macro, int replacement) {
- this->definitions().appendf("#define %s %i\n", macro, replacement);
+ void defineConstant(const char* name, int value) {
+ this->definitions().appendf("const int %s = %i;\n", name, value);
}
- void definef(const char* macro, const char* replacement, ...) {
- this->definitions().appendf("#define %s ", macro);
+ void defineConstant(const char* name, float value) {
+ this->definitions().appendf("const float %s = %f;\n", name, value);
+ }
+
+ void defineConstantf(const char* type, const char* name, const char* fmt, ...) {
+ this->definitions().appendf("const %s %s = ", type, name);
va_list args;
- va_start(args, replacement);
- this->definitions().appendVAList(replacement, args);
+ va_start(args, fmt);
+ this->definitions().appendVAList(fmt, args);
va_end(args);
- this->definitions().append("\n");
+ this->definitions().append(";\n");
}
/**
« no previous file with comments | « src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp ('k') | src/gpu/glsl/GrGLSLShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698