From 8ddbe8b9366c8c59c4fb55f01f253de8a0b37d6e Mon Sep 17 00:00:00 2001 From: joshualitt Date: Tue, 16 Sep 2014 06:46:30 -0700 Subject: removing GrDrawEffect BUG=skia: R=bsalomon@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/571163002 --- include/gpu/GrBackendEffectFactory.h | 6 ++--- include/gpu/GrDrawEffect.h | 47 ----------------------------------- include/gpu/GrEffect.h | 12 ++++----- include/gpu/GrTBackendEffectFactory.h | 11 ++++---- 4 files changed, 13 insertions(+), 63 deletions(-) delete mode 100644 include/gpu/GrDrawEffect.h (limited to 'include/gpu') diff --git a/include/gpu/GrBackendEffectFactory.h b/include/gpu/GrBackendEffectFactory.h index e6362520fc..936d632a7e 100644 --- a/include/gpu/GrBackendEffectFactory.h +++ b/include/gpu/GrBackendEffectFactory.h @@ -16,7 +16,7 @@ class GrGLEffect; class GrGLCaps; -class GrDrawEffect; +class GrEffect; /** * Used by effects to build their keys. It incorporates each per-effect key into a larger shader key. @@ -96,13 +96,13 @@ public: * configuration that affect GLSL code generation. Two GrEffect instances that would cause * this->createGLInstance()->emitCode() to produce different code must produce different keys. */ - virtual void getGLEffectKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0; + virtual void getGLEffectKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0; /** * Creates a GrGLEffect instance that is used both to generate code for the GrEffect in a GLSL * program and to manage updating uniforms for the program when it is used. */ - virtual GrGLEffect* createGLInstance(const GrDrawEffect&) const = 0; + virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0; /** * Produces a human-reable name for the effect. diff --git a/include/gpu/GrDrawEffect.h b/include/gpu/GrDrawEffect.h deleted file mode 100644 index 710b00035f..0000000000 --- a/include/gpu/GrDrawEffect.h +++ /dev/null @@ -1,47 +0,0 @@ - -#ifndef GrDrawEffect_DEFINED -#define GrDrawEffect_DEFINED - -#include "GrEffectStage.h" - -/** - * This class is used to communicate the particular GrEffect used in a draw to the backend-specific - * effect subclass (e.g. GrGLEffect). It is used to by the backend-specific class to generate a - * cache key for the effect, generate code on a program cache miss, and to upload uniform values to - * the program. - * In addition to the effect, it also communicates any changes between the relationship between - * the view matrix and local coordinate system since the effect was installed in its GrDrawState. - * The typical use case is that sometime after an effect was installed a decision was made to draw - * in device coordinates (i.e. use an identity view-matrix). In such a case the GrDrawEffect's - * coord-change-matrix would be the inverse of the view matrix that was set when the effect was - * installed. - */ -class GrDrawEffect { -public: - GrDrawEffect(const GrEffectStage& stage, bool explicitLocalCoords) - : fEffectStage(&stage) - , fExplicitLocalCoords(explicitLocalCoords) { - SkASSERT(fEffectStage); - SkASSERT(fEffectStage->getEffect()); - } - const GrEffect* effect() const { return fEffectStage->getEffect(); } - - template - const T& castEffect() const { return *static_cast(this->effect()); } - - const SkMatrix& getCoordChangeMatrix() const { - if (fExplicitLocalCoords) { - return SkMatrix::I(); - } else { - return fEffectStage->getCoordChangeMatrix(); - } - } - - bool programHasExplicitLocalCoords() const { return fExplicitLocalCoords; } - -private: - const GrEffectStage* fEffectStage; - bool fExplicitLocalCoords; -}; - -#endif diff --git a/include/gpu/GrEffect.h b/include/gpu/GrEffect.h index 102b9d4b96..e9259979f0 100644 --- a/include/gpu/GrEffect.h +++ b/include/gpu/GrEffect.h @@ -130,6 +130,11 @@ public: ::operator delete(target, placement); } + /** + * Helper for down-casting to a GrEffect subclass + */ + template const T& cast() const { return *static_cast(this); } + protected: /** * Subclasses call this from their constructor to register coordinate transformations. The @@ -154,13 +159,6 @@ protected: , fWillUseInputColor(true) , fRequiresVertexShader(false) {} - /** - * Helper for down-casting to a GrEffect subclass - */ - template static const T& CastEffect(const GrEffect& effect) { - return *static_cast(&effect); - } - /** * If the effect subclass will read the destination pixel value then it must call this function * from its constructor. Otherwise, when its generated backend-specific effect class attempts diff --git a/include/gpu/GrTBackendEffectFactory.h b/include/gpu/GrTBackendEffectFactory.h index 450eb68ee5..a45aeacb72 100644 --- a/include/gpu/GrTBackendEffectFactory.h +++ b/include/gpu/GrTBackendEffectFactory.h @@ -9,7 +9,6 @@ #define GrTBackendEffectFactory_DEFINED #include "GrBackendEffectFactory.h" -#include "GrDrawEffect.h" #include "gl/GrGLProgramEffects.h" /** @@ -27,7 +26,7 @@ * 1. The GrGLEffect used by GrEffect subclass MyEffect must be named or typedef'ed to * MyEffect::GLEffect. * 2. MyEffect::GLEffect must have a static function: - * EffectKey GenKey(const GrDrawEffect, const GrGLCaps&) + * EffectKey GenKey(const GrEffect, const GrGLCaps&) * which generates a key that maps 1 to 1 with code variations emitted by * MyEffect::GLEffect::emitCode(). * 3. MyEffect must have a static function: @@ -46,17 +45,17 @@ public: /** Implemented using GLEffect::GenKey as described in this class's comment. */ - virtual void getGLEffectKey(const GrDrawEffect& drawEffect, + virtual void getGLEffectKey(const GrEffect& effect, const GrGLCaps& caps, GrEffectKeyBuilder* b) const SK_OVERRIDE { - GLEffect::GenKey(drawEffect, caps, b); + GLEffect::GenKey(effect, caps, b); } /** Returns a new instance of the appropriate *GL* implementation class for the given GrEffect; caller is responsible for deleting the object. */ - virtual GrGLEffect* createGLInstance(const GrDrawEffect& drawEffect) const SK_OVERRIDE { - return SkNEW_ARGS(GLEffect, (*this, drawEffect)); + virtual GrGLEffect* createGLInstance(const GrEffect& effect) const SK_OVERRIDE { + return SkNEW_ARGS(GLEffect, (*this, effect)); } /** This class is a singleton. This function returns the single instance. */ -- cgit v1.2.3