Chromium Code Reviews| Index: src/effects/gradients/SkGradientShaderPriv.h |
| diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h |
| index 31cc9f26171c6184b4535004ea1388d2de024bc4..875872f07b94eb214480df7f12d712e2f5172cb8 100644 |
| --- a/src/effects/gradients/SkGradientShaderPriv.h |
| +++ b/src/effects/gradients/SkGradientShaderPriv.h |
| @@ -249,6 +249,8 @@ public: |
| SkScalar getYCoord() const { return fYCoord; }; |
| const SkMatrix& getMatrix() const { return fMatrix;} |
| + int numColors; |
|
reed1
2013/08/13 12:33:41
nit:
- does this guy really need to be public?
- w
dierk
2013/08/13 19:50:17
Done.
|
| + |
| virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE; |
| protected: |
| @@ -301,6 +303,21 @@ protected: |
| kMatrixKeyMask = (1 << kMatrixKeyBitCnt) - 1, |
| }; |
| + static inline bool is2Color(const GrGradientEffect& e){ |
|
bsalomon
2013/08/13 14:28:37
How about an enum named ColorType (or something li
dierk
2013/08/13 19:50:17
Done.
|
| + return e.numColors == 2; |
| + } |
| + static inline bool is3Color(const GrGradientEffect& e){ |
| + return e.numColors == 3; |
| + } |
| + |
| + static inline bool is2Color(const EffectKey key){ |
| + return (key & 0x4000) == 0x4000; |
| + } |
| + static inline bool is3Color(const EffectKey key){ |
| + return (key & 0x6000) == 0x6000; |
| + } |
| + |
| + |
| /** |
| * Subclasses must call this. It will return a value restricted to the lower kMatrixKeyBitCnt |
| * bits. |
| @@ -323,22 +340,27 @@ protected: |
| // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses |
| // should call this method from their emitCode(). |
| - void emitYCoordUniform(GrGLShaderBuilder* builder); |
| + void emitUniforms(GrGLShaderBuilder* builder, EffectKey key); |
| + |
| - // emit code that gets a fragment's color from an expression for t; for now this always uses the |
| - // texture, but for simpler cases we'll be able to lerp. Subclasses should call this method from |
| + // emit code that gets a fragment's color from an expression for t; Only used if 4 or more |
|
bsalomon
2013/08/13 14:28:37
Do you mean the sampler array is only used for 4+?
dierk
2013/08/13 19:50:17
Done.
|
| + // colors, a simpler lerp is used for 2 and 3 colors. Subclasses should call this method from |
| // their emitCode(). |
| - void emitColorLookup(GrGLShaderBuilder* builder, |
| - const char* gradientTValue, |
| - const char* outputColor, |
| - const char* inputColor, |
| - const GrGLShaderBuilder::TextureSampler&); |
| + void emitColor(GrGLShaderBuilder* builder, |
| + const char* gradientTValue, |
| + EffectKey key, |
| + const char* outputColor, |
| + const char* inputColor, |
| + const GrGLShaderBuilder::TextureSamplerArray& samplers); |
| private: |
| static const GrEffect::CoordsType kCoordsType = GrEffect::kLocal_CoordsType; |
| SkScalar fCachedYCoord; |
| GrGLUniformManager::UniformHandle fFSYUni; |
| + GrGLUniformManager::UniformHandle fColorStartUni; |
| + GrGLUniformManager::UniformHandle fColorMidUni; |
| + GrGLUniformManager::UniformHandle fColorEndUni; |
| GrGLEffectMatrix fEffectMatrix; |
| typedef GrGLEffect INHERITED; |