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

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

Issue 1660813002: Add #define directives to GrGLSLShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: kDefinitions ordering Created 4 years, 10 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 | « no previous file | no next file » | 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 16a07563060c58b087826b89220eed5f3c939557..5c3408e704420ed55f5c55f469e5240d37c49319 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.h
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.h
@@ -60,6 +60,26 @@ public:
GrSLType coordType = kVec2f_GrSLType);
/**
+ * Adds a #define directive to the top of the shader.
+ */
+ void define(const char* macro, const char* replacement) {
+ this->definitions().appendf("#define %s %s\n", macro, replacement);
+ }
+
+ void define(const char* macro, int replacement) {
+ this->definitions().appendf("#define %s %i\n", macro, replacement);
+ }
+
+ void definef(const char* macro, const char* replacement, ...) {
+ this->definitions().appendf("#define %s ", macro);
+ va_list args;
+ va_start(args, replacement);
+ this->definitions().appendVAList(replacement, args);
+ va_end(args);
+ this->definitions().append("\n");
+ }
+
+ /**
* Called by GrGLSLProcessors to add code to one of the shaders.
*/
void codeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) {
@@ -152,6 +172,7 @@ protected:
SkString& versionDecl() { return fShaderStrings[kVersionDecl]; }
SkString& extensions() { return fShaderStrings[kExtensions]; }
+ SkString& definitions() { return fShaderStrings[kDefinitions]; }
SkString& precisionQualifier() { return fShaderStrings[kPrecisionQualifier]; }
SkString& layoutQualifiers() { return fShaderStrings[kLayoutQualifiers]; }
SkString& uniforms() { return fShaderStrings[kUniforms]; }
@@ -166,6 +187,7 @@ protected:
enum {
kVersionDecl,
kExtensions,
+ kDefinitions,
kPrecisionQualifier,
kLayoutQualifiers,
kUniforms,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698