aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLEffect.h
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-22 19:55:59 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-01-22 19:55:59 +0000
commit6340a41108633ac1ce5941e5cd30538630c4c55b (patch)
treec6f791722f09f6cf31207aea8093b1b06be3ae92 /src/gpu/gl/GrGLEffect.h
parentba3284e7bbb830749206414890f8152e421969f2 (diff)
Let them eat GrEffectRef.
Changes the remaining existing code that operates on naked GrEffects to GrEffectRef. Review URL: https://codereview.appspot.com/7124058 git-svn-id: http://skia.googlecode.com/svn/trunk@7321 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLEffect.h')
-rw-r--r--src/gpu/gl/GrGLEffect.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGLEffect.h b/src/gpu/gl/GrGLEffect.h
index f2142c5b22..32fc960125 100644
--- a/src/gpu/gl/GrGLEffect.h
+++ b/src/gpu/gl/GrGLEffect.h
@@ -86,7 +86,28 @@ public:
const char* name() const { return fFactory.name(); }
- static EffectKey GenTextureKey(const GrEffect&, const GrGLCaps&);
+ static EffectKey GenTextureKey(const GrEffectRef*, const GrGLCaps&);
+
+ /**
+ * GrGLEffect subclasses get passed a GrEffectStage in their emitCode and setData functions.
+ * The GrGLEffect usually needs to cast the stage's effect to the GrEffect subclass that
+ * generated the GrGLEffect. This helper does just that.
+ */
+ template <typename T>
+ static const T& GetEffectFromStage(const GrEffectStage& effectStage) {
+ GrAssert(NULL != effectStage.getEffect());
+ return CastEffect<T>(*effectStage.getEffect());
+ }
+
+ /**
+ * Extracts the GrEffect from a GrEffectRef and down-casts to a GrEffect subclass. Usually used
+ * in a GrGLEffect subclass's constructor (which takes const GrEffectRef&).
+ */
+ template <typename T>
+ static const T& CastEffect(const GrEffectRef& effectRef) {
+ GrAssert(NULL != effectRef.get());
+ return *static_cast<const T*>(effectRef.get());
+ }
protected:
const GrBackendEffectFactory& fFactory;