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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.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/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMatrixConvolutionImageFilter.cpp
===================================================================
--- src/effects/SkMatrixConvolutionImageFilter.cpp (revision 8005)
+++ src/effects/SkMatrixConvolutionImageFilter.cpp (working copy)
@@ -365,7 +365,6 @@
const GrGLShaderBuilder::TextureSampler& sampler,
const char* coord,
SkMatrixConvolutionImageFilter::TileMode tileMode) {
- SkString* code = &builder->fFSCode;
SkString clampedCoord;
switch (tileMode) {
case SkMatrixConvolutionImageFilter::kClamp_TileMode:
@@ -377,10 +376,10 @@
coord = clampedCoord.c_str();
break;
case SkMatrixConvolutionImageFilter::kClampToBlack_TileMode:
- code->appendf("clamp(%s, 0.0, 1.0) != %s ? vec4(0, 0, 0, 0) : ", coord, coord);
+ builder->fsCodeAppendf("clamp(%s, 0.0, 1.0) != %s ? vec4(0, 0, 0, 0) : ", coord, coord);
break;
}
- builder->appendTextureLookup(code, sampler, coord);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, sampler, coord);
}
void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
@@ -403,8 +402,6 @@
fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kFloat_GrSLType, "Bias");
- SkString* code = &builder->fFSCode;
-
const char* target = builder->getUniformCStr(fTargetUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
const char* kernel = builder->getUniformCStr(fKernelUni);
@@ -413,31 +410,31 @@
int kWidth = fKernelSize.width();
int kHeight = fKernelSize.height();
- code->appendf("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
- code->appendf("\t\tvec2 coord = %s - %s * %s;\n", coords, target, imgInc);
- code->appendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight);
- code->appendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth);
- code->appendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth);
- code->appendf("\t\t\t\tvec2 coord2 = coord + vec2(x, y) * %s;\n", imgInc);
- code->appendf("\t\t\t\tvec4 c = ");
+ builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords, target, imgInc);
+ builder->fsCodeAppendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight);
+ builder->fsCodeAppendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth);
+ builder->fsCodeAppendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth);
+ builder->fsCodeAppendf("\t\t\t\tvec2 coord2 = coord + vec2(x, y) * %s;\n", imgInc);
+ builder->fsCodeAppend("\t\t\t\tvec4 c = ");
appendTextureLookup(builder, samplers[0], "coord2", fTileMode);
- code->appendf(";\n");
+ builder->fsCodeAppend(";\n");
if (!fConvolveAlpha) {
- code->appendf("\t\t\t\tc.rgb /= c.a;\n");
+ builder->fsCodeAppend("\t\t\t\tc.rgb /= c.a;\n");
}
- code->appendf("\t\t\t\tsum += c * k;\n");
- code->appendf("\t\t\t}\n");
- code->appendf("\t\t}\n");
+ builder->fsCodeAppend("\t\t\t\tsum += c * k;\n");
+ builder->fsCodeAppend("\t\t\t}\n");
+ builder->fsCodeAppend("\t\t}\n");
if (fConvolveAlpha) {
- code->appendf("\t\t%s = sum * %s + %s;\n", outputColor, gain, bias);
- code->appendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", outputColor, outputColor, outputColor);
+ builder->fsCodeAppendf("\t\t%s = sum * %s + %s;\n", outputColor, gain, bias);
+ builder->fsCodeAppendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", outputColor, outputColor, outputColor);
} else {
- code->appendf("\t\tvec4 c = ");
+ builder->fsCodeAppend("\t\tvec4 c = ");
appendTextureLookup(builder, samplers[0], coords, fTileMode);
- code->appendf(";\n");
- code->appendf("\t\t%s.a = c.a;\n", outputColor);
- code->appendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor, gain, bias);
- code->appendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ builder->fsCodeAppend(";\n");
+ builder->fsCodeAppendf("\t\t%s.a = c.a;\n", outputColor);
+ builder->fsCodeAppendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor, gain, bias);
+ builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
}
« no previous file with comments | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698