| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 private: | 230 private: |
| 231 GrGLFullShaderBuilder* fBuilder; | 231 GrGLFullShaderBuilder* fBuilder; |
| 232 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects; | 232 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects; |
| 233 | 233 |
| 234 typedef GrGLProgramEffectsBuilder INHERITED; | 234 typedef GrGLProgramEffectsBuilder INHERITED; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 //////////////////////////////////////////////////////////////////////////////// | 237 //////////////////////////////////////////////////////////////////////////////// |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * This is a GrGLProgramEffects implementation that does coord transforms with t
he the built-in GL | 240 * This is a GrGLProgramEffects implementation that does coord transforms with |
| 241 * TexGen functionality. | 241 * the the NV_path_rendering PathTexGen functionality. |
| 242 */ | 242 */ |
| 243 class GrGLTexGenProgramEffects : public GrGLProgramEffects { | 243 class GrGLPathTexGenProgramEffects : public GrGLProgramEffects { |
| 244 public: | 244 public: |
| 245 virtual void setData(GrGpuGL*, | 245 virtual void setData(GrGpuGL*, |
| 246 const GrGLUniformManager&, | 246 const GrGLUniformManager&, |
| 247 const GrEffectStage* effectStages[]) SK_OVERRIDE; | 247 const GrEffectStage* effectStages[]) SK_OVERRIDE; |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 friend class GrGLTexGenProgramEffectsBuilder; | 250 friend class GrGLPathTexGenProgramEffectsBuilder; |
| 251 | 251 |
| 252 GrGLTexGenProgramEffects(int reserveCount) | 252 GrGLPathTexGenProgramEffects(int reserveCount) |
| 253 : INHERITED(reserveCount) | 253 : INHERITED(reserveCount) |
| 254 , fTransforms(reserveCount) { | 254 , fTransforms(reserveCount) { |
| 255 } | 255 } |
| 256 | 256 |
| 257 /** | 257 /** |
| 258 * Helper for GrGLProgramEffectsBuilder::emitEfffect(). This method is meant
to only be called | 258 * Helper for GrGLProgramEffectsBuilder::emitEfffect(). This method is meant
to only be called |
| 259 * during the construction phase. | 259 * during the construction phase. |
| 260 */ | 260 */ |
| 261 void emitEffect(GrGLFragmentOnlyShaderBuilder*, | 261 void emitEffect(GrGLFragmentOnlyShaderBuilder*, |
| 262 const GrEffectStage&, | 262 const GrEffectStage&, |
| 263 GrGLProgramEffects::EffectKey, | 263 GrGLProgramEffects::EffectKey, |
| 264 const char* outColor, | 264 const char* outColor, |
| 265 const char* inColor, | 265 const char* inColor, |
| 266 int stageIndex); | 266 int stageIndex); |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * Helper for emitEffect(). Allocates texture units from the builder for eac
h transform in an | 269 * Helper for emitEffect(). Allocates texture units from the builder for eac
h transform in an |
| 270 * effect. The transforms all use adjacent texture units. They either use tw
o or three of the | 270 * effect. The transforms all use adjacent texture units. They either use tw
o or three of the |
| 271 * coordinates at a given texture unit, depending on if they need perspectiv
e interpolation. | 271 * coordinates at a given texture unit, depending on if they need perspectiv
e interpolation. |
| 272 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[
0])') as well as the | 272 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[
0])') as well as the |
| 273 * types are appended to the TransformedCoordsArray* object, which is in tur
n passed to the | 273 * types are appended to the TransformedCoordsArray* object, which is in tur
n passed to the |
| 274 * effect's emitCode() function. | 274 * effect's emitCode() function. |
| 275 */ | 275 */ |
| 276 void setupTexGen(GrGLFragmentOnlyShaderBuilder*, | 276 void setupPathTexGen(GrGLFragmentOnlyShaderBuilder*, |
| 277 const GrEffectRef&, | 277 const GrEffectRef&, |
| 278 EffectKey, | 278 EffectKey, |
| 279 TransformedCoordsArray*); | 279 TransformedCoordsArray*); |
| 280 | 280 |
| 281 /** | 281 /** |
| 282 * Helper for setData(). Sets the TexGen state for each transform in an effe
ct. | 282 * Helper for setData(). Sets the PathTexGen state for each transform in an
effect. |
| 283 */ | 283 */ |
| 284 void setTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); | 284 void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx); |
| 285 | 285 |
| 286 struct Transforms { | 286 struct Transforms { |
| 287 Transforms(EffectKey transformKey, int texCoordIndex) | 287 Transforms(EffectKey transformKey, int texCoordIndex) |
| 288 : fTransformKey(transformKey), fTexCoordIndex(texCoordIndex) {} | 288 : fTransformKey(transformKey), fTexCoordIndex(texCoordIndex) {} |
| 289 EffectKey fTransformKey; | 289 EffectKey fTransformKey; |
| 290 int fTexCoordIndex; | 290 int fTexCoordIndex; |
| 291 }; | 291 }; |
| 292 | 292 |
| 293 SkTArray<Transforms> fTransforms; | 293 SkTArray<Transforms> fTransforms; |
| 294 | 294 |
| 295 typedef GrGLProgramEffects INHERITED; | 295 typedef GrGLProgramEffects INHERITED; |
| 296 }; | 296 }; |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * This class is used to construct a GrGLTexGenProgramEffects* object. | 299 * This class is used to construct a GrGLPathTexGenProgramEffects* object. |
| 300 */ | 300 */ |
| 301 class GrGLTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder { | 301 class GrGLPathTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder { |
| 302 public: | 302 public: |
| 303 GrGLTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int reserveC
ount); | 303 GrGLPathTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int rese
rveCount); |
| 304 virtual ~GrGLTexGenProgramEffectsBuilder() { } | 304 virtual ~GrGLPathTexGenProgramEffectsBuilder() { } |
| 305 | 305 |
| 306 virtual void emitEffect(const GrEffectStage&, | 306 virtual void emitEffect(const GrEffectStage&, |
| 307 GrGLProgramEffects::EffectKey, | 307 GrGLProgramEffects::EffectKey, |
| 308 const char* outColor, | 308 const char* outColor, |
| 309 const char* inColor, | 309 const char* inColor, |
| 310 int stageIndex) SK_OVERRIDE; | 310 int stageIndex) SK_OVERRIDE; |
| 311 | 311 |
| 312 /** | 312 /** |
| 313 * Finalizes the building process and returns the effect array. After this c
all, the builder | 313 * Finalizes the building process and returns the effect array. After this c
all, the builder |
| 314 * becomes invalid. | 314 * becomes invalid. |
| 315 */ | 315 */ |
| 316 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 316 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } |
| 317 | 317 |
| 318 private: | 318 private: |
| 319 GrGLFragmentOnlyShaderBuilder* fBuilder; | 319 GrGLFragmentOnlyShaderBuilder* fBuilder; |
| 320 SkAutoTDelete<GrGLTexGenProgramEffects> fProgramEffects; | 320 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; |
| 321 | 321 |
| 322 typedef GrGLProgramEffectsBuilder INHERITED; | 322 typedef GrGLProgramEffectsBuilder INHERITED; |
| 323 }; | 323 }; |
| 324 | 324 |
| 325 #endif | 325 #endif |
| OLD | NEW |