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

Unified Diff: src/effects/SkTableColorFilter.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/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkTableColorFilter.cpp
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 54e1efe5501a21c45693dbf5b6cdad642df4e104..8b391eebf4d1ac6fac29b60e4ebcea63b373795c 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -278,7 +278,7 @@ bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const {
#include "GrEffect.h"
#include "GrTBackendEffectFactory.h"
#include "gl/GrGLEffect.h"
-#include "gl/GrGLShaderBuilder.h"
+#include "gl/builders/GrGLProgramBuilder.h"
#include "SkGr.h"
class GLColorTableEffect;
@@ -316,7 +316,7 @@ class GLColorTableEffect : public GrGLEffect {
public:
GLColorTableEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
- virtual void emitCode(GrGLShaderBuilder*,
+ virtual void emitCode(GrGLProgramBuilder*,
const GrDrawEffect&,
const GrEffectKey&,
const char* outputColor,
@@ -337,7 +337,7 @@ GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, co
: INHERITED(factory) {
}
-void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
+void GLColorTableEffect::emitCode(GrGLProgramBuilder* builder,
const GrDrawEffect&,
const GrEffectKey&,
const char* outputColor,
@@ -347,38 +347,39 @@ void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
static const float kColorScaleFactor = 255.0f / 256.0f;
static const float kColorOffsetFactor = 1.0f / 512.0f;
+ GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
if (NULL == inputColor) {
// the input color is solid white (all ones).
static const float kMaxValue = kColorScaleFactor + kColorOffsetFactor;
- builder->fsCodeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
+ fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%f, %f, %f, %f);\n",
kMaxValue, kMaxValue, kMaxValue, kMaxValue);
} else {
- builder->fsCodeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", inputColor);
- builder->fsCodeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n", inputColor);
- builder->fsCodeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
+ fsBuilder->codeAppendf("\t\tfloat nonZeroAlpha = max(%s.a, .0001);\n", inputColor);
+ fsBuilder->codeAppendf("\t\tvec4 coord = vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha);\n", inputColor);
+ fsBuilder->codeAppendf("\t\tcoord = coord * %f + vec4(%f, %f, %f, %f);\n",
kColorScaleFactor,
kColorOffsetFactor, kColorOffsetFactor,
kColorOffsetFactor, kColorOffsetFactor);
}
- builder->fsCodeAppendf("\t\t%s.a = ", outputColor);
- builder->fsAppendTextureLookup(samplers[0], "vec2(coord.a, 0.125)");
- builder->fsCodeAppend(";\n");
+ fsBuilder->codeAppendf("\t\t%s.a = ", outputColor);
+ fsBuilder->appendTextureLookup(samplers[0], "vec2(coord.a, 0.125)");
+ fsBuilder->codeAppend(";\n");
- builder->fsCodeAppendf("\t\t%s.r = ", outputColor);
- builder->fsAppendTextureLookup(samplers[0], "vec2(coord.r, 0.375)");
- builder->fsCodeAppend(";\n");
+ fsBuilder->codeAppendf("\t\t%s.r = ", outputColor);
+ fsBuilder->appendTextureLookup(samplers[0], "vec2(coord.r, 0.375)");
+ fsBuilder->codeAppend(";\n");
- builder->fsCodeAppendf("\t\t%s.g = ", outputColor);
- builder->fsAppendTextureLookup(samplers[0], "vec2(coord.g, 0.625)");
- builder->fsCodeAppend(";\n");
+ fsBuilder->codeAppendf("\t\t%s.g = ", outputColor);
+ fsBuilder->appendTextureLookup(samplers[0], "vec2(coord.g, 0.625)");
+ fsBuilder->codeAppend(";\n");
- builder->fsCodeAppendf("\t\t%s.b = ", outputColor);
- builder->fsAppendTextureLookup(samplers[0], "vec2(coord.b, 0.875)");
- builder->fsCodeAppend(";\n");
+ fsBuilder->codeAppendf("\t\t%s.b = ", outputColor);
+ fsBuilder->appendTextureLookup(samplers[0], "vec2(coord.b, 0.875)");
+ fsBuilder->codeAppend(";\n");
- builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
+ fsBuilder->codeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698