Move GPU gradients into src/effects/gradients.
Review URL: https://codereview.appspot.com/6453055

git-svn-id: http://skia.googlecode.com/svn/trunk@4805 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index 49249b5..23de48c 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -18,9 +18,9 @@
 #include "SkTemplates.h"

 #include "SkBitmapCache.h"

 #include "SkShader.h"

-#include "effects/GrGradientEffects.h"

 #include "GrSamplerState.h"

 #include "SkGr.h"

+#include "gl/GrGLProgramStage.h"

 

 #ifndef SK_DISABLE_DITHER_32BIT_GRADIENT

     #define USE_DITHER_32BIT_GRADIENT

@@ -189,5 +189,76 @@
     typedef SkShader INHERITED;

 };

 

+///////////////////////////////////////////////////////////////////////////////

+

+class GrSamplerState;

+class GrProgramStageFactory;

+

+/*

+ * The intepretation of the texture matrix depends on the sample mode. The

+ * texture matrix is applied both when the texture coordinates are explicit

+ * and  when vertex positions are used as texture  coordinates. In the latter

+ * case the texture matrix is applied to the pre-view-matrix position 

+ * values.

+ *

+ * Normal SampleMode

+ *  The post-matrix texture coordinates are in normalize space with (0,0) at

+ *  the top-left and (1,1) at the bottom right.

+ * RadialGradient

+ *  The matrix specifies the radial gradient parameters.

+ *  (0,0) in the post-matrix space is center of the radial gradient.

+ * Radial2Gradient

+ *   Matrix transforms to space where first circle is centered at the

+ *   origin. The second circle will be centered (x, 0) where x may be 

+ *   0 and is provided by setRadial2Params. The post-matrix space is 

+ *   normalized such that 1 is the second radius - first radius.

+ * SweepGradient

+ *  The angle from the origin of texture coordinates in post-matrix space

+ *  determines the gradient value.

+ */

+

+// Base class for Gr gradient effects

+class GrGradientEffect : public GrCustomStage {

+public:

+

+    GrGradientEffect(GrTexture* texture);

+    GrGradientEffect(GrContext* ctx, const SkShader& shader, 

+                     GrSamplerState* sampler);

+

+    virtual ~GrGradientEffect();

+

+    unsigned int numTextures() const;

+    GrTexture* texture(unsigned int index) const;

+

+    bool useTexture() const { return fUseTexture; }

+

+private:

+

+    GrTexture* fTexture;

+    bool fUseTexture;

+

+    typedef GrCustomStage INHERITED;

+

+};

+

+///////////////////////////////////////////////////////////////////////////////

+

+// Base class for GL gradient custom stages

+class GrGLGradientStage : public GrGLProgramStage {

+public:

+

+    GrGLGradientStage(const GrProgramStageFactory& factory);

+    virtual ~GrGLGradientStage();

+

+    // 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, 

+                         const char* outputColor, const char* samplerName);

+

+private:

+

+    typedef GrGLProgramStage INHERITED;

+};

+

 #endif