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

Unified Diff: src/effects/gradients/SkGradientShader.cpp

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 years 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/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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],
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698