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 |
(...skipping 21 matching lines...) Expand all Loading... | |
32 typedef GrGLProgramDataManager::VaryingHandle VaryingHandle; | 32 typedef GrGLProgramDataManager::VaryingHandle VaryingHandle; |
33 | 33 |
34 /** | 34 /** |
35 * This class emits some of the code inserted into the shaders for an effect . The code it | 35 * This class emits some of the code inserted into the shaders for an effect . The code it |
36 * creates may be dependent on properties of the effect that the effect itse lf doesn't use | 36 * creates may be dependent on properties of the effect that the effect itse lf doesn't use |
37 * in its key (e.g. the pixel format of textures used). So this class insert s a meta-key for | 37 * in its key (e.g. the pixel format of textures used). So this class insert s a meta-key for |
38 * every effect using this function. It is also responsible for inserting th e effect's class ID | 38 * every effect using this function. It is also responsible for inserting th e effect's class ID |
39 * which must be different for every GrEffect subclass. It can fail if an ef fect uses too many | 39 * which must be different for every GrEffect subclass. It can fail if an ef fect uses too many |
40 * textures, attributes, etc for the space allotted in the meta-key. | 40 * textures, attributes, etc for the space allotted in the meta-key. |
41 */ | 41 */ |
42 static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectK eyBuilder*); | 42 static bool GenEffectMetaKey(const GrEffectStage&, |
43 bool, | |
44 const GrGLCaps&, | |
45 GrEffectKeyBuilder*); | |
43 | 46 |
44 virtual ~GrGLProgramEffects(); | 47 virtual ~GrGLProgramEffects(); |
45 | 48 |
46 /** | 49 /** |
47 * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ es the next | 50 * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ es the next |
48 * available unit to *texUnitIdx when it returns. | 51 * available unit to *texUnitIdx when it returns. |
49 */ | 52 */ |
50 void initSamplers(const GrGLProgramDataManager&, int* texUnitIdx); | 53 void initSamplers(const GrGLProgramDataManager&, int* texUnitIdx); |
51 | 54 |
52 /** | 55 /** |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 char fSwizzle[5]; | 110 char fSwizzle[5]; |
108 }; | 111 }; |
109 | 112 |
110 typedef SkTArray<TextureSampler> TextureSamplerArray; | 113 typedef SkTArray<TextureSampler> TextureSamplerArray; |
111 | 114 |
112 protected: | 115 protected: |
113 | 116 |
114 /** | 117 /** |
115 * Helpers for GenEffectMetaKey. | 118 * Helpers for GenEffectMetaKey. |
116 */ | 119 */ |
117 static uint32_t GenAttribKey(const GrEffect&); | 120 static uint32_t GenAttribKey(const GrEffect*); |
118 static uint32_t GenTransformKey(const GrDrawEffect&); | 121 static uint32_t GenTransformKey(const GrEffectStage&, bool); |
bsalomon
2014/09/15 19:54:25
seems like we should name the bool param since it'
| |
119 static uint32_t GenTextureKey(const GrDrawEffect&, const GrGLCaps&); | 122 static uint32_t GenTextureKey(const GrEffect*, const GrGLCaps&); |
120 | 123 |
121 GrGLProgramEffects(int reserveCount) | 124 GrGLProgramEffects(int reserveCount) |
122 : fGLEffects(reserveCount) | 125 : fGLEffects(reserveCount) |
123 , fSamplers(reserveCount) { | 126 , fSamplers(reserveCount) { |
124 } | 127 } |
125 | 128 |
126 /** | 129 /** |
127 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t exture accesses and | 130 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t exture accesses and |
128 * appends the necessary data to the TextureSamplerArray* object so effects can add texture | 131 * appends the necessary data to the TextureSamplerArray* object so effects can add texture |
129 * lookups to their code. This method is only meant to be called during the construction phase. | 132 * lookups to their code. This method is only meant to be called during the construction phase. |
130 */ | 133 */ |
131 void emitSamplers(GrGLProgramBuilder*, const GrEffect*, TextureSamplerArray* ); | 134 void emitSamplers(GrGLProgramBuilder*, const GrEffect&, TextureSamplerArray* ); |
132 | 135 |
133 /** | 136 /** |
134 * Helper for setData(). Binds all the textures for an effect. | 137 * Helper for setData(). Binds all the textures for an effect. |
135 */ | 138 */ |
136 void bindTextures(GrGpuGL*, const GrEffect*, int effectIdx); | 139 void bindTextures(GrGpuGL*, const GrEffect&, int effectIdx); |
137 | 140 |
138 struct Sampler { | 141 struct Sampler { |
139 SkDEBUGCODE(Sampler() : fTextureUnit(-1) {}) | 142 SkDEBUGCODE(Sampler() : fTextureUnit(-1) {}) |
140 UniformHandle fUniform; | 143 UniformHandle fUniform; |
141 int fTextureUnit; | 144 int fTextureUnit; |
142 }; | 145 }; |
143 | 146 |
144 SkTArray<GrGLEffect*> fGLEffects; | 147 SkTArray<GrGLEffect*> fGLEffects; |
145 SkTArray<SkSTArray<4, Sampler, true> > fSamplers; | 148 SkTArray<SkSTArray<4, Sampler, true> > fSamplers; |
146 | 149 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 void emitAttributes(GrGLFullProgramBuilder*, const GrEffectStage&); | 208 void emitAttributes(GrGLFullProgramBuilder*, const GrEffectStage&); |
206 | 209 |
207 /** | 210 /** |
208 * Helper for emitEffect(). Emits code to implement an effect's coord transf orms in the VS. | 211 * Helper for emitEffect(). Emits code to implement an effect's coord transf orms in the VS. |
209 * Varyings are added as an outputs of the VS and inputs to the FS. The vary ings may be either a | 212 * Varyings are added as an outputs of the VS and inputs to the FS. The vary ings may be either a |
210 * vec2f or vec3f depending upon whether perspective interpolation is requir ed or not. The names | 213 * vec2f or vec3f depending upon whether perspective interpolation is requir ed or not. The names |
211 * of the varyings in the VS and FS as well their types are appended to the | 214 * of the varyings in the VS and FS as well their types are appended to the |
212 * TransformedCoordsArray* object, which is in turn passed to the effect's e mitCode() function. | 215 * TransformedCoordsArray* object, which is in turn passed to the effect's e mitCode() function. |
213 */ | 216 */ |
214 void emitTransforms(GrGLFullProgramBuilder*, | 217 void emitTransforms(GrGLFullProgramBuilder*, |
215 const GrDrawEffect&, | 218 const GrEffectStage&, |
216 TransformedCoordsArray*); | 219 TransformedCoordsArray*); |
217 | 220 |
218 /** | 221 /** |
219 * Helper for setData(). Sets all the transform matrices for an effect. | 222 * Helper for setData(). Sets all the transform matrices for an effect. |
220 */ | 223 */ |
221 void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrD rawEffect&, int effectIdx); | 224 void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrE ffectStage&, |
222 void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrDrawEffect&, | 225 int effectIdx); |
226 void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&, | |
223 int effectIdx); | 227 int effectIdx); |
224 | 228 |
225 struct Transform { | 229 struct Transform { |
226 Transform() { fCurrentValue = SkMatrix::InvalidMatrix(); } | 230 Transform() { fCurrentValue = SkMatrix::InvalidMatrix(); } |
227 UniformHandle fHandle; | 231 UniformHandle fHandle; |
228 SkMatrix fCurrentValue; | 232 SkMatrix fCurrentValue; |
229 }; | 233 }; |
230 | 234 |
231 struct PathTransform { | 235 struct PathTransform { |
232 PathTransform() { fCurrentValue = SkMatrix::InvalidMatrix(); } | 236 PathTransform() { fCurrentValue = SkMatrix::InvalidMatrix(); } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 | 304 |
301 /** | 305 /** |
302 * Helper for emitEffect(). Allocates texture units from the builder for eac h transform in an | 306 * Helper for emitEffect(). Allocates texture units from the builder for eac h transform in an |
303 * effect. The transforms all use adjacent texture units. They either use tw o or three of the | 307 * effect. The transforms all use adjacent texture units. They either use tw o or three of the |
304 * coordinates at a given texture unit, depending on if they need perspectiv e interpolation. | 308 * coordinates at a given texture unit, depending on if they need perspectiv e interpolation. |
305 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[ 0])') as well as the | 309 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[ 0])') as well as the |
306 * types are appended to the TransformedCoordsArray* object, which is in tur n passed to the | 310 * types are appended to the TransformedCoordsArray* object, which is in tur n passed to the |
307 * effect's emitCode() function. | 311 * effect's emitCode() function. |
308 */ | 312 */ |
309 void setupPathTexGen(GrGLFragmentOnlyProgramBuilder*, | 313 void setupPathTexGen(GrGLFragmentOnlyProgramBuilder*, |
310 const GrDrawEffect&, | 314 const GrEffectStage&, |
311 TransformedCoordsArray*); | 315 TransformedCoordsArray*); |
312 | 316 |
313 /** | 317 /** |
314 * Helper for setData(). Sets the PathTexGen state for each transform in an effect. | 318 * Helper for setData(). Sets the PathTexGen state for each transform in an effect. |
315 */ | 319 */ |
316 void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); | 320 void setPathTexGenState(GrGpuGL*, const GrEffectStage&, int effectIdx); |
317 | 321 |
318 struct Transforms { | 322 struct Transforms { |
319 Transforms(uint32_t transformKey, int texCoordIndex) | 323 Transforms(uint32_t transformKey, int texCoordIndex) |
320 : fTransformKey(transformKey), fTexCoordIndex(texCoordIndex) {} | 324 : fTransformKey(transformKey), fTexCoordIndex(texCoordIndex) {} |
321 uint32_t fTransformKey; | 325 uint32_t fTransformKey; |
322 int fTexCoordIndex; | 326 int fTexCoordIndex; |
323 }; | 327 }; |
324 | 328 |
325 SkTArray<Transforms> fTransforms; | 329 SkTArray<Transforms> fTransforms; |
326 | 330 |
(...skipping 19 matching lines...) Expand all Loading... | |
346 */ | 350 */ |
347 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 351 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } |
348 private: | 352 private: |
349 GrGLFragmentOnlyProgramBuilder* fBuilder; | 353 GrGLFragmentOnlyProgramBuilder* fBuilder; |
350 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; | 354 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; |
351 typedef GrGLProgramEffectsBuilder INHERITED; | 355 typedef GrGLProgramEffectsBuilder INHERITED; |
352 }; | 356 }; |
353 | 357 |
354 | 358 |
355 #endif | 359 #endif |
OLD | NEW |