| 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 "GrGLUniformManager.h" |  | 
| 13 #include "GrTexture.h" | 12 #include "GrTexture.h" | 
| 14 #include "GrTextureAccess.h" | 13 #include "GrTextureAccess.h" | 
|  | 14 #include "GrGLUniformManager.h" | 
| 15 | 15 | 
| 16 class GrEffect; | 16 class GrEffect; | 
| 17 class GrEffectStage; | 17 class GrEffectStage; | 
| 18 class GrGLVertexProgramEffectsBuilder; | 18 class GrGLVertexProgramEffectsBuilder; | 
| 19 class GrGLShaderBuilder; | 19 class GrGLShaderBuilder; | 
| 20 class GrGLFullShaderBuilder; | 20 class GrGLFullShaderBuilder; | 
| 21 class GrGLFragmentOnlyShaderBuilder; | 21 class GrGLFragmentOnlyShaderBuilder; | 
| 22 | 22 | 
| 23 /** | 23 /** | 
| 24  * 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 | 
| 25  * 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 | 
| 26  * state and shader uniforms. | 26  * state and shader uniforms. | 
| 27  */ | 27  */ | 
| 28 class GrGLProgramEffects : public SkRefCnt { | 28 class GrGLProgramEffects : public SkRefCnt { | 
| 29 public: | 29 public: | 
| 30     typedef GrBackendEffectFactory::EffectKey EffectKey; | 30     typedef GrBackendEffectFactory::EffectKey EffectKey; | 
| 31     typedef GrGLUniformManager::UniformHandle UniformHandle; | 31     typedef GrGLUniformManager::UniformHandle UniformHandle; | 
| 32 | 32 | 
| 33     /** | 33     /** | 
| 34      * This class emits some of the code inserted into the shaders for an effect
     . The code it | 34      * These methods generate different portions of an effect's final key. | 
| 35      * creates may be dependent on properties of the effect that the effect itse
     lf doesn't use |  | 
| 36      * in its key (e.g. the pixel format of textures used). So this class insert
     s a meta-key for |  | 
| 37      * every effect using this function. It is also responsible for inserting th
     e effect's class ID |  | 
| 38      * which must be different for every GrEffect subclass. It can fail if an ef
     fect uses too many |  | 
| 39      * textures, attributes, etc for the space allotted in the meta-key. |  | 
| 40      */ | 35      */ | 
| 41     static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectK
     eyBuilder*); | 36     static EffectKey GenAttribKey(const GrDrawEffect&); | 
|  | 37     static EffectKey GenTransformKey(const GrDrawEffect&); | 
|  | 38     static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&); | 
| 42 | 39 | 
| 43     virtual ~GrGLProgramEffects(); | 40     virtual ~GrGLProgramEffects(); | 
| 44 | 41 | 
| 45     /** | 42     /** | 
| 46      * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ
     es the next | 43      * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ
     es the next | 
| 47      * available unit to *texUnitIdx when it returns. | 44      * available unit to *texUnitIdx when it returns. | 
| 48      */ | 45      */ | 
| 49     void initSamplers(const GrGLUniformManager&, int* texUnitIdx); | 46     void initSamplers(const GrGLUniformManager&, int* texUnitIdx); | 
| 50 | 47 | 
| 51     /** | 48     /** | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 94 | 91 | 
| 95     private: | 92     private: | 
| 96         UniformHandle fSamplerUniform; | 93         UniformHandle fSamplerUniform; | 
| 97         uint32_t      fConfigComponentMask; | 94         uint32_t      fConfigComponentMask; | 
| 98         char          fSwizzle[5]; | 95         char          fSwizzle[5]; | 
| 99     }; | 96     }; | 
| 100 | 97 | 
| 101     typedef SkTArray<TextureSampler> TextureSamplerArray; | 98     typedef SkTArray<TextureSampler> TextureSamplerArray; | 
| 102 | 99 | 
| 103 protected: | 100 protected: | 
| 104     /** |  | 
| 105      * Helpers for GenEffectMetaKey. |  | 
| 106      */ |  | 
| 107     static EffectKey GenAttribKey(const GrDrawEffect&); |  | 
| 108     static EffectKey GenTransformKey(const GrDrawEffect&); |  | 
| 109     static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&); |  | 
| 110 |  | 
| 111     GrGLProgramEffects(int reserveCount) | 101     GrGLProgramEffects(int reserveCount) | 
| 112         : fGLEffects(reserveCount) | 102         : fGLEffects(reserveCount) | 
| 113         , fSamplers(reserveCount) { | 103         , fSamplers(reserveCount) { | 
| 114     } | 104     } | 
| 115 | 105 | 
| 116     /** | 106     /** | 
| 117      * 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 | 
| 118      * 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 | 
| 119      * 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. | 
| 120      */ | 110      */ | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 327     GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 317     GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 
| 328 | 318 | 
| 329 private: | 319 private: | 
| 330     GrGLFragmentOnlyShaderBuilder*          fBuilder; | 320     GrGLFragmentOnlyShaderBuilder*          fBuilder; | 
| 331     SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; | 321     SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; | 
| 332 | 322 | 
| 333     typedef GrGLProgramEffectsBuilder INHERITED; | 323     typedef GrGLProgramEffectsBuilder INHERITED; | 
| 334 }; | 324 }; | 
| 335 | 325 | 
| 336 #endif | 326 #endif | 
| OLD | NEW | 
|---|