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

Unified Diff: src/effects/SkDisplacementMapEffect.cpp

Issue 491673002: Initial refactor of shaderbuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 27fc0d3722881ce24f652c393820c5131b2b8929..a1d29bf42791efb31255aedacd2de9b7d1d811ca 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -14,7 +14,7 @@
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "gl/GrGLEffect.h"
-#include "gl/GrGLShaderBuilder.h"
+#include "gl/builders/GrGLProgramBuilder.h"
#include "GrTBackendEffectFactory.h"
#endif
@@ -302,7 +302,7 @@ public:
const GrDrawEffect& drawEffect);
virtual ~GrGLDisplacementMapEffect();
- virtual void emitCode(GrGLShaderBuilder*,
+ virtual void emitCode(GrGLProgramBuilder*,
const GrDrawEffect&,
const GrEffectKey&,
const char* outputColor,
@@ -540,7 +540,7 @@ GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactor
GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
}
-void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
+void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder,
const GrDrawEffect&,
const GrEffectKey& key,
const char* outputColor,
@@ -549,7 +549,7 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
sk_ignore_unused_variable(inputColor);
- fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
+ fScaleUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
kVec2f_GrSLType, "Scale");
const char* scaleUni = builder->getUniformCStr(fScaleUni);
const char* dColor = "dColor";
@@ -559,29 +559,30 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
// a number smaller than that to approximate 0, but
// leave room for 32-bit float GPU rounding errors.
- builder->fsCodeAppendf("\t\tvec4 %s = ", dColor);
- builder->fsAppendTextureLookup(samplers[0], coords[0].c_str(), coords[0].type());
- builder->fsCodeAppend(";\n");
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
+ fsBuilder->codeAppendf("\t\tvec4 %s = ", dColor);
+ fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0].type());
+ fsBuilder->codeAppend(";\n");
// Unpremultiply the displacement
- builder->fsCodeAppendf("\t\t%s.rgb = (%s.a < %s) ? vec3(0.0) : clamp(%s.rgb / %s.a, 0.0, 1.0);",
+ fsBuilder->codeAppendf("\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\tvec2 %s = %s + %s*(%s.",
+ fsBuilder->codeAppendf("\t\tvec2 %s = %s + %s*(%s.",
cCoords, coords[1].c_str(), scaleUni, dColor);
switch (fXChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:
- builder->fsCodeAppend("r");
+ fsBuilder->codeAppend("r");
break;
case SkDisplacementMapEffect::kG_ChannelSelectorType:
- builder->fsCodeAppend("g");
+ fsBuilder->codeAppend("g");
break;
case SkDisplacementMapEffect::kB_ChannelSelectorType:
- builder->fsCodeAppend("b");
+ fsBuilder->codeAppend("b");
break;
case SkDisplacementMapEffect::kA_ChannelSelectorType:
- builder->fsCodeAppend("a");
+ fsBuilder->codeAppend("a");
break;
case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
default:
@@ -590,31 +591,31 @@ void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
switch (fYChannelSelector) {
case SkDisplacementMapEffect::kR_ChannelSelectorType:
- builder->fsCodeAppend("r");
+ fsBuilder->codeAppend("r");
break;
case SkDisplacementMapEffect::kG_ChannelSelectorType:
- builder->fsCodeAppend("g");
+ fsBuilder->codeAppend("g");
break;
case SkDisplacementMapEffect::kB_ChannelSelectorType:
- builder->fsCodeAppend("b");
+ fsBuilder->codeAppend("b");
break;
case SkDisplacementMapEffect::kA_ChannelSelectorType:
- builder->fsCodeAppend("a");
+ fsBuilder->codeAppend("a");
break;
case SkDisplacementMapEffect::kUnknown_ChannelSelectorType:
default:
SkDEBUGFAIL("Unknown Y channel selector");
}
- builder->fsCodeAppend("-vec2(0.5));\t\t");
+ fsBuilder->codeAppend("-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.
- builder->fsCodeAppendf(
+ fsBuilder->codeAppendf(
"bool %s = (%s.x < 0.0) || (%s.y < 0.0) || (%s.x > 1.0) || (%s.y > 1.0);\t\t",
outOfBounds, cCoords, cCoords, cCoords, cCoords);
- builder->fsCodeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds);
- builder->fsAppendTextureLookup(samplers[1], cCoords, coords[1].type());
- builder->fsCodeAppend(";\n");
+ fsBuilder->codeAppendf("%s = %s ? vec4(0.0) : ", outputColor, outOfBounds);
+ fsBuilder->appendTextureLookup(samplers[1], cCoords, coords[1].type());
+ fsBuilder->codeAppend(";\n");
}
void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
« 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