| 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 |
| 11 #include "GrBackendEffectFactory.h" | 11 #include "GrBackendEffectFactory.h" |
| 12 #include "GrGLProgramEffects.h" | 12 #include "GrGLProgramEffects.h" |
| 13 #include "GrGLShaderBuilder.h" | 13 #include "GrGLShaderBuilder.h" |
| 14 #include "GrGLShaderVar.h" | 14 #include "GrGLShaderVar.h" |
| 15 #include "GrGLSL.h" | 15 #include "GrGLSL.h" |
| 16 | 16 |
| 17 class GrGLTexture; | |
| 18 | |
| 19 /** @file | 17 /** @file |
| 20 This file contains specializations for OpenGL of the shader stages declared
in | 18 This file contains specializations for OpenGL of the shader stages declared
in |
| 21 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt
ing the | 19 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt
ing the |
| 22 GLSL code that implements a GrEffect and for uploading uniforms at draw time
. If they don't | 20 GLSL code that implements a GrEffect and for uploading uniforms at draw time
. If they don't |
| 23 always emit the same GLSL code, they must have a function: | 21 always emit the same GLSL code, they must have a function: |
| 24 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) | 22 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) |
| 25 that is used to implement a program cache. When two GrEffects produce the sa
me key this means | 23 that is used to implement a program cache. When two GrEffects produce the sa
me key this means |
| 26 that their GrGLEffects would emit the same GLSL code. | 24 that their GrGLEffects would emit the same GLSL code. |
| 27 | 25 |
| 28 The GrGLEffect subclass must also have a constructor of the form: | 26 The GrGLEffect subclass must also have a constructor of the form: |
| 29 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr
awEffect&) | 27 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr
awEffect&) |
| 30 The effect held by the GrDrawEffect is guaranteed to be of the type that gen
erated the | 28 The effect held by the GrDrawEffect is guaranteed to be of the type that gen
erated the |
| 31 GrGLEffect subclass instance. | 29 GrGLEffect subclass instance. |
| 32 | 30 |
| 33 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). | 31 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). |
| 34 */ | 32 */ |
| 35 | 33 |
| 36 class GrDrawEffect; | 34 class GrDrawEffect; |
| 35 class GrGLTexture; |
| 36 class GrGLVertexEffect; |
| 37 | 37 |
| 38 class GrGLEffect { | 38 class GrGLEffect { |
| 39 | 39 |
| 40 public: | 40 public: |
| 41 typedef GrBackendEffectFactory::EffectKey EffectKey; | 41 typedef GrBackendEffectFactory::EffectKey EffectKey; |
| 42 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; | 42 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; |
| 43 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; | 43 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; |
| 44 | 44 |
| 45 enum { | 45 enum { |
| 46 kNoEffectKey = GrBackendEffectFactory::kNoEffectKey, | 46 kNoEffectKey = GrBackendEffectFactory::kNoEffectKey, |
| 47 // the number of bits in EffectKey available to GenKey | 47 // the number of bits in EffectKey available to GenKey |
| 48 kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits, | 48 kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits, |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 GrGLEffect(const GrBackendEffectFactory& factory) : fFactory(factory) {} | 51 GrGLEffect(const GrBackendEffectFactory& factory) |
| 52 : fFactory(factory) |
| 53 , fIsVertexEffect(false) { |
| 54 } |
| 52 | 55 |
| 53 virtual ~GrGLEffect() {} | 56 virtual ~GrGLEffect() {} |
| 54 | 57 |
| 55 /** Called when the program stage should insert its code into the shaders. T
he code in each | 58 /** Called when the program stage should insert its code into the shaders. T
he code in each |
| 56 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 59 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
| 57 stages. | 60 stages. |
| 58 | 61 |
| 59 @param builder Interface used to emit code in the shaders. | 62 @param builder Interface used to emit code in the shaders. |
| 60 @param drawEffect A wrapper on the effect that generated this program
stage. | 63 @param drawEffect A wrapper on the effect that generated this program
stage. |
| 61 @param key The key that was computed by GenKey() from the gener
ating GrEffect. | 64 @param key The key that was computed by GenKey() from the gener
ating GrEffect. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 guaranteed to be of the same type that created this GrGLEffect and to ha
ve an identical | 89 guaranteed to be of the same type that created this GrGLEffect and to ha
ve an identical |
| 87 EffectKey as the one that created this GrGLEffect. Effects that use loca
l coords have | 90 EffectKey as the one that created this GrGLEffect. Effects that use loca
l coords have |
| 88 to consider whether the GrEffectStage's coord change matrix should be us
ed. When explicit | 91 to consider whether the GrEffectStage's coord change matrix should be us
ed. When explicit |
| 89 local coordinates are used it can be ignored. */ | 92 local coordinates are used it can be ignored. */ |
| 90 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) {} | 93 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) {} |
| 91 | 94 |
| 92 const char* name() const { return fFactory.name(); } | 95 const char* name() const { return fFactory.name(); } |
| 93 | 96 |
| 94 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { retur
n 0; } | 97 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { retur
n 0; } |
| 95 | 98 |
| 99 /** Used by the system when generating shader code, to see if this effect ca
n be downcasted to |
| 100 the internal GrGLVertexEffect type */ |
| 101 bool isVertexEffect() const { return fIsVertexEffect; } |
| 102 |
| 96 protected: | 103 protected: |
| 97 const GrBackendEffectFactory& fFactory; | 104 const GrBackendEffectFactory& fFactory; |
| 105 |
| 106 private: |
| 107 friend class GrGLVertexEffect; // to set fIsVertexEffect |
| 108 |
| 109 bool fIsVertexEffect; |
| 98 }; | 110 }; |
| 99 | 111 |
| 100 #endif | 112 #endif |
| OLD | NEW |