| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrGLEffect_DEFINED | 8 #ifndef GrGLEffect_DEFINED |
| 9 #define GrGLEffect_DEFINED | 9 #define GrGLEffect_DEFINED |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 /** A GrGLEffect instance can be reused with any GrEffect that produces the
same stage | 80 /** A GrGLEffect instance can be reused with any GrEffect that produces the
same stage |
| 81 key; this function reads data from a stage and uploads any uniform varia
bles required | 81 key; this function reads data from a stage and uploads any uniform varia
bles required |
| 82 by the shaders created in emitCode(). The GrEffect installed in the GrEf
fectStage is | 82 by the shaders created in emitCode(). The GrEffect installed in the GrEf
fectStage is |
| 83 guaranteed to be of the same type that created this GrGLEffect and to ha
ve an identical | 83 guaranteed to be of the same type that created this GrGLEffect and to ha
ve an identical |
| 84 EffectKey as the one that created this GrGLEffect. */ | 84 EffectKey as the one that created this GrGLEffect. */ |
| 85 virtual void setData(const GrGLUniformManager&, const GrEffectStage&); | 85 virtual void setData(const GrGLUniformManager&, const GrEffectStage&); |
| 86 | 86 |
| 87 const char* name() const { return fFactory.name(); } | 87 const char* name() const { return fFactory.name(); } |
| 88 | 88 |
| 89 static EffectKey GenTextureKey(const GrEffectRef*, const GrGLCaps&); | 89 static EffectKey GenTextureKey(const GrEffectRef*, const GrGLCaps&); |
| 90 static EffectKey GenAttribKey(const GrEffectStage& stage); |
| 90 | 91 |
| 91 /** | 92 /** |
| 92 * GrGLEffect subclasses get passed a GrEffectStage in their emitCode and set
Data functions. | 93 * GrGLEffect subclasses get passed a GrEffectStage in their emitCode and set
Data functions. |
| 93 * The GrGLEffect usually needs to cast the stage's effect to the GrEffect su
bclass that | 94 * The GrGLEffect usually needs to cast the stage's effect to the GrEffect su
bclass that |
| 94 * generated the GrGLEffect. This helper does just that. | 95 * generated the GrGLEffect. This helper does just that. |
| 95 */ | 96 */ |
| 96 template <typename T> | 97 template <typename T> |
| 97 static const T& GetEffectFromStage(const GrEffectStage& effectStage) { | 98 static const T& GetEffectFromStage(const GrEffectStage& effectStage) { |
| 98 GrAssert(NULL != effectStage.getEffect()); | 99 GrAssert(NULL != effectStage.getEffect()); |
| 99 return CastEffect<T>(*effectStage.getEffect()); | 100 return CastEffect<T>(*effectStage.getEffect()); |
| 100 } | 101 } |
| 101 | 102 |
| 102 /** | 103 /** |
| 103 * Extracts the GrEffect from a GrEffectRef and down-casts to a GrEffect subc
lass. Usually used | 104 * Extracts the GrEffect from a GrEffectRef and down-casts to a GrEffect subc
lass. Usually used |
| 104 * in a GrGLEffect subclass's constructor (which takes const GrEffectRef&). | 105 * in a GrGLEffect subclass's constructor (which takes const GrEffectRef&). |
| 105 */ | 106 */ |
| 106 template <typename T> | 107 template <typename T> |
| 107 static const T& CastEffect(const GrEffectRef& effectRef) { | 108 static const T& CastEffect(const GrEffectRef& effectRef) { |
| 108 GrAssert(NULL != effectRef.get()); | 109 GrAssert(NULL != effectRef.get()); |
| 109 return *static_cast<const T*>(effectRef.get()); | 110 return *static_cast<const T*>(effectRef.get()); |
| 110 } | 111 } |
| 111 | 112 |
| 112 protected: | 113 protected: |
| 113 const GrBackendEffectFactory& fFactory; | 114 const GrBackendEffectFactory& fFactory; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 #endif | 117 #endif |
| OLD | NEW |