Index: src/effects/SkMagnifierImageFilter.cpp |
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp |
index cb0fc2423f064f445e32c64f4b195f6faf808076..bf6f4a7725f54030abba6eb65a2a16ebad2d4ec6 100644 |
--- a/src/effects/SkMagnifierImageFilter.cpp |
+++ b/src/effects/SkMagnifierImageFilter.cpp |
@@ -16,7 +16,7 @@ |
#if SK_SUPPORT_GPU |
#include "effects/GrSingleTextureEffect.h" |
#include "gl/GrGLEffect.h" |
-#include "gl/GrGLShaderBuilder.h" |
+#include "gl/builders/GrGLProgramBuilder.h" |
#include "gl/GrGLSL.h" |
#include "gl/GrGLTexture.h" |
#include "GrTBackendEffectFactory.h" |
@@ -95,7 +95,7 @@ class GrGLMagnifierEffect : public GrGLEffect { |
public: |
GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
- virtual void emitCode(GrGLShaderBuilder*, |
+ virtual void emitCode(GrGLProgramBuilder*, |
const GrDrawEffect&, |
const GrEffectKey&, |
const char* outputColor, |
@@ -117,57 +117,58 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, |
: INHERITED(factory) { |
} |
-void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder, |
+void GrGLMagnifierEffect::emitCode(GrGLProgramBuilder* builder, |
const GrDrawEffect&, |
const GrEffectKey& key, |
const char* outputColor, |
const char* inputColor, |
const TransformedCoordsArray& coords, |
const TextureSamplerArray& samplers) { |
- SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
fOffsetVar = builder->addUniform( |
- GrGLShaderBuilder::kFragment_Visibility | |
- GrGLShaderBuilder::kVertex_Visibility, |
+ GrGLProgramBuilder::kFragment_Visibility | |
+ GrGLProgramBuilder::kVertex_Visibility, |
kVec2f_GrSLType, "Offset"); |
fInvZoomVar = builder->addUniform( |
- GrGLShaderBuilder::kFragment_Visibility | |
- GrGLShaderBuilder::kVertex_Visibility, |
+ GrGLProgramBuilder::kFragment_Visibility | |
+ GrGLProgramBuilder::kVertex_Visibility, |
kVec2f_GrSLType, "InvZoom"); |
fInvInsetVar = builder->addUniform( |
- GrGLShaderBuilder::kFragment_Visibility | |
- GrGLShaderBuilder::kVertex_Visibility, |
+ GrGLProgramBuilder::kFragment_Visibility | |
+ GrGLProgramBuilder::kVertex_Visibility, |
kVec2f_GrSLType, "InvInset"); |
- builder->fsCodeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); |
- builder->fsCodeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", |
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
+ SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
+ fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); |
+ fsBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n", |
builder->getUniformCStr(fOffsetVar), |
coords2D.c_str(), |
builder->getUniformCStr(fInvZoomVar)); |
- builder->fsCodeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n"); |
+ fsBuilder->codeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n"); |
- builder->fsCodeAppendf("\t\tdelta = delta * %s;\n", builder->getUniformCStr(fInvInsetVar)); |
+ fsBuilder->codeAppendf("\t\tdelta = delta * %s;\n", builder->getUniformCStr(fInvInsetVar)); |
- builder->fsCodeAppend("\t\tfloat weight = 0.0;\n"); |
- builder->fsCodeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n"); |
- builder->fsCodeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n"); |
- builder->fsCodeAppend("\t\t\tfloat dist = length(delta);\n"); |
- builder->fsCodeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n"); |
- builder->fsCodeAppend("\t\t\tweight = min(dist * dist, 1.0);\n"); |
- builder->fsCodeAppend("\t\t} else {\n"); |
- builder->fsCodeAppend("\t\t\tvec2 delta_squared = delta * delta;\n"); |
- builder->fsCodeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n"); |
- builder->fsCodeAppend("\t\t}\n"); |
+ fsBuilder->codeAppend("\t\tfloat weight = 0.0;\n"); |
+ fsBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n"); |
+ fsBuilder->codeAppend("\t\t\tdelta = vec2(2.0, 2.0) - delta;\n"); |
+ fsBuilder->codeAppend("\t\t\tfloat dist = length(delta);\n"); |
+ fsBuilder->codeAppend("\t\t\tdist = max(2.0 - dist, 0.0);\n"); |
+ fsBuilder->codeAppend("\t\t\tweight = min(dist * dist, 1.0);\n"); |
+ fsBuilder->codeAppend("\t\t} else {\n"); |
+ fsBuilder->codeAppend("\t\t\tvec2 delta_squared = delta * delta;\n"); |
+ fsBuilder->codeAppend("\t\t\tweight = min(min(delta_squared.x, delta_squared.y), 1.0);\n"); |
+ fsBuilder->codeAppend("\t\t}\n"); |
- builder->fsCodeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n"); |
- builder->fsCodeAppend("\t\tvec4 output_color = "); |
- builder->fsAppendTextureLookup(samplers[0], "mix_coord"); |
- builder->fsCodeAppend(";\n"); |
+ fsBuilder->codeAppend("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n"); |
+ fsBuilder->codeAppend("\t\tvec4 output_color = "); |
+ fsBuilder->appendTextureLookup(samplers[0], "mix_coord"); |
+ fsBuilder->codeAppend(";\n"); |
- builder->fsCodeAppendf("\t\t%s = output_color;", outputColor); |
+ fsBuilder->codeAppendf("\t\t%s = output_color;", outputColor); |
SkString modulate; |
GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor); |
- builder->fsCodeAppend(modulate.c_str()); |
+ fsBuilder->codeAppend(modulate.c_str()); |
} |
void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman, |