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" | |
14 #include "GrGLShaderVar.h" | 13 #include "GrGLShaderVar.h" |
15 #include "GrGLSL.h" | 14 #include "GrGLSL.h" |
16 | 15 |
| 16 class GrGLShaderBuilder; |
| 17 |
17 /** @file | 18 /** @file |
18 This file contains specializations for OpenGL of the shader stages declared
in | 19 This file contains specializations for OpenGL of the shader stages declared
in |
19 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt
ing the | 20 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt
ing the |
20 GLSL code that implements a GrEffect and for uploading uniforms at draw time
. If they don't | 21 GLSL code that implements a GrEffect and for uploading uniforms at draw time
. If they don't |
21 always emit the same GLSL code, they must have a function: | 22 always emit the same GLSL code, they must have a function: |
22 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) | 23 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) |
23 that is used to implement a program cache. When two GrEffects produce the sa
me key this means | 24 that is used to implement a program cache. When two GrEffects produce the sa
me key this means |
24 that their GrGLEffects would emit the same GLSL code. | 25 that their GrGLEffects would emit the same GLSL code. |
25 | 26 |
26 The GrGLEffect subclass must also have a constructor of the form: | 27 The GrGLEffect subclass must also have a constructor of the form: |
27 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr
awEffect&) | 28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr
awEffect&) |
28 The effect held by the GrDrawEffect is guaranteed to be of the type that gen
erated the | 29 The effect held by the GrDrawEffect is guaranteed to be of the type that gen
erated the |
29 GrGLEffect subclass instance. | 30 GrGLEffect subclass instance. |
30 | 31 |
31 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). | 32 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). |
32 */ | 33 */ |
33 | 34 |
34 class GrDrawEffect; | 35 class GrDrawEffect; |
35 class GrGLTexture; | 36 class GrGLTexture; |
36 class GrGLVertexEffect; | 37 class GrGLVertexEffect; |
37 | 38 |
38 class GrGLEffect { | 39 class GrGLEffect { |
39 | 40 |
40 public: | 41 public: |
41 typedef GrBackendEffectFactory::EffectKey EffectKey; | 42 typedef GrBackendEffectFactory::EffectKey EffectKey; |
42 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; | 43 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; |
43 typedef GrGLProgramEffects::TextureSampler TextureSampler; | 44 typedef GrGLProgramEffects::TextureSampler TextureSampler; |
44 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; | 45 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; |
45 | 46 |
46 enum { | |
47 kNoEffectKey = GrBackendEffectFactory::kNoEffectKey, | |
48 // the number of bits in EffectKey available to GenKey | |
49 kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits, | |
50 }; | |
51 | |
52 GrGLEffect(const GrBackendEffectFactory& factory) | 47 GrGLEffect(const GrBackendEffectFactory& factory) |
53 : fFactory(factory) | 48 : fFactory(factory) |
54 , fIsVertexEffect(false) { | 49 , fIsVertexEffect(false) { |
55 } | 50 } |
56 | 51 |
57 virtual ~GrGLEffect() {} | 52 virtual ~GrGLEffect() {} |
58 | 53 |
59 /** Called when the program stage should insert its code into the shaders. T
he code in each | 54 /** Called when the program stage should insert its code into the shaders. T
he code in each |
60 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 55 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
61 stages. | 56 stages. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 protected: | 99 protected: |
105 const GrBackendEffectFactory& fFactory; | 100 const GrBackendEffectFactory& fFactory; |
106 | 101 |
107 private: | 102 private: |
108 friend class GrGLVertexEffect; // to set fIsVertexEffect | 103 friend class GrGLVertexEffect; // to set fIsVertexEffect |
109 | 104 |
110 bool fIsVertexEffect; | 105 bool fIsVertexEffect; |
111 }; | 106 }; |
112 | 107 |
113 #endif | 108 #endif |
OLD | NEW |