Add #define directives to GrGLSLShaderBuilder

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1660813002

Review URL: https://codereview.chromium.org/1660813002
This commit is contained in:
cdalton 2016-02-11 14:10:38 -08:00 committed by Commit bot
parent 9b9497ef14
commit d36f2c4bc0

View File

@ -59,6 +59,26 @@ public:
const char* coordName,
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.
*/
@ -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,