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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.cpp

Issue 24853002: Make GPU coord transforms automatic (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 3 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/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMatrixConvolutionImageFilter.cpp
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 9446b8ee194c7591e7f483be732c83e7070832b0..d73f6335d74c7a1f13b8ee15985a7337041b68c1 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -14,7 +14,6 @@
#if SK_SUPPORT_GPU
#include "gl/GrGLEffect.h"
-#include "gl/GrGLEffectMatrix.h"
#include "effects/GrSingleTextureEffect.h"
#include "GrTBackendEffectFactory.h"
#include "GrTexture.h"
@@ -324,6 +323,7 @@ public:
EffectKey,
const char* outputColor,
const char* inputColor,
+ const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
@@ -343,15 +343,12 @@ private:
UniformHandle fGainUni;
UniformHandle fBiasUni;
- GrGLEffectMatrix fEffectMatrix;
-
typedef GrGLEffect INHERITED;
};
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
const GrDrawEffect& drawEffect)
- : INHERITED(factory)
- , fEffectMatrix(drawEffect.castEffect<GrMatrixConvolutionEffect>().coordsType()) {
+ : INHERITED(factory) {
const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
fKernelSize = m.kernelSize();
fTileMode = m.tileMode();
@@ -384,9 +381,9 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
EffectKey key,
const char* outputColor,
const char* inputColor,
+ const TransformedCoordsArray& coords,
const TextureSamplerArray& samplers) {
- SkString coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
+ SkString coords2D = builder->ensureFSCoords2D(coords, 0);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
kVec2f_GrSLType, "ImageIncrement");
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility,
@@ -407,7 +404,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
int kHeight = fKernelSize.height();
builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
- builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords.c_str(), target, imgInc);
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords2D.c_str(), target, imgInc);
builder->fsCodeAppendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight);
builder->fsCodeAppendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth);
builder->fsCodeAppendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth);
@@ -426,7 +423,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppendf("\t\t%s.rgb = clamp(%s.rgb, 0.0, %s.a);\n", outputColor, outputColor, outputColor);
} else {
builder->fsCodeAppend("\t\tvec4 c = ");
- appendTextureLookup(builder, samplers[0], coords.c_str(), fTileMode);
+ appendTextureLookup(builder, samplers[0], coords2D.c_str(), fTileMode);
builder->fsCodeAppend(";\n");
builder->fsCodeAppendf("\t\t%s.a = c.a;\n", outputColor);
builder->fsCodeAppendf("\t\t%s.rgb = sum.rgb * %s + %s;\n", outputColor, gain, bias);
@@ -452,12 +449,7 @@ GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& dr
EffectKey key = encodeXY(m.kernelSize().width(), m.kernelSize().height());
key |= m.tileMode() << 7;
key |= m.convolveAlpha() ? 1 << 9 : 0;
- key <<= GrGLEffectMatrix::kKeyBits;
- EffectKey matrixKey = GrGLEffectMatrix::GenKey(m.getMatrix(),
- drawEffect,
- m.coordsType(),
- m.texture(0));
- return key | matrixKey;
+ return key;
}
void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
@@ -476,10 +468,6 @@ void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), conv.kernel());
uman.set1f(fGainUni, conv.gain());
uman.set1f(fBiasUni, conv.bias());
- fEffectMatrix.setData(uman,
- conv.getMatrix(),
- drawEffect,
- conv.texture(0));
}
GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
« no previous file with comments | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698