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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.cpp

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
===================================================================
--- src/effects/SkMatrixConvolutionImageFilter.cpp (revision 8241)
+++ src/effects/SkMatrixConvolutionImageFilter.cpp (working copy)
@@ -284,8 +284,6 @@
typedef GrGLMatrixConvolutionEffect GLEffect;
-
-
virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
private:
@@ -316,18 +314,17 @@
class GrGLMatrixConvolutionEffect : public GrGLEffect {
public:
GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffectRef& effect);
+ const GrDrawEffect& effect);
virtual void emitCode(GrGLShaderBuilder*,
- const GrEffectStage&,
+ const GrDrawEffect&,
EffectKey,
- const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&);
+ static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
- virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
private:
typedef GrGLUniformManager::UniformHandle UniformHandle;
@@ -348,14 +345,15 @@
};
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
- const GrEffectRef& effect)
+ const GrDrawEffect& drawEffect)
: INHERITED(factory)
, fKernelUni(GrGLUniformManager::kInvalidUniformHandle)
, fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle)
, fTargetUni(GrGLUniformManager::kInvalidUniformHandle)
, fGainUni(GrGLUniformManager::kInvalidUniformHandle)
- , fBiasUni(GrGLUniformManager::kInvalidUniformHandle) {
- const GrMatrixConvolutionEffect& m = CastEffect<GrMatrixConvolutionEffect>(effect);
+ , fBiasUni(GrGLUniformManager::kInvalidUniformHandle)
+ , fEffectMatrix(drawEffect.castEffect<GrMatrixConvolutionEffect>().coordsType()) {
+ const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
fKernelSize = m.kernelSize();
fTileMode = m.tileMode();
fConvolveAlpha = m.convolveAlpha();
@@ -383,14 +381,13 @@
}
void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
- const GrEffectStage&,
+ const GrDrawEffect&,
EffectKey key,
- const char* vertexCoords,
const char* outputColor,
const char* inputColor,
const TextureSamplerArray& samplers) {
const char* coords;
- fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, vertexCoords, &coords);
+ fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
@@ -450,38 +447,40 @@
};
-GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) {
- const GrMatrixConvolutionEffect& m = GetEffectFromStage<GrMatrixConvolutionEffect>(s);
+GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
+ const GrGLCaps&) {
+ const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
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(),
- s.getCoordChangeMatrix(),
+ drawEffect,
+ m.coordsType(),
m.texture(0));
return key | matrixKey;
}
void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
- const GrEffectStage& stage) {
- const GrMatrixConvolutionEffect& effect = GetEffectFromStage<GrMatrixConvolutionEffect>(stage);
- GrTexture& texture = *effect.texture(0);
+ const GrDrawEffect& drawEffect) {
+ const GrMatrixConvolutionEffect& conv = drawEffect.castEffect<GrMatrixConvolutionEffect>();
+ GrTexture& texture = *conv.texture(0);
// the code we generated was for a specific kernel size
- GrAssert(effect.kernelSize() == fKernelSize);
- GrAssert(effect.tileMode() == fTileMode);
+ GrAssert(conv.kernelSize() == fKernelSize);
+ GrAssert(conv.tileMode() == fTileMode);
float imageIncrement[2];
float ySign = texture.origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = ySign / texture.height();
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
- uman.set2fv(fTargetUni, 0, 1, effect.target());
- uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), effect.kernel());
- uman.set1f(fGainUni, effect.gain());
- uman.set1f(fBiasUni, effect.bias());
+ uman.set2fv(fTargetUni, 0, 1, conv.target());
+ uman.set1fv(fKernelUni, 0, fKernelSize.width() * fKernelSize.height(), conv.kernel());
+ uman.set1f(fGainUni, conv.gain());
+ uman.set1f(fBiasUni, conv.bias());
fEffectMatrix.setData(uman,
- effect.getMatrix(),
- stage.getCoordChangeMatrix(),
- effect.texture(0));
+ 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