aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrConvolutionEffect.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-02 13:04:56 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-02 13:04:56 +0000
commit77af6805e5faea1e2a5c0220098aec9082f3a6e5 (patch)
treeda604c305177b007bb8a669ab753290143431ca8 /src/gpu/effects/GrConvolutionEffect.cpp
parent693a837082404d212fd9b2c3d2ab65dd269211c9 (diff)
Make GPU coord transforms automatic
Adds a GrCoordTransform class and updates the framework to handle coord transforms similar to how it handles textures with GrTextureAccess. Renames GrGLEffectMatrix to GrGLCoordTransform and slightly repurposes it to be used by the framework instead of effects. R=bsalomon@google.com, robertphillips@google.com Review URL: https://codereview.chromium.org/24853002 git-svn-id: http://skia.googlecode.com/svn/trunk@11569 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/effects/GrConvolutionEffect.cpp')
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 19fed1cfbd..4d16361fe5 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -7,7 +7,6 @@
#include "GrConvolutionEffect.h"
#include "gl/GrGLEffect.h"
-#include "gl/GrGLEffectMatrix.h"
#include "gl/GrGLSL.h"
#include "gl/GrGLTexture.h"
#include "GrTBackendEffectFactory.h"
@@ -24,6 +23,7 @@ public:
EffectKey,
const char* outputColor,
const char* inputColor,
+ const TransformedCoordsArray&,
const TextureSamplerArray&) SK_OVERRIDE;
virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK_OVERRIDE;
@@ -41,15 +41,13 @@ private:
UniformHandle fKernelUni;
UniformHandle fImageIncrementUni;
UniformHandle fBoundsUni;
- GrGLEffectMatrix fEffectMatrix;
typedef GrGLEffect INHERITED;
};
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& factory,
const GrDrawEffect& drawEffect)
- : INHERITED(factory)
- , fEffectMatrix(drawEffect.castEffect<GrConvolutionEffect>().coordsType()) {
+ : INHERITED(factory) {
const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>();
fRadius = c.radius();
fUseBounds = c.useBounds();
@@ -61,9 +59,9 @@ void GrGLConvolutionEffect::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");
if (this->useBounds()) {
@@ -79,7 +77,7 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
- builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords.c_str(), fRadius, imgInc);
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(), fRadius, imgInc);
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
for (int i = 0; i < width; i++) {
@@ -133,7 +131,6 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
}
}
uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
- fEffectMatrix.setData(uman, conv.getMatrix(), drawEffect, conv.texture(0));
}
GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
@@ -145,12 +142,7 @@ GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffe
key |= 0x2;
key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0;
}
- key <<= GrGLEffectMatrix::kKeyBits;
- EffectKey matrixKey = GrGLEffectMatrix::GenKey(conv.getMatrix(),
- drawEffect,
- conv.coordsType(),
- conv.texture(0));
- return key | matrixKey;
+ return key;
}
///////////////////////////////////////////////////////////////////////////////