| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 GrGLEffect_DEFINED | 8 #ifndef GrGLEffect_DEFINED |
| 9 #define GrGLEffect_DEFINED | 9 #define GrGLEffect_DEFINED |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 The GrGLEffect subclass must also have a constructor of the form: | 27 The GrGLEffect subclass must also have a constructor of the form: |
| 28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEf
fect&) | 28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEf
fect&) |
| 29 | 29 |
| 30 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). | 30 These objects are created by the factory object returned by the GrEffect::ge
tFactory(). |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 class GrGLTexture; | 33 class GrGLTexture; |
| 34 class GrGLGeometryProcessor; | 34 class GrGLGeometryProcessor; |
| 35 | 35 |
| 36 class GrGLEffect { | 36 class GrGLEffect { |
| 37 public: |
| 38 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 37 | 39 |
| 38 public: | 40 /** |
| 39 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; | 41 * Passed to GrGLEffects so they can add transformed coordinates to their sh
ader code. |
| 40 typedef GrGLProgramEffects::TextureSampler TextureSampler; | 42 */ |
| 41 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; | 43 typedef GrShaderVar TransformedCoords; |
| 44 typedef SkTArray<GrShaderVar> TransformedCoordsArray; |
| 45 |
| 46 /** |
| 47 * Passed to GrGLEffects so they can add texture reads to their shader code. |
| 48 */ |
| 49 class TextureSampler { |
| 50 public: |
| 51 TextureSampler(UniformHandle uniform, const GrTextureAccess& access) |
| 52 : fSamplerUniform(uniform) |
| 53 , fConfigComponentMask(GrPixelConfigComponentMask(access.getTexture(
)->config())) { |
| 54 SkASSERT(0 != fConfigComponentMask); |
| 55 memcpy(fSwizzle, access.getSwizzle(), 5); |
| 56 } |
| 57 |
| 58 // bitfield of GrColorComponentFlags present in the texture's config. |
| 59 uint32_t configComponentMask() const { return fConfigComponentMask; } |
| 60 // this is .abcd |
| 61 const char* swizzle() const { return fSwizzle; } |
| 62 |
| 63 private: |
| 64 UniformHandle fSamplerUniform; |
| 65 uint32_t fConfigComponentMask; |
| 66 char fSwizzle[5]; |
| 67 |
| 68 friend class GrGLShaderBuilder; |
| 69 }; |
| 70 |
| 71 typedef SkTArray<TextureSampler> TextureSamplerArray; |
| 42 | 72 |
| 43 GrGLEffect(const GrBackendEffectFactory& factory) | 73 GrGLEffect(const GrBackendEffectFactory& factory) |
| 44 : fFactory(factory) | 74 : fFactory(factory) |
| 45 , fIsVertexEffect(false) { | 75 , fIsVertexEffect(false) { |
| 46 } | 76 } |
| 47 | 77 |
| 48 virtual ~GrGLEffect() {} | 78 virtual ~GrGLEffect() {} |
| 49 | 79 |
| 50 /** Called when the program stage should insert its code into the shaders. T
he code in each | 80 /** Called when the program stage should insert its code into the shaders. T
he code in each |
| 51 shader will be in its own block ({}) and so locally scoped names will no
t collide across | 81 shader will be in its own block ({}) and so locally scoped names will no
t collide across |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 protected: | 123 protected: |
| 94 const GrBackendEffectFactory& fFactory; | 124 const GrBackendEffectFactory& fFactory; |
| 95 | 125 |
| 96 private: | 126 private: |
| 97 friend class GrGLGeometryProcessor; // to set fIsVertexEffect | 127 friend class GrGLGeometryProcessor; // to set fIsVertexEffect |
| 98 | 128 |
| 99 bool fIsVertexEffect; | 129 bool fIsVertexEffect; |
| 100 }; | 130 }; |
| 101 | 131 |
| 102 #endif | 132 #endif |
| OLD | NEW |