| Index: src/effects/gradients/SkGradientShaderPriv.h
|
| diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
|
| index 31cc9f26171c6184b4535004ea1388d2de024bc4..4280d9bfb13e3eda2a19b0a648034a595d936829 100644
|
| --- a/src/effects/gradients/SkGradientShaderPriv.h
|
| +++ b/src/effects/gradients/SkGradientShaderPriv.h
|
| @@ -250,6 +250,19 @@ public:
|
| const SkMatrix& getMatrix() const { return fMatrix;}
|
|
|
| virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
|
| +
|
| + enum ColorType {
|
| + kTwo_ColorType,
|
| + kThree_ColorType,
|
| + kTexture_ColorType
|
| + };
|
| +
|
| + inline ColorType getColorType() const {
|
| + return fColorType;
|
| + }
|
| + const inline SkColor* getColors() const {
|
| + return &fColors[0];
|
| + }
|
|
|
| protected:
|
|
|
| @@ -276,6 +289,9 @@ private:
|
| int fRow;
|
| SkMatrix fMatrix;
|
| bool fIsOpaque;
|
| + int fNumColors;
|
| + ColorType fColorType;
|
| + SkColor fColors[3];
|
|
|
| typedef GrEffect INHERITED;
|
|
|
| @@ -299,13 +315,25 @@ protected:
|
| enum {
|
| kMatrixKeyBitCnt = GrGLEffectMatrix::kKeyBits,
|
| kMatrixKeyMask = (1 << kMatrixKeyBitCnt) - 1,
|
| +
|
| + kTwoColorKey = 2 << kMatrixKeyBitCnt,
|
| + kThreeColorKey = 3 << kMatrixKeyBitCnt,
|
| + kColorKeyMask = kTwoColorKey | kThreeColorKey
|
| };
|
|
|
| + static inline GrGradientEffect::ColorType getColorType(EffectKey key){
|
| + if (kTwoColorKey == (key & kColorKeyMask)) {
|
| + return GrGradientEffect::kTwo_ColorType;
|
| + } else if (kThreeColorKey == (key & kColorKeyMask)) {
|
| + return GrGradientEffect::kThree_ColorType;
|
| + } else {return GrGradientEffect::kTexture_ColorType;}
|
| + }
|
| +
|
| /**
|
| * Subclasses must call this. It will return a value restricted to the lower kMatrixKeyBitCnt
|
| * bits.
|
| */
|
| - static EffectKey GenMatrixKey(const GrDrawEffect&);
|
| + static EffectKey GenBaseGradientKey(const GrDrawEffect&);
|
|
|
| /**
|
| * Inserts code to implement the GrGradientEffect's matrix. This should be called before a
|
| @@ -323,22 +351,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
|
| - // their emitCode().
|
| - void emitColorLookup(GrGLShaderBuilder* builder,
|
| - const char* gradientTValue,
|
| - const char* outputColor,
|
| - const char* inputColor,
|
| - const GrGLShaderBuilder::TextureSampler&);
|
| + // emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
|
| + // control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
|
| + // native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
|
| + 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;
|
|
|