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) { |