| 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 SkGradientShaderPriv_DEFINED |    8 #ifndef SkGradientShaderPriv_DEFINED | 
|    9 #define SkGradientShaderPriv_DEFINED |    9 #define SkGradientShaderPriv_DEFINED | 
|   10  |   10  | 
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  267 }; |  267 }; | 
|  268  |  268  | 
|  269 /////////////////////////////////////////////////////////////////////////////// |  269 /////////////////////////////////////////////////////////////////////////////// | 
|  270  |  270  | 
|  271 // Base class for GL gradient effects |  271 // Base class for GL gradient effects | 
|  272 class GrGLGradientEffect : public GrGLEffect { |  272 class GrGLGradientEffect : public GrGLEffect { | 
|  273 public: |  273 public: | 
|  274     GrGLGradientEffect(const GrBackendEffectFactory& factory); |  274     GrGLGradientEffect(const GrBackendEffectFactory& factory); | 
|  275     virtual ~GrGLGradientEffect(); |  275     virtual ~GrGLGradientEffect(); | 
|  276  |  276  | 
|  277     virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVE
     RRIDE; |  277     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
     RIDE; | 
|  278  |  278  | 
|  279 protected: |  279 protected: | 
|  280     /** |  280     /** | 
|  281      * Subclasses must reserve the lower kMatrixKeyBitCnt of their key for use b
     y |  281      * Subclasses must reserve the lower kMatrixKeyBitCnt of their key for use b
     y | 
|  282      * GrGLGradientEffect. |  282      * GrGLGradientEffect. | 
|  283      */ |  283      */ | 
|  284     enum { |  284     enum { | 
|  285         kMatrixKeyBitCnt = GrGLEffectMatrix::kKeyBits, |  285         kMatrixKeyBitCnt = GrGLEffectMatrix::kKeyBits, | 
|  286         kMatrixKeyMask = (1 << kMatrixKeyBitCnt) - 1, |  286         kMatrixKeyMask = (1 << kMatrixKeyBitCnt) - 1, | 
|  287     }; |  287     }; | 
|  288  |  288  | 
|  289     /** |  289     /** | 
|  290      * Subclasses must call this. It will return a value restricted to the lower
      kMatrixKeyBitCnt |  290      * Subclasses must call this. It will return a value restricted to the lower
      kMatrixKeyBitCnt | 
|  291      * bits. |  291      * bits. | 
|  292      */ |  292      */ | 
|  293     static EffectKey GenMatrixKey(const GrEffectStage& s); |  293     static EffectKey GenMatrixKey(const GrDrawEffect&); | 
|  294  |  294  | 
|  295     /** |  295     /** | 
|  296      * Inserts code to implement the GrGradientEffect's matrix. This should be c
     alled before a |  296      * Inserts code to implement the GrGradientEffect's matrix. This should be c
     alled before a | 
|  297      * subclass emits its own code. The name of the 2D coords is output via fsCo
     ordName and already |  297      * subclass emits its own code. The name of the 2D coords is output via fsCo
     ordName and already | 
|  298      * incorporates any perspective division. The caller can also optionally ret
     rieve the name of |  298      * incorporates any perspective division. The caller can also optionally ret
     rieve the name of | 
|  299      * the varying inserted in the VS and its type, which may be either vec2f or
      vec3f depending |  299      * the varying inserted in the VS and its type, which may be either vec2f or
      vec3f depending | 
|  300      * upon whether the matrix has perspective or not. It is not necessary to ma
     sk the key before |  300      * upon whether the matrix has perspective or not. It is not necessary to ma
     sk the key before | 
|  301      * calling. |  301      * calling. | 
|  302      */ |  302      */ | 
|  303     void setupMatrix(GrGLShaderBuilder* builder, |  303     void setupMatrix(GrGLShaderBuilder* builder, | 
|  304                      EffectKey key, |  304                      EffectKey key, | 
|  305                      const char* vertexCoords, |  | 
|  306                      const char** fsCoordName, |  305                      const char** fsCoordName, | 
|  307                      const char** vsVaryingName = NULL, |  306                      const char** vsVaryingName = NULL, | 
|  308                      GrSLType* vsVaryingType = NULL); |  307                      GrSLType* vsVaryingType = NULL); | 
|  309  |  308  | 
|  310     // Emits the uniform used as the y-coord to texture samples in derived class
     es. Subclasses |  309     // Emits the uniform used as the y-coord to texture samples in derived class
     es. Subclasses | 
|  311     // should call this method from their emitCode(). |  310     // should call this method from their emitCode(). | 
|  312     void emitYCoordUniform(GrGLShaderBuilder* builder); |  311     void emitYCoordUniform(GrGLShaderBuilder* builder); | 
|  313  |  312  | 
|  314     // emit code that gets a fragment's color from an expression for t; for now 
     this always uses the |  313     // emit code that gets a fragment's color from an expression for t; for now 
     this always uses the | 
|  315     // texture, but for simpler cases we'll be able to lerp. Subclasses should c
     all this method from |  314     // texture, but for simpler cases we'll be able to lerp. Subclasses should c
     all this method from | 
|  316     // their emitCode(). |  315     // their emitCode(). | 
|  317     void emitColorLookup(GrGLShaderBuilder* builder, |  316     void emitColorLookup(GrGLShaderBuilder* builder, | 
|  318                          const char* gradientTValue, |  317                          const char* gradientTValue, | 
|  319                          const char* outputColor, |  318                          const char* outputColor, | 
|  320                          const char* inputColor, |  319                          const char* inputColor, | 
|  321                          const GrGLShaderBuilder::TextureSampler&); |  320                          const GrGLShaderBuilder::TextureSampler&); | 
|  322  |  321  | 
|  323 private: |  322 private: | 
 |  323     static const GrEffect::CoordsType kCoordsType = GrEffect::kLocal_CoordsType; | 
 |  324  | 
|  324     SkScalar fCachedYCoord; |  325     SkScalar fCachedYCoord; | 
|  325     GrGLUniformManager::UniformHandle fFSYUni; |  326     GrGLUniformManager::UniformHandle fFSYUni; | 
|  326     GrGLEffectMatrix fEffectMatrix; |  327     GrGLEffectMatrix fEffectMatrix; | 
|  327  |  328  | 
|  328     typedef GrGLEffect INHERITED; |  329     typedef GrGLEffect INHERITED; | 
|  329 }; |  330 }; | 
|  330  |  331  | 
|  331 #endif |  332 #endif | 
|  332  |  333  | 
|  333 #endif |  334 #endif | 
| OLD | NEW |