From 6340a41108633ac1ce5941e5cd30538630c4c55b Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Tue, 22 Jan 2013 19:55:59 +0000 Subject: 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 --- src/gpu/gl/GrGLEffect.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/gpu/gl/GrGLEffect.h') 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 + static const T& GetEffectFromStage(const GrEffectStage& effectStage) { + GrAssert(NULL != effectStage.getEffect()); + return CastEffect(*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 + static const T& CastEffect(const GrEffectRef& effectRef) { + GrAssert(NULL != effectRef.get()); + return *static_cast(effectRef.get()); + } protected: const GrBackendEffectFactory& fFactory; -- cgit v1.2.3