aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients/SkGradientShaderPriv.h
diff options
context:
space:
mode:
authorGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-14 21:06:15 +0000
committerGravatar rileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-14 21:06:15 +0000
commit50b2bcf321d0a6657679c26cfcf703b746cf0660 (patch)
treee807c3e2c0f8feb6021a75aaa1f7cf8405de0547 /src/effects/gradients/SkGradientShaderPriv.h
parent5224d7532da041ef1eee14274fd9f893d247b292 (diff)
Made gradient effects use GrTextureStripAtlas.
Review URL: https://codereview.appspot.com/6450131 git-svn-id: http://skia.googlecode.com/svn/trunk@5101 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects/gradients/SkGradientShaderPriv.h')
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 8152d5fb71..4c3b6c777f 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -220,6 +220,8 @@ class GrProgramStageFactory;
* determines the gradient value.
*/
+ class GrTextureStripAtlas;
+
// Base class for Gr gradient effects
class GrGradientEffect : public GrCustomStage {
public:
@@ -233,6 +235,14 @@ public:
GrTexture* texture(unsigned int index) const;
bool useTexture() const { return fUseTexture; }
+ bool useAtlas() const { return SkToBool(-1 != fRow); }
+ GrScalar getYCoord() const { GrAssert(fUseTexture); return fYCoord; };
+
+ bool isEqual(const GrCustomStage& stage) const {
+ const GrGradientEffect& s = static_cast<const GrGradientEffect&>(stage);
+ return INHERITED::isEqual(stage) && this->useAtlas() == s.useAtlas() &&
+ fYCoord == s.getYCoord();
+ }
protected:
@@ -252,6 +262,9 @@ protected:
private:
GrTexture* fTexture;
bool fUseTexture;
+ GrScalar fYCoord;
+ GrTextureStripAtlas* fAtlas;
+ int fRow;
typedef GrCustomStage INHERITED;
@@ -266,6 +279,12 @@ public:
GrGLGradientStage(const GrProgramStageFactory& factory);
virtual ~GrGLGradientStage();
+ virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
+ virtual void setData(const GrGLUniformManager&,
+ const GrCustomStage&,
+ const GrRenderTarget*,
+ int stageNum) SK_OVERRIDE;
+
// 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
void emitColorLookup(GrGLShaderBuilder* builder, const char* t,
@@ -273,6 +292,9 @@ public:
private:
+ GrScalar fCachedYCoord;
+ GrGLUniformManager::UniformHandle fFSYUni;
+
typedef GrGLProgramStage INHERITED;
};