OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLProgramEffects_DEFINED | 8 #ifndef GrGLProgramEffects_DEFINED |
9 #define GrGLProgramEffects_DEFINED | 9 #define GrGLProgramEffects_DEFINED |
10 | 10 |
11 #include "GrBackendEffectFactory.h" | 11 #include "GrBackendEffectFactory.h" |
12 #include "GrTexture.h" | 12 #include "GrTexture.h" |
13 #include "GrTextureAccess.h" | 13 #include "GrTextureAccess.h" |
14 #include "GrGLUniformManager.h" | 14 #include "GrGLUniformManager.h" |
15 | 15 |
| 16 class GrEffect; |
16 class GrEffectStage; | 17 class GrEffectStage; |
17 class GrGLVertexProgramEffectsBuilder; | 18 class GrGLVertexProgramEffectsBuilder; |
18 class GrGLShaderBuilder; | 19 class GrGLShaderBuilder; |
19 class GrGLFullShaderBuilder; | 20 class GrGLFullShaderBuilder; |
20 class GrGLFragmentOnlyShaderBuilder; | 21 class GrGLFragmentOnlyShaderBuilder; |
21 | 22 |
22 /** | 23 /** |
23 * This class encapsulates an array of GrGLEffects and their supporting data (co
ord transforms | 24 * This class encapsulates an array of GrGLEffects and their supporting data (co
ord transforms |
24 * and textures). It is built with GrGLProgramEffectsBuilder, then used to manag
e the necessary GL | 25 * and textures). It is built with GrGLProgramEffectsBuilder, then used to manag
e the necessary GL |
25 * state and shader uniforms. | 26 * state and shader uniforms. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 GrGLProgramEffects(int reserveCount) | 101 GrGLProgramEffects(int reserveCount) |
101 : fGLEffects(reserveCount) | 102 : fGLEffects(reserveCount) |
102 , fSamplers(reserveCount) { | 103 , fSamplers(reserveCount) { |
103 } | 104 } |
104 | 105 |
105 /** | 106 /** |
106 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t
exture accesses and | 107 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t
exture accesses and |
107 * appends the necessary data to the TextureSamplerArray* object so effects
can add texture | 108 * appends the necessary data to the TextureSamplerArray* object so effects
can add texture |
108 * lookups to their code. This method is only meant to be called during the
construction phase. | 109 * lookups to their code. This method is only meant to be called during the
construction phase. |
109 */ | 110 */ |
110 void emitSamplers(GrGLShaderBuilder*, const GrEffectRef&, TextureSamplerArra
y*); | 111 void emitSamplers(GrGLShaderBuilder*, const GrEffect*, TextureSamplerArray*)
; |
111 | 112 |
112 /** | 113 /** |
113 * Helper for setData(). Binds all the textures for an effect. | 114 * Helper for setData(). Binds all the textures for an effect. |
114 */ | 115 */ |
115 void bindTextures(GrGpuGL*, const GrEffectRef&, int effectIdx); | 116 void bindTextures(GrGpuGL*, const GrEffect*, int effectIdx); |
116 | 117 |
117 struct Sampler { | 118 struct Sampler { |
118 SkDEBUGCODE(Sampler() : fTextureUnit(-1) {}) | 119 SkDEBUGCODE(Sampler() : fTextureUnit(-1) {}) |
119 UniformHandle fUniform; | 120 UniformHandle fUniform; |
120 int fTextureUnit; | 121 int fTextureUnit; |
121 }; | 122 }; |
122 | 123 |
123 SkTArray<GrGLEffect*> fGLEffects; | 124 SkTArray<GrGLEffect*> fGLEffects; |
124 SkTArray<SkSTArray<4, Sampler, true> > fSamplers; | 125 SkTArray<SkSTArray<4, Sampler, true> > fSamplers; |
125 | 126 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 void emitAttributes(GrGLFullShaderBuilder*, const GrEffectStage&); | 182 void emitAttributes(GrGLFullShaderBuilder*, const GrEffectStage&); |
182 | 183 |
183 /** | 184 /** |
184 * Helper for emitEffect(). Emits code to implement an effect's coord transf
orms in the VS. | 185 * Helper for emitEffect(). Emits code to implement an effect's coord transf
orms in the VS. |
185 * Varyings are added as an outputs of the VS and inputs to the FS. The vary
ings may be either a | 186 * Varyings are added as an outputs of the VS and inputs to the FS. The vary
ings may be either a |
186 * vec2f or vec3f depending upon whether perspective interpolation is requir
ed or not. The names | 187 * vec2f or vec3f depending upon whether perspective interpolation is requir
ed or not. The names |
187 * of the varyings in the VS and FS as well their types are appended to the | 188 * of the varyings in the VS and FS as well their types are appended to the |
188 * TransformedCoordsArray* object, which is in turn passed to the effect's e
mitCode() function. | 189 * TransformedCoordsArray* object, which is in turn passed to the effect's e
mitCode() function. |
189 */ | 190 */ |
190 void emitTransforms(GrGLFullShaderBuilder*, | 191 void emitTransforms(GrGLFullShaderBuilder*, |
191 const GrEffectRef&, | 192 const GrEffect*, |
192 EffectKey, | 193 EffectKey, |
193 TransformedCoordsArray*); | 194 TransformedCoordsArray*); |
194 | 195 |
195 /** | 196 /** |
196 * Helper for setData(). Sets all the transform matrices for an effect. | 197 * Helper for setData(). Sets all the transform matrices for an effect. |
197 */ | 198 */ |
198 void setTransformData(const GrGLUniformManager&, const GrDrawEffect&, int ef
fectIdx); | 199 void setTransformData(const GrGLUniformManager&, const GrDrawEffect&, int ef
fectIdx); |
199 | 200 |
200 struct Transform { | 201 struct Transform { |
201 Transform() { fCurrentValue = SkMatrix::InvalidMatrix(); } | 202 Transform() { fCurrentValue = SkMatrix::InvalidMatrix(); } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 270 |
270 /** | 271 /** |
271 * Helper for emitEffect(). Allocates texture units from the builder for eac
h transform in an | 272 * Helper for emitEffect(). Allocates texture units from the builder for eac
h transform in an |
272 * effect. The transforms all use adjacent texture units. They either use tw
o or three of the | 273 * effect. The transforms all use adjacent texture units. They either use tw
o or three of the |
273 * coordinates at a given texture unit, depending on if they need perspectiv
e interpolation. | 274 * coordinates at a given texture unit, depending on if they need perspectiv
e interpolation. |
274 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[
0])') as well as the | 275 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[
0])') as well as the |
275 * types are appended to the TransformedCoordsArray* object, which is in tur
n passed to the | 276 * types are appended to the TransformedCoordsArray* object, which is in tur
n passed to the |
276 * effect's emitCode() function. | 277 * effect's emitCode() function. |
277 */ | 278 */ |
278 void setupPathTexGen(GrGLFragmentOnlyShaderBuilder*, | 279 void setupPathTexGen(GrGLFragmentOnlyShaderBuilder*, |
279 const GrEffectRef&, | 280 const GrEffect*, |
280 EffectKey, | 281 EffectKey, |
281 TransformedCoordsArray*); | 282 TransformedCoordsArray*); |
282 | 283 |
283 /** | 284 /** |
284 * Helper for setData(). Sets the PathTexGen state for each transform in an
effect. | 285 * Helper for setData(). Sets the PathTexGen state for each transform in an
effect. |
285 */ | 286 */ |
286 void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); | 287 void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); |
287 | 288 |
288 struct Transforms { | 289 struct Transforms { |
289 Transforms(EffectKey transformKey, int texCoordIndex) | 290 Transforms(EffectKey transformKey, int texCoordIndex) |
(...skipping 28 matching lines...) Expand all Loading... |
318 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 319 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } |
319 | 320 |
320 private: | 321 private: |
321 GrGLFragmentOnlyShaderBuilder* fBuilder; | 322 GrGLFragmentOnlyShaderBuilder* fBuilder; |
322 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; | 323 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; |
323 | 324 |
324 typedef GrGLProgramEffectsBuilder INHERITED; | 325 typedef GrGLProgramEffectsBuilder INHERITED; |
325 }; | 326 }; |
326 | 327 |
327 #endif | 328 #endif |
OLD | NEW |