Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Unified Diff: src/effects/gradients/SkGradientShaderPriv.h

Issue 22854005: GPU Gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reverted defer flag to true Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {
reed1 2013/08/15 21:32:15 nit: not need for 'inline' in a class header when
dierk 2013/08/16 16:59:56 Done.
+ return fColorType;
+ }
+ const inline SkColor* getColors() const {
reed1 2013/08/15 21:32:15 1. same nit about not needing 'inline' here 2. ver
reed1 2013/08/15 21:32:15 API question: given that getColors is only valid f
dierk 2013/08/16 16:59:56 Done.
+ return &fColors[0];
+ }
protected:
@@ -276,6 +289,9 @@ private:
int fRow;
SkMatrix fMatrix;
bool fIsOpaque;
+ int fNumColors;
+ ColorType fColorType;
+ SkColor fColors[3];
reed1 2013/08/15 21:32:15 // Short comment on why [3] here or maybe an enum
dierk 2013/08/16 16:59:56 Done.
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){
reed1 2013/08/15 21:32:15 again with the 'inline' :)
dierk 2013/08/16 16:59:56 Done.
+ 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;

Powered by Google App Engine
This is Rietveld 408576698