diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-29 19:51:22 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-29 19:51:22 +0000 |
commit | 2eaaefd7e6a58339b3f93333f1e9cc92252cc303 (patch) | |
tree | f65a31a9b3bc70909ceb311ebad684c2bf445868 /src/effects | |
parent | 484ee2a5fe47c204d9dda6acba54f9789d1cf69f (diff) |
Pass GrCustomStage to key-generation functions and emitCode().
R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6819046
git-svn-id: http://skia.googlecode.com/svn/branches/gpu_dev@6182 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkBlendImageFilter.cpp | 11 | ||||
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 14 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 11 | ||||
-rw-r--r-- | src/effects/SkMatrixConvolutionImageFilter.cpp | 13 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 13 | ||||
-rw-r--r-- | src/effects/SkTableColorFilter.cpp | 10 | ||||
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 8 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.cpp | 8 | ||||
-rw-r--r-- | src/effects/gradients/SkSweepGradient.cpp | 8 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointConicalGradient.cpp | 12 | ||||
-rw-r--r-- | src/effects/gradients/SkTwoPointRadialGradient.cpp | 12 |
12 files changed, 68 insertions, 57 deletions
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp index 39d7fd38b2..fb0e4d089a 100644 --- a/src/effects/SkBlendImageFilter.cpp +++ b/src/effects/SkBlendImageFilter.cpp @@ -13,6 +13,7 @@ #include "SkGr.h" #include "SkGrPixelRef.h" #include "gl/GrGLEffect.h" +#include "GrTBackendEffectFactory.h" #endif namespace { @@ -117,14 +118,14 @@ public: virtual ~GrGLBlendEffect(); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps&); + static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); private: typedef GrGLEffect INHERITED; @@ -246,7 +247,7 @@ GrGLBlendEffect::~GrGLBlendEffect() { } void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -278,7 +279,7 @@ void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder, } } -GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffect& s, const GrGLCaps&) { - return static_cast<const GrBlendEffect&>(s).mode(); +GrGLEffect::EffectKey GrGLBlendEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) { + return static_cast<const GrBlendEffect&>(*s.getEffect()).mode(); } #endif diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index dc93a24baa..58d26735a1 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -320,6 +320,7 @@ bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) { #if SK_SUPPORT_GPU #include "GrEffect.h" +#include "GrTBackendEffectFactory.h" #include "gl/GrGLEffect.h" class ColorMatrixEffect : public GrEffect { @@ -342,7 +343,7 @@ public: class GLEffect : public GrGLEffect { public: // this class always generates the same code. - static EffectKey GenKey(const GrEffect& s, const GrGLCaps&) { return 0; } + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; } GLEffect(const GrBackendEffectFactory& factory, const GrEffect& effect) @@ -352,7 +353,7 @@ public: } virtual void emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index e25ab9fd3d..2f403c13f4 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -14,10 +14,10 @@ #include "SkTypes.h" #if SK_SUPPORT_GPU -#include "GrBackendEffectFactory.h" #include "effects/GrSingleTextureEffect.h" #include "gl/GrGLEffect.h" #include "GrEffect.h" +#include "GrTBackendEffectFactory.h" class GrGLDiffuseLightingEffect; class GrGLSpecularLightingEffect; @@ -949,14 +949,14 @@ public: virtual ~GrGLLightingEffect(); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps); + static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); /** * Subclasses of GrGLLightingEffect must call INHERITED::setData(); @@ -1072,7 +1072,7 @@ GrGLLightingEffect::~GrGLLightingEffect() { } void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -1167,9 +1167,9 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, GrGLSLMulVarBy4f(code, 2, outputColor, inputColor); } -GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrEffect& s, - const GrGLCaps& caps) { - return static_cast<const GrLightingEffect&>(s).light()->type(); +GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrEffectStage& s, + const GrGLCaps& caps) { + return static_cast<const GrLightingEffect&>(*s.getEffect()).light()->type(); } void GrGLLightingEffect::setData(const GrGLUniformManager& uman, const GrEffectStage& stage) { diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 524a4bb662..1097273057 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -18,7 +18,7 @@ #include "gl/GrGLEffect.h" #include "gl/GrGLSL.h" #include "gl/GrGLTexture.h" -#include "GrBackendEffectFactory.h" +#include "GrTBackendEffectFactory.h" class GrGLMagnifierEffect; @@ -78,7 +78,7 @@ public: const GrEffect& effect); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -87,7 +87,7 @@ public: virtual void setData(const GrGLUniformManager& uman, const GrEffectStage& stage) SK_OVERRIDE; - static inline EffectKey GenKey(const GrEffect&, const GrGLCaps&); + static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); private: @@ -107,7 +107,7 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, } void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -167,8 +167,7 @@ void GrGLMagnifierEffect::setData(const GrGLUniformManager& uman, uman.set2f(fInsetVar, zoom.x_inset(), zoom.y_inset()); } -GrGLEffect::EffectKey GrGLMagnifierEffect::GenKey(const GrEffect& s, - const GrGLCaps& caps) { +GrGLEffect::EffectKey GrGLMagnifierEffect::GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; } diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index ed0a00b548..f8d1c093b5 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -14,6 +14,7 @@ #if SK_SUPPORT_GPU #include "gl/GrGLEffect.h" +#include "GrTBackendEffectFactory.h" #endif SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(const SkISize& kernelSize, const SkScalar* kernel, SkScalar gain, SkScalar bias, const SkIPoint& target, TileMode tileMode, bool convolveAlpha, SkImageFilter* input) @@ -284,14 +285,14 @@ public: GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory, const GrEffect& effect); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps); + static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE; @@ -348,7 +349,7 @@ static void appendTextureLookup(GrGLShaderBuilder* builder, } void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -417,9 +418,9 @@ int encodeXY(int x, int y) { }; -GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffect& s, - const GrGLCaps& caps) { - const GrMatrixConvolutionEffect& m = static_cast<const GrMatrixConvolutionEffect&>(s); +GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) { + const GrMatrixConvolutionEffect& m = + static_cast<const GrMatrixConvolutionEffect&>(*s.getEffect()); EffectKey key = encodeXY(m.kernelSize().width(), m.kernelSize().height()); key |= m.tileMode() << 7; key |= m.convolveAlpha() ? 1 << 9 : 0; diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 6b099142d7..0e6a3186a2 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -13,7 +13,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrTexture.h" -#include "GrGpu.h" +#include "GrTBackendEffectFactory.h" #include "gl/GrGLEffect.h" #include "effects/Gr1DKernelEffect.h" #endif @@ -272,14 +272,14 @@ public: const GrEffect& effect); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps); + static inline EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE; @@ -303,7 +303,7 @@ GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory } void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -342,9 +342,8 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder, GrGLSLMulVarBy4f(code, 2, outputColor, inputColor); } -GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffect& s, - const GrGLCaps& caps) { - const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(s); +GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrEffectStage& s, const GrGLCaps&) { + const GrMorphologyEffect& m = static_cast<const GrMorphologyEffect&>(*s.getEffect()); EffectKey key = static_cast<EffectKey>(m.radius()); key |= (m.type() << 8); return key; diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 71b4d16dba..0ae7e1950b 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -217,6 +217,7 @@ bool SkTable_ColorFilter::asComponentTable(SkBitmap* table) const { #if SK_SUPPORT_GPU #include "GrEffect.h" +#include "GrTBackendEffectFactory.h" #include "gl/GrGLEffect.h" #include "SkGr.h" @@ -250,7 +251,7 @@ public: const GrEffect& effect); virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -259,7 +260,7 @@ public: virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE {} - static EffectKey GenKey(const GrEffect&, const GrGLCaps&); + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps&); private: @@ -272,7 +273,7 @@ GLColorTableEffect::GLColorTableEffect( } void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -316,8 +317,7 @@ void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder, code->appendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor); } -GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrEffect& s, - const GrGLCaps& caps) { +GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrEffectStage&, const GrGLCaps&) { return 0; } diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 0e08ec067d..524db76966 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -474,6 +474,8 @@ void SkLinearGradient::shadeSpan16(int x, int y, #if SK_SUPPORT_GPU +#include "GrTBackendEffectFactory.h" + ///////////////////////////////////////////////////////////////////// class GrGLLinearGradient : public GrGLGradientEffect { @@ -486,14 +488,14 @@ public: virtual ~GrGLLinearGradient() { } virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; } + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; } private: @@ -551,7 +553,7 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random, ///////////////////////////////////////////////////////////////////// void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 6fa29a79c5..4766af604b 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -473,6 +473,8 @@ void SkRadialGradient::shadeSpan(int x, int y, #if SK_SUPPORT_GPU +#include "GrTBackendEffectFactory.h" + class GrGLRadialGradient : public GrGLGradientEffect { public: @@ -481,14 +483,14 @@ public: virtual ~GrGLRadialGradient() { } virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; } + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; } private: @@ -549,7 +551,7 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random, ///////////////////////////////////////////////////////////////////// void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp index b264075c12..b64e15d0c1 100644 --- a/src/effects/gradients/SkSweepGradient.cpp +++ b/src/effects/gradients/SkSweepGradient.cpp @@ -382,6 +382,8 @@ void SkSweepGradient::shadeSpan16(int x, int y, uint16_t* SK_RESTRICT dstC, #if SK_SUPPORT_GPU +#include "GrTBackendEffectFactory.h" + class GrGLSweepGradient : public GrGLGradientEffect { public: @@ -390,14 +392,14 @@ public: virtual ~GrGLSweepGradient() { } virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, const char* inputColor, const TextureSamplerArray&) SK_OVERRIDE; - static EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps) { return 0; } + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps) { return 0; } private: @@ -455,7 +457,7 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random, ///////////////////////////////////////////////////////////////////// void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp index 396981f598..acd0eeedfb 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp @@ -315,6 +315,8 @@ void SkTwoPointConicalGradient::flatten( #if SK_SUPPORT_GPU +#include "GrTBackendEffectFactory.h" + // For brevity typedef GrGLUniformManager::UniformHandle UniformHandle; static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle; @@ -327,7 +329,7 @@ public: virtual ~GrGLConical2Gradient() { } virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -335,7 +337,7 @@ public: const TextureSamplerArray&) SK_OVERRIDE; virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE; - static EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps); + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps); protected: @@ -466,7 +468,7 @@ GrGLConical2Gradient::GrGLConical2Gradient( } void GrGLConical2Gradient::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -666,8 +668,8 @@ void GrGLConical2Gradient::setData(const GrGLUniformManager& uman, const GrEffec } } -GrEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffect& s, const GrGLCaps& caps) { - return (static_cast<const GrConical2Gradient&>(s).isDegenerate()); +GrGLEffect::EffectKey GrGLConical2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) { + return (static_cast<const GrConical2Gradient&>(*s.getEffect()).isDegenerate()); } ///////////////////////////////////////////////////////////////////// diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp index 2aac6677f4..9357b11685 100644 --- a/src/effects/gradients/SkTwoPointRadialGradient.cpp +++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp @@ -349,6 +349,8 @@ void SkTwoPointRadialGradient::init() { #if SK_SUPPORT_GPU +#include "GrTBackendEffectFactory.h" + // For brevity typedef GrGLUniformManager::UniformHandle UniformHandle; static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle; @@ -362,7 +364,7 @@ public: virtual ~GrGLRadial2Gradient() { } virtual void emitCode(GrGLShaderBuilder*, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -370,7 +372,7 @@ public: const TextureSamplerArray&) SK_OVERRIDE; virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE; - static EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps); + static EffectKey GenKey(const GrEffectStage&, const GrGLCaps& caps); protected: @@ -499,7 +501,7 @@ GrGLRadial2Gradient::GrGLRadial2Gradient( } void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, - const GrEffect&, + const GrEffectStage&, EffectKey, const char* vertexCoords, const char* outputColor, @@ -640,8 +642,8 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, const GrEffect } } -GrEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffect& s, const GrGLCaps& caps) { - return (static_cast<const GrRadial2Gradient&>(s).isDegenerate()); +GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrEffectStage& s, const GrGLCaps&) { + return (static_cast<const GrRadial2Gradient&>(*s.getEffect()).isDegenerate()); } ///////////////////////////////////////////////////////////////////// |