| 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" |
| 12 #include "GrTexture.h" | 13 #include "GrTexture.h" |
| 13 #include "GrTextureAccess.h" | 14 #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 * These methods generate different portions of an effect's final key. | 34 * This class emits some of the code inserted into the shaders for an effect
. The code it |
| 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. |
| 35 */ | 40 */ |
| 36 static EffectKey GenAttribKey(const GrDrawEffect&); | 41 static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectK
eyBuilder*); |
| 37 static EffectKey GenTransformKey(const GrDrawEffect&); | |
| 38 static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&); | |
| 39 | 42 |
| 40 virtual ~GrGLProgramEffects(); | 43 virtual ~GrGLProgramEffects(); |
| 41 | 44 |
| 42 /** | 45 /** |
| 43 * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ
es the next | 46 * Assigns a texture unit to each sampler. It starts on *texUnitIdx and writ
es the next |
| 44 * available unit to *texUnitIdx when it returns. | 47 * available unit to *texUnitIdx when it returns. |
| 45 */ | 48 */ |
| 46 void initSamplers(const GrGLUniformManager&, int* texUnitIdx); | 49 void initSamplers(const GrGLUniformManager&, int* texUnitIdx); |
| 47 | 50 |
| 48 /** | 51 /** |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 94 |
| 92 private: | 95 private: |
| 93 UniformHandle fSamplerUniform; | 96 UniformHandle fSamplerUniform; |
| 94 uint32_t fConfigComponentMask; | 97 uint32_t fConfigComponentMask; |
| 95 char fSwizzle[5]; | 98 char fSwizzle[5]; |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 typedef SkTArray<TextureSampler> TextureSamplerArray; | 101 typedef SkTArray<TextureSampler> TextureSamplerArray; |
| 99 | 102 |
| 100 protected: | 103 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 |
| 101 GrGLProgramEffects(int reserveCount) | 111 GrGLProgramEffects(int reserveCount) |
| 102 : fGLEffects(reserveCount) | 112 : fGLEffects(reserveCount) |
| 103 , fSamplers(reserveCount) { | 113 , fSamplers(reserveCount) { |
| 104 } | 114 } |
| 105 | 115 |
| 106 /** | 116 /** |
| 107 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t
exture accesses and | 117 * Helper for emitEffect() in a subclasses. Emits uniforms for an effect's t
exture accesses and |
| 108 * appends the necessary data to the TextureSamplerArray* object so effects
can add texture | 118 * appends the necessary data to the TextureSamplerArray* object so effects
can add texture |
| 109 * lookups to their code. This method is only meant to be called during the
construction phase. | 119 * lookups to their code. This method is only meant to be called during the
construction phase. |
| 110 */ | 120 */ |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } | 327 GrGLProgramEffects* finish() { return fProgramEffects.detach(); } |
| 318 | 328 |
| 319 private: | 329 private: |
| 320 GrGLFragmentOnlyShaderBuilder* fBuilder; | 330 GrGLFragmentOnlyShaderBuilder* fBuilder; |
| 321 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; | 331 SkAutoTDelete<GrGLPathTexGenProgramEffects> fProgramEffects; |
| 322 | 332 |
| 323 typedef GrGLProgramEffectsBuilder INHERITED; | 333 typedef GrGLProgramEffectsBuilder INHERITED; |
| 324 }; | 334 }; |
| 325 | 335 |
| 326 #endif | 336 #endif |
| OLD | NEW |