Index: src/effects/gradients/SkGradientShader.cpp |
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp |
index e486e08a64b95d46ecf650416cc7efeaf4511e1a..8155b1cc61ae7876749a31202a0a5e26e009fe14 100644 |
--- a/src/effects/gradients/SkGradientShader.cpp |
+++ b/src/effects/gradients/SkGradientShader.cpp |
@@ -910,8 +910,8 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
#include "GrInvariantOutput.h" |
#include "gl/GrGLContext.h" |
#include "glsl/GrGLSLFragmentShaderBuilder.h" |
-#include "glsl/GrGLSLProgramBuilder.h" |
#include "glsl/GrGLSLProgramDataManager.h" |
+#include "glsl/GrGLSLUniformHandler.h" |
#include "SkGr.h" |
GrGLGradientEffect::GrGLGradientEffect() |
@@ -920,31 +920,32 @@ GrGLGradientEffect::GrGLGradientEffect() |
GrGLGradientEffect::~GrGLGradientEffect() { } |
-void GrGLGradientEffect::emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect& ge) { |
+void GrGLGradientEffect::emitUniforms(GrGLSLUniformHandler* uniformHandler, |
+ const GrGradientEffect& ge) { |
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()) { // 2 Color case |
- fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kVec4f_GrSLType, kDefault_GrSLPrecision, |
- "GradientStartColor"); |
- fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kVec4f_GrSLType, kDefault_GrSLPrecision, |
- "GradientEndColor"); |
+ fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kVec4f_GrSLType, kDefault_GrSLPrecision, |
+ "GradientStartColor"); |
+ fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kVec4f_GrSLType, kDefault_GrSLPrecision, |
+ "GradientEndColor"); |
} else if (SkGradientShaderBase::kThree_GpuColorType == ge.getColorType()) { // 3 Color Case |
- fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kVec4f_GrSLType, kDefault_GrSLPrecision, |
- "GradientStartColor"); |
- fColorMidUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kVec4f_GrSLType, kDefault_GrSLPrecision, |
- "GradientMidColor"); |
- fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kVec4f_GrSLType, kDefault_GrSLPrecision, |
- "GradientEndColor"); |
+ fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kVec4f_GrSLType, kDefault_GrSLPrecision, |
+ "GradientStartColor"); |
+ fColorMidUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kVec4f_GrSLType, kDefault_GrSLPrecision, |
+ "GradientMidColor"); |
+ fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kVec4f_GrSLType, kDefault_GrSLPrecision, |
+ "GradientEndColor"); |
} else { // if not a fast case |
- fFSYUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
- kFloat_GrSLType, kDefault_GrSLPrecision, |
- "GradientYCoordFS"); |
+ fFSYUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility, |
+ kFloat_GrSLType, kDefault_GrSLPrecision, |
+ "GradientYCoordFS"); |
} |
} |
@@ -1026,8 +1027,8 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) { |
return key; |
} |
-void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder, |
- GrGLSLFragmentBuilder* fragBuilder, |
+void GrGLGradientEffect::emitColor(GrGLSLFragmentBuilder* fragBuilder, |
+ GrGLSLUniformHandler* uniformHandler, |
const GrGLSLCaps* glslCaps, |
const GrGradientEffect& ge, |
const char* gradientTValue, |
@@ -1036,8 +1037,8 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder, |
const TextureSamplerArray& samplers) { |
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){ |
fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n", |
- builder->getUniformVariable(fColorStartUni).c_str(), |
- builder->getUniformVariable(fColorEndUni).c_str(), |
+ uniformHandler->getUniformVariable(fColorStartUni).c_str(), |
+ uniformHandler->getUniformVariable(fColorEndUni).c_str(), |
gradientTValue); |
// Note that we could skip this step if both colors are known to be opaque. Two |
// considerations: |
@@ -1055,20 +1056,20 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder, |
fragBuilder->codeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n", |
gradientTValue); |
fragBuilder->codeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n", |
- builder->getUniformVariable(fColorStartUni).c_str()); |
+ uniformHandler->getUniformVariable(fColorStartUni).c_str()); |
if (!glslCaps->canUseMinAndAbsTogether()) { |
// The Tegra3 compiler will sometimes never return if we have |
// min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression. |
fragBuilder->codeAppend("\tfloat minAbs = abs(oneMinus2t);\n"); |
fragBuilder->codeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n"); |
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n", |
- builder->getUniformVariable(fColorMidUni).c_str()); |
+ uniformHandler->getUniformVariable(fColorMidUni).c_str()); |
} else { |
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n", |
- builder->getUniformVariable(fColorMidUni).c_str()); |
+ uniformHandler->getUniformVariable(fColorMidUni).c_str()); |
} |
fragBuilder->codeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n", |
- builder->getUniformVariable(fColorEndUni).c_str()); |
+ uniformHandler->getUniformVariable(fColorEndUni).c_str()); |
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) { |
fragBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n"); |
} |
@@ -1078,7 +1079,7 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder, |
} else { |
fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n", |
gradientTValue, |
- builder->getUniformVariable(fFSYUni).c_str()); |
+ uniformHandler->getUniformVariable(fFSYUni).c_str()); |
fragBuilder->codeAppendf("\t%s = ", outputColor); |
fragBuilder->appendTextureLookupAndModulate(inputColor, |
samplers[0], |