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

Unified Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 12547012: Make GrGLEffects use an interface to append their code. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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/gl/GrGLShaderBuilder.h ('k') | src/ports/SkDebug_stdio.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLShaderBuilder.cpp
===================================================================
--- src/gpu/gl/GrGLShaderBuilder.cpp (revision 8005)
+++ src/gpu/gl/GrGLShaderBuilder.cpp (working copy)
@@ -101,6 +101,42 @@
fPositionVar->set(kVec2f_GrSLType, GrGLShaderVar::kAttribute_TypeModifier, "aPosition");
}
+void GrGLShaderBuilder::codeAppendf(ShaderType type, const char format[], va_list args) {
+ SkString* string;
+ switch (type) {
+ case kVertex_ShaderType:
+ string = &fVSCode;
+ break;
+ case kGeometry_ShaderType:
+ string = &fGSCode;
+ break;
+ case kFragment_ShaderType:
+ string = &fFSCode;
+ break;
+ default:
+ GrCrash("Invalid shader type");
+ }
+ string->appendf(format, args);
+}
+
+void GrGLShaderBuilder::codeAppend(ShaderType type, const char* str) {
+ SkString* string;
+ switch (type) {
+ case kVertex_ShaderType:
+ string = &fVSCode;
+ break;
+ case kGeometry_ShaderType:
+ string = &fGSCode;
+ break;
+ case kFragment_ShaderType:
+ string = &fFSCode;
+ break;
+ default:
+ GrCrash("Invalid shader type");
+ }
+ string->append(str);
+}
+
void GrGLShaderBuilder::appendTextureLookup(SkString* out,
const GrGLShaderBuilder::TextureSampler& sampler,
const char* coordName,
@@ -115,16 +151,24 @@
append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
}
+void GrGLShaderBuilder::appendTextureLookup(ShaderType type,
+ const GrGLShaderBuilder::TextureSampler& sampler,
+ const char* coordName,
+ GrSLType varyingType) {
+ GrAssert(kFragment_ShaderType == type);
+ this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType);
+}
+
void GrGLShaderBuilder::appendTextureLookupAndModulate(
- SkString* out,
+ ShaderType type,
const char* modulation,
const GrGLShaderBuilder::TextureSampler& sampler,
const char* coordName,
- GrSLType varyingType) const {
- GrAssert(NULL != out);
+ GrSLType varyingType) {
+ GrAssert(kFragment_ShaderType == type);
SkString lookup;
this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
- GrGLSLModulate4f(out, modulation, lookup.c_str());
+ GrGLSLModulate4f(&fFSCode, modulation, lookup.c_str());
}
GrBackendEffectFactory::EffectKey GrGLShaderBuilder::KeyForTextureAccess(
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | src/ports/SkDebug_stdio.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698