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

Unified Diff: src/effects/SkDisplacementMapEffect.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/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkDisplacementMapEffect.cpp
===================================================================
--- src/effects/SkDisplacementMapEffect.cpp (revision 8005)
+++ src/effects/SkDisplacementMapEffect.cpp (working copy)
@@ -409,36 +409,38 @@
GrSLType cCoordsType = fColorEffectMatrix.emitCode(
builder, key, vertexCoords, &cCoordsIn, NULL, "COLOR");
- SkString* code = &builder->fFSCode;
const char* dColor = "dColor";
const char* cCoords = "cCoords";
const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half float, use
// a number smaller than that to approximate 0, but
// leave room for 32-bit float GPU rounding errors.
- code->appendf("\t\tvec4 %s = ", dColor);
- builder->appendTextureLookup(code, samplers[0], dCoordsIn, dCoordsType);
- code->append(";\n");
+ builder->fsCodeAppendf("\t\tvec4 %s = ", dColor);
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
+ samplers[0],
+ dCoordsIn,
+ dCoordsType);
+ builder->fsCodeAppend(";\n");
// Unpremultiply the displacement
- code->appendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
- dColor, dColor, nearZero, dColor, dColor);
+ builder->fsCodeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
+ dColor, dColor, nearZero, dColor, dColor);
- code->appendf("\t\tvec2 %s = %s + %s*(%s.",
- cCoords, cCoordsIn, scaleUni, dColor);
+ builder->fsCodeAppendf("\t\tvec2 %s = %s + %s*(%s.",
+ cCoords, cCoordsIn, scaleUni, dColor);
switch (fXChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:
- code->append("r");
+ builder->fsCodeAppend("r");
break;
case SkDisplacementMapEffect::kG_ChannelSelectorType:
- code->append("g");
+ builder->fsCodeAppend("g");
break;
case SkDisplacementMapEffect::kB_ChannelSelectorType:
- code->append("b");
+ builder->fsCodeAppend("b");
break;
case SkDisplacementMapEffect::kA_ChannelSelectorType:
- code->append("a");
+ builder->fsCodeAppend("a");
break;
case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
default:
@@ -447,30 +449,33 @@
switch (fYChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:
- code->append("r");
+ builder->fsCodeAppend("r");
break;
case SkDisplacementMapEffect::kG_ChannelSelectorType:
- code->append("g");
+ builder->fsCodeAppend("g");
break;
case SkDisplacementMapEffect::kB_ChannelSelectorType:
- code->append("b");
+ builder->fsCodeAppend("b");
break;
case SkDisplacementMapEffect::kA_ChannelSelectorType:
- code->append("a");
+ builder->fsCodeAppend("a");
break;
case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
default:
SkASSERT(!"Unknown Y channel selector");
}
- code->append("-vec2(0.5));\t\t");
+ builder->fsCodeAppend("-vec2(0.5));\t\t");
// FIXME : This can be achieved with a "clamp to border" texture repeat mode and
// a 0 border color instead of computing if cCoords is out of bounds here.
- code->appendf(
+ builder->fsCodeAppendf(
"%s = any(greaterThan(vec4(vec2(0.0), %s), vec4(%s, vec2(1.0)))) ? vec4(0.0) : ",
outputColor, cCoords, cCoords);
- builder->appendTextureLookup(code, samplers[1], cCoords, cCoordsType);
- code->append(";\n");
+ builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType,
+ samplers[1],
+ cCoords,
+ cCoordsType);
+ builder->fsCodeAppend(";\n");
}
void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) {
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698