Chromium Code Reviews| Index: src/gpu/gl/GrGLProgramEffects.h |
| diff --git a/src/gpu/gl/GrGLProgramEffects.h b/src/gpu/gl/GrGLProgramEffects.h |
| index f6f975ae4e76106a4c342e6b70d02248392657dc..837398b38f6cb9ce56e2f5b3c49c95954015e738 100644 |
| --- a/src/gpu/gl/GrGLProgramEffects.h |
| +++ b/src/gpu/gl/GrGLProgramEffects.h |
| @@ -18,6 +18,7 @@ class GrGLProgramEffectsBuilder; |
| class GrGLVertexProgramEffectsBuilder; |
| class GrGLShaderBuilder; |
| class GrGLFullShaderBuilder; |
| +class GrGLFragmentOnlyShaderBuilder; |
| /** |
| * This class encapsulates an array of GrGLEffects and their supporting data (coord transforms |
| @@ -56,7 +57,7 @@ public: |
| */ |
| class TransformedCoords { |
| public: |
| - TransformedCoords(const char* name, GrSLType type) |
| + TransformedCoords(const SkString& name, GrSLType type) |
| : fName(name), fType(type) { |
| } |
| @@ -155,6 +156,43 @@ private: |
| typedef GrGLProgramEffects INHERITED; |
| }; |
| +/** |
| + * This is a GrGLProgramEffects implementation that does coord transforms with the the built-in GL |
| + * TexGen functionality. |
| + */ |
| +class GrGLTexGenProgramEffects : public GrGLProgramEffects { |
| +public: |
| + virtual void setData(GrGpuGL*, |
| + const GrGLUniformManager&, |
| + const GrEffectStage* effectStages[]) SK_OVERRIDE; |
| + |
| +private: |
| + friend class GrGLTexGenProgramEffectsBuilder; |
| + |
| + GrGLTexGenProgramEffects(int reserveCount) |
| + : INHERITED(reserveCount) |
| +#ifdef SK_DEBUG |
| + , fFirstTexCoordIdx(0) |
|
Kimmo Kinnunen
2013/10/04 11:02:33
This variable is never set in release mode. Causes
|
| + , fNumTexCoordSets(0) |
| +#endif |
| + , fTransformKeys(reserveCount) { |
| + } |
| + |
| + /** |
| + * Helper for setData(). Sets the TexGen state for each transform in an effect. The transforms |
| + * use adjacent texture units, starting with *texCoordIdx. Increments *texCoordIdx by the number |
| + * of transforms before returning. |
| + */ |
| + void setTexGenState(GrGpuGL*, const GrDrawEffect&, int* texCoordIdx, int effectIdx); |
| + |
| + int fFirstTexCoordIdx; |
| + SkDEBUGCODE(int fNumTexCoordSets;) |
| + SkTArray<EffectKey, true> fTransformKeys; |
| + |
| + typedef GrGLProgramEffects INHERITED; |
| +}; |
| + |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| /** |
| @@ -224,4 +262,42 @@ private: |
| typedef GrGLProgramEffectsBuilder INHERITED; |
| }; |
| +/** |
| + * This class is used by GrGLFragmentOnlyBuilder to construct a GrGLTexGenProgramEffects. |
| + */ |
| +class GrGLTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder { |
| +public: |
| + GrGLTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int reserveCount); |
| + |
| + virtual void emitEffect(const GrEffectStage&, |
| + GrGLProgramEffects::EffectKey, |
| + const char* outColor, |
| + const char* inColor, |
| + int stageIndex) SK_OVERRIDE; |
| + |
| + /** |
| + * Finalizes the building process and returns the effect array. After this call, the builder |
| + * becomes invalid. |
| + */ |
| + GrGLProgramEffects* finish() { return fProgramEffects.detach(); } |
| + |
| +private: |
| + /** |
| + * Helper for emitEffect(). Allocates texture units from the builder for each transform in an |
| + * effect. The transforms all use adjacent texture units. They either use two or three of the |
| + * coordinates at a given texture unit, depending on if they need perspective interpolation. |
| + * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[0])') as well as the |
| + * types are appended to the TransformedCoordsArray* object, which is in turn passed to the |
| + * effect's emitCode() function. |
| + */ |
| + void setupTexGen(const GrEffectRef&, |
| + GrGLProgramEffects::EffectKey, |
| + GrGLProgramEffects::TransformedCoordsArray*); |
| + |
| + GrGLFragmentOnlyShaderBuilder* fBuilder; |
| + SkAutoTDelete<GrGLTexGenProgramEffects> fProgramEffects; |
| + |
| + typedef GrGLProgramEffectsBuilder INHERITED; |
| +}; |
| + |
| #endif |