Allow GrGLEffects to produce variable length keys.
authorbsalomon <bsalomon@google.com>
Mon, 21 Jul 2014 15:03:14 +0000 (08:03 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 21 Jul 2014 15:03:14 +0000 (08:03 -0700)
R=robertphillips@google.com, jvanverth@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/385713005

48 files changed:
include/gpu/GrBackendEffectFactory.h
include/gpu/GrEffect.h
include/gpu/GrTBackendEffectFactory.h
src/core/SkXfermode.cpp
src/effects/SkAlphaThresholdFilter.cpp
src/effects/SkArithmeticMode.cpp
src/effects/SkBlurMaskFilter.cpp
src/effects/SkColorFilters.cpp
src/effects/SkColorMatrixFilter.cpp
src/effects/SkDisplacementMapEffect.cpp
src/effects/SkLightingImageFilter.cpp
src/effects/SkLumaColorFilter.cpp
src/effects/SkMagnifierImageFilter.cpp
src/effects/SkMatrixConvolutionImageFilter.cpp
src/effects/SkMorphologyImageFilter.cpp
src/effects/SkPerlinNoiseShader.cpp
src/effects/SkTableColorFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/effects/gradients/SkTwoPointRadialGradient.cpp
src/gpu/GrAAConvexPathRenderer.cpp
src/gpu/GrAARectRenderer.cpp
src/gpu/GrOvalRenderer.cpp
src/gpu/effects/GrBezierEffect.cpp
src/gpu/effects/GrBicubicEffect.cpp
src/gpu/effects/GrConfigConversionEffect.cpp
src/gpu/effects/GrConvexPolyEffect.cpp
src/gpu/effects/GrConvolutionEffect.cpp
src/gpu/effects/GrCustomCoordsTextureEffect.cpp
src/gpu/effects/GrDashingEffect.cpp
src/gpu/effects/GrDistanceFieldTextureEffect.cpp
src/gpu/effects/GrDitherEffect.cpp
src/gpu/effects/GrOvalEffect.cpp
src/gpu/effects/GrRRectEffect.cpp
src/gpu/effects/GrSimpleTextureEffect.cpp
src/gpu/effects/GrTextureDomain.cpp
src/gpu/effects/GrTextureDomain.h
src/gpu/effects/GrYUVtoRGBEffect.cpp
src/gpu/gl/GrGLEffect.h
src/gpu/gl/GrGLProgramDesc.h
src/gpu/gl/GrGLProgramEffects.cpp
src/gpu/gl/GrGLProgramEffects.h
src/gpu/gl/GrGLShaderBuilder.h
src/gpu/gl/GrGLVertexEffect.h

index ef9e436401d72466f64603c1e4b1672b95646ef8..e6362520fc2b2e3b59e43b18343dfd86ced7bfd9 100644 (file)
@@ -47,6 +47,31 @@ private:
     int fCount;                     // number of uint32_ts added to fData by the effect.
 };
 
+/**
+ * This class is used to pass the key that was created for a GrGLEffect back to it
+ * when it emits code. It may allow the emit step to skip calculations that were
+ * performed when computing the key.
+ */
+class GrEffectKey {
+public:
+    GrEffectKey(const uint32_t* key, int count) : fKey(key), fCount(count) {
+        SkASSERT(0 == reinterpret_cast<intptr_t>(key) % sizeof(uint32_t));
+    }
+
+    /** Gets the uint32_t values that the effect inserted into the key. */
+    uint32_t get32(int index) const {
+        SkASSERT(index >=0 && index < fCount);
+        return fKey[index];
+    }
+
+    /** Gets the number of uint32_t values that the effect inserted into the key. */
+    int count32() const { return fCount; }
+
+private:
+    const uint32_t* fKey;           // unowned ptr into the larger key.
+    int             fCount;         // number of uint32_ts inserted by the effect into its key.
+};
+
 /**
  * Given a GrEffect of a particular type, creates the corresponding graphics-backend-specific
  * effect object. It also tracks equivalence of shaders generated via a key. The factory for an
@@ -66,8 +91,6 @@ private:
  */
 class GrBackendEffectFactory : SkNoncopyable {
 public:
-    typedef uint32_t EffectKey;
-
     /** 
      * Generates an effect's key. The key is based on the aspects of the GrEffect object's
      * configuration that affect GLSL code generation. Two GrEffect instances that would cause
index 781a29d289a5fcf84bedc4c3e5060059071eac0f..8cb870ee153dd88ff388690987c44d765cbb5514 100644 (file)
@@ -71,9 +71,8 @@ public:
         from getFactory()).
 
         A return value of true from isEqual() should not be used to test whether the effects would
-        generate the same shader code. To test for identical code generation use the EffectKey
-        computed by the GrBackendEffectFactory:
-            effectA.getFactory().glEffectKey(effectA) == effectB.getFactory().glEffectKey(effectB).
+        generate the same shader code. To test for identical code generation use the effects' keys
+        computed by the GrBackendEffectFactory.
      */
     bool isEqual(const GrEffect& other) const {
         if (&this->getFactory() != &other.getFactory()) {
index 251e8c776877be577b0fa206ed616526fd81b1af..450eb68ee563e67ef5b2b2a13adca11791ed8994 100644 (file)
@@ -49,8 +49,7 @@ public:
     virtual void getGLEffectKey(const GrDrawEffect& drawEffect,
                                 const GrGLCaps& caps,
                                 GrEffectKeyBuilder* b) const SK_OVERRIDE {
-        EffectKey effectKey = GLEffect::GenKey(drawEffect, caps);
-        b->add32(effectKey);
+        GLEffect::GenKey(drawEffect, caps, b);
     }
 
     /** Returns a new instance of the appropriate *GL* implementation class
index d0208570c63502475b478b25d5de948305d555f6..0811808d46c3e72813b4c972337b4d662dcf0cee 100644 (file)
@@ -823,7 +823,7 @@ public:
         }
         virtual void emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray& coords,
@@ -969,11 +969,13 @@ public:
             }
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+        static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                  GrEffectKeyBuilder* b) {
             // The background may come from the dst or from a texture.
-            int numTextures = drawEffect.effect()->numTextures();
-            SkASSERT(numTextures <= 1);
-            return (drawEffect.castEffect<XferEffect>().mode() << 1) | numTextures;
+            uint32_t key = drawEffect.effect()->numTextures();
+            SkASSERT(key <= 1);
+            key |= drawEffect.castEffect<XferEffect>().mode() << 1;
+            b->add32(key);
         }
 
     private:
index f8b84977e1c5b80398031ee99e93895b3b220683..76e1bc8ec7b88c62d3a32a104011abdb45d5f058 100644 (file)
@@ -118,7 +118,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -140,7 +140,7 @@ GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendEffectFactory&
 
 void GrGLAlphaThresholdEffect::emitCode(GrGLShaderBuilder* builder,
                                         const GrDrawEffect&,
-                                        EffectKey key,
+                                        const GrEffectKey& key,
                                         const char* outputColor,
                                         const char* inputColor,
                                         const TransformedCoordsArray& coords,
index 6e01504df728a730e1ad2e2cbf49ee9446ad1b15..e43603ac1e1f6b8d8348e899b823ac82520218ba 100644 (file)
@@ -242,7 +242,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -250,7 +250,7 @@ public:
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 private:
     GrGLUniformManager::UniformHandle fKUni;
@@ -349,7 +349,7 @@ GrGLArithmeticEffect::~GrGLArithmeticEffect() {
 
 void GrGLArithmeticEffect::emitCode(GrGLShaderBuilder* builder,
                                     const GrDrawEffect& drawEffect,
-                                    EffectKey key,
+                                    const GrEffectKey& key,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TransformedCoordsArray& coords,
@@ -401,14 +401,14 @@ void GrGLArithmeticEffect::setData(const GrGLUniformManager& uman, const GrDrawE
     fEnforcePMColor = arith.enforcePMColor();
 }
 
-GrGLEffect::EffectKey GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                   const GrGLCaps&) {
+void GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect,
+                                  const GrGLCaps&, GrEffectKeyBuilder* b) {
     const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>();
-    EffectKey key = arith.enforcePMColor() ? 1 : 0;
+    uint32_t key = arith.enforcePMColor() ? 1 : 0;
     if (arith.backgroundTexture()) {
         key |= 2;
     }
-    return key;
+    b->add32(key);
 }
 
 GrEffect* GrArithmeticEffect::TestCreate(SkRandom* rand,
index 4ab9944d8ca2ce573b3898c64bee64232cbfbbee..3c502f4a6a0498e6a2e585c141347b1683cd206f 100644 (file)
@@ -600,7 +600,7 @@ public:
                       const GrDrawEffect&);
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -641,7 +641,7 @@ void OutputRectBlurProfileLookup(GrGLShaderBuilder* builder,
 
 void GrGLRectBlurEffect::emitCode(GrGLShaderBuilder* builder,
                                  const GrDrawEffect&,
-                                 EffectKey key,
+                                 const GrEffectKey& key,
                                  const char* outputColor,
                                  const char* inputColor,
                                  const TransformedCoordsArray& coords,
@@ -961,7 +961,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -983,7 +983,7 @@ GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendEffectFactory& factory,
 
 void GrGLRRectBlurEffect::emitCode(GrGLShaderBuilder* builder,
                              const GrDrawEffect& drawEffect,
-                             EffectKey key,
+                             const GrEffectKey& key,
                              const char* outputColor,
                              const char* inputColor,
                              const TransformedCoordsArray&,
index 0e2fd6c9d9f25c1a25b2abda426f13ca2d352d6a..43df21555b00fbca279d91fa3f1fc3d4b8670862 100644 (file)
@@ -228,7 +228,7 @@ public:
 
         virtual void emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray& coords,
@@ -249,12 +249,12 @@ public:
             builder->fsCodeAppendf("\t%s = %s;\n", outputColor, filter.c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+        static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                           GrEffectKeyBuilder* b) {
             const ModeColorFilterEffect& colorModeFilter = drawEffect.castEffect<ModeColorFilterEffect>();
             // The SL code does not depend on filter color at the moment, so no need to represent it
             // in the key.
-            EffectKey modeKey = colorModeFilter.mode();
-            return modeKey;
+            b->add32(colorModeFilter.mode());
         }
 
         virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) SK_OVERRIDE {
index c24a2b773ad74678a8d0c7e244d9646a72ad9005..31a76ab9cdfecb7d8271d7143a14bf8a399cb609 100644 (file)
@@ -391,7 +391,7 @@ public:
     class GLEffect : public GrGLEffect {
     public:
         // this class always generates the same code.
-        static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { return 0; }
+        static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
 
         GLEffect(const GrBackendEffectFactory& factory,
                  const GrDrawEffect&)
@@ -400,7 +400,7 @@ public:
 
         virtual void emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect&,
-                              EffectKey,
+                              const GrEffectKey&,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
index a6897ea89157e51ff2ec6a72f325e08dd7b6a938..55935b4bdcd91181e56ec5ec7209d018f7f52a31 100644 (file)
@@ -278,13 +278,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -513,7 +513,7 @@ GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
 
 void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder,
                                          const GrDrawEffect&,
-                                         EffectKey key,
+                                         const GrEffectKey& key,
                                          const char* outputColor,
                                          const char* inputColor,
                                          const TransformedCoordsArray& coords,
@@ -600,14 +600,14 @@ void GrGLDisplacementMapEffect::setData(const GrGLUniformManager& uman,
                SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
 }
 
-GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                        const GrGLCaps&) {
+void GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& drawEffect,
+                                       const GrGLCaps&, GrEffectKeyBuilder* b) {
     const GrDisplacementMapEffect& displacementMap =
         drawEffect.castEffect<GrDisplacementMapEffect>();
 
-    EffectKey xKey = displacementMap.xChannelSelector();
-    EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBits;
+    uint32_t xKey = displacementMap.xChannelSelector();
+    uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBits;
 
-    return xKey | yKey;
+    b->add32(xKey | yKey);
 }
 #endif
index 682f2bad56c51c7c9a112c5f8d4f8903df866b7c..6e6828b74561be1a47ab440ca1fa3d228fdd7dd4 100644 (file)
@@ -1131,13 +1131,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
 
     /**
      * Subclasses of GrGLLightingEffect must call INHERITED::setData();
@@ -1266,7 +1266,7 @@ GrGLLightingEffect::~GrGLLightingEffect() {
 
 void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
                                   const GrDrawEffect&,
-                                  EffectKey key,
+                                  const GrEffectKey& key,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TransformedCoordsArray& coords,
@@ -1360,9 +1360,9 @@ void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppend(modulate.c_str());
 }
 
-GrGLEffect::EffectKey GrGLLightingEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                 const GrGLCaps& caps) {
-    return drawEffect.castEffect<GrLightingEffect>().light()->type();
+void GrGLLightingEffect::GenKey(const GrDrawEffect& drawEffect,
+                                const GrGLCaps& caps, GrEffectKeyBuilder* b) {
+    b->add32(drawEffect.castEffect<GrLightingEffect>().light()->type());
 }
 
 void GrGLLightingEffect::setData(const GrGLUniformManager& uman,
index 7564307f45efd214b33dc82cba68d2fb1400b5fd..d33e5e8d78ea0087c2fc9ded6656b797afa0ddde 100644 (file)
@@ -86,14 +86,11 @@ public:
         : INHERITED(factory) {
         }
 
-        static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) {
-            // this class always generates the same code.
-            return 0;
-        }
+        static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
 
         virtual void emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect&,
-                              EffectKey,
+                              const GrEffectKey&,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
index 4a730c2c136e9d306bc2c5cfd558026aa2222887..d3adf27183163edd72a730d505ac0c24ae825403 100644 (file)
@@ -97,7 +97,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -119,7 +119,7 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
 
 void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
                                    const GrDrawEffect&,
-                                   EffectKey key,
+                                   const GrEffectKey& key,
                                    const char* outputColor,
                                    const char* inputColor,
                                    const TransformedCoordsArray& coords,
index fa7d20596c55ce2d3f55c63332bba16ec8251f0c..676cab7b3266e8913ec1224f9eb9b0af5d2baac1 100644 (file)
@@ -405,13 +405,13 @@ public:
                                 const GrDrawEffect& effect);
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -465,7 +465,7 @@ static void appendTextureLookup(GrGLShaderBuilder* builder,
 
 void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
                                            const GrDrawEffect&,
-                                           EffectKey key,
+                                           const GrEffectKey& key,
                                            const char* outputColor,
                                            const char* inputColor,
                                            const TransformedCoordsArray& coords,
@@ -537,13 +537,13 @@ int encodeXY(int x, int y) {
 
 };
 
-GrGLEffect::EffectKey GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                          const GrGLCaps&) {
+void GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
+                                         const GrGLCaps&, GrEffectKeyBuilder* b) {
     const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
-    EffectKey key = encodeXY(m.kernelSize().width(), m.kernelSize().height());
+    uint32_t key = encodeXY(m.kernelSize().width(), m.kernelSize().height());
     key |= m.tileMode() << 7;
     key |= m.convolveAlpha() ? 1 << 9 : 0;
-    return key;
+    b->add32(key);
 }
 
 void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
index 10c6fe5ad0699258afecca08b2c01eaa9e0dc247..7be4435b687a0545cac26168d8ac40be77218391 100644 (file)
@@ -316,13 +316,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -346,7 +346,7 @@ GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory
 
 void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
                                     const GrDrawEffect&,
-                                    EffectKey key,
+                                    const GrEffectKey& key,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TransformedCoordsArray& coords,
@@ -384,12 +384,12 @@ void GrGLMorphologyEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppend(modulate.c_str());
 }
 
-GrGLEffect::EffectKey GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                   const GrGLCaps&) {
+void GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffect,
+                                  const GrGLCaps&, GrEffectKeyBuilder* b) {
     const GrMorphologyEffect& m = drawEffect.castEffect<GrMorphologyEffect>();
-    EffectKey key = static_cast<EffectKey>(m.radius());
+    uint32_t key = static_cast<uint32_t>(m.radius());
     key |= (m.type() << 8);
-    return key;
+    b->add32(key);
 }
 
 void GrGLMorphologyEffect::setData(const GrGLUniformManager& uman,
index e4811627b2da19f4bef53d38b46ac332333f62f4..f0b9f67712ccf237d117fd90b88463f00bcf5af5 100644 (file)
@@ -499,7 +499,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -507,7 +507,7 @@ public:
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
 
 private:
 
@@ -647,7 +647,7 @@ GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendEffectFactory& factory, const Gr
 
 void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
                                const GrDrawEffect&,
-                               EffectKey key,
+                               const GrEffectKey& key,
                                const char* outputColor,
                                const char* inputColor,
                                const TransformedCoordsArray& coords,
@@ -900,10 +900,10 @@ void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
                   outputColor, outputColor, outputColor, outputColor);
 }
 
-GrGLEffect::EffectKey GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+void GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
     const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseEffect>();
 
-    EffectKey key = turbulence.numOctaves();
+    uint32_t key = turbulence.numOctaves();
 
     key = key << 3; // Make room for next 3 bits
 
@@ -923,7 +923,7 @@ GrGLEffect::EffectKey GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, co
         key |= 0x4; // Flip the 3rd bit if tile stitching is on
     }
 
-    return key;
+    b->add32(key);
 }
 
 void GrGLPerlinNoise::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
index 4cf09877c4d53f93a69f8734bb417d7447ac236c..e9ce20f6c1d3837025969af3df711d8c5bf334df 100644 (file)
@@ -270,7 +270,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -278,7 +278,7 @@ public:
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
 
 private:
 
@@ -291,7 +291,7 @@ GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, co
 
 void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
                                   const GrDrawEffect&,
-                                  EffectKey,
+                                  const GrEffectKey&,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TransformedCoordsArray&,
@@ -333,10 +333,6 @@ void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppendf("\t\t%s.rgb *= %s.a;\n", outputColor, outputColor);
 }
 
-GrGLEffect::EffectKey GLColorTableEffect::GenKey(const GrDrawEffect&, const GrGLCaps&) {
-    return 0;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 ColorTableEffect::ColorTableEffect(GrTexture* texture, unsigned flags)
index fb8a7e5c8f04d1414d7443fd367547267ac846d6..5014c35ee0e647ce65b989513c59f480d554c9d9 100644 (file)
@@ -862,15 +862,15 @@ GrGLGradientEffect::GrGLGradientEffect(const GrBackendEffectFactory& factory)
 
 GrGLGradientEffect::~GrGLGradientEffect() { }
 
-void GrGLGradientEffect::emitUniforms(GrGLShaderBuilder* builder, EffectKey key) {
+void GrGLGradientEffect::emitUniforms(GrGLShaderBuilder* builder, uint32_t baseKey) {
 
-    if (SkGradientShaderBase::kTwo_GpuColorType == ColorTypeFromKey(key)) { // 2 Color case
+    if (SkGradientShaderBase::kTwo_GpuColorType == ColorTypeFromKey(baseKey)) { // 2 Color case
         fColorStartUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                              kVec4f_GrSLType, "GradientStartColor");
         fColorEndUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                            kVec4f_GrSLType, "GradientEndColor");
 
-    } else if (SkGradientShaderBase::kThree_GpuColorType == ColorTypeFromKey(key)){ // 3 Color Case
+    } else if (SkGradientShaderBase::kThree_GpuColorType == ColorTypeFromKey(baseKey)){ // 3 Color Case
         fColorStartUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                              kVec4f_GrSLType, "GradientStartColor");
         fColorMidUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
@@ -944,10 +944,10 @@ void GrGLGradientEffect::setData(const GrGLUniformManager& uman,
 }
 
 
-GrGLEffect::EffectKey GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect& drawEffect) {
+uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect& drawEffect) {
     const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>();
 
-    EffectKey key = 0;
+    uint32_t key = 0;
 
     if (SkGradientShaderBase::kTwo_GpuColorType == e.getColorType()) {
         key |= kTwoColorKey;
@@ -964,11 +964,11 @@ GrGLEffect::EffectKey GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect&
 
 void GrGLGradientEffect::emitColor(GrGLShaderBuilder* builder,
                                    const char* gradientTValue,
-                                   EffectKey key,
+                                   uint32_t baseKey,
                                    const char* outputColor,
                                    const char* inputColor,
                                    const TextureSamplerArray& samplers) {
-    if (SkGradientShaderBase::kTwo_GpuColorType == ColorTypeFromKey(key)){
+    if (SkGradientShaderBase::kTwo_GpuColorType == ColorTypeFromKey(baseKey)){
         builder->fsCodeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
                                builder->getUniformVariable(fColorStartUni).c_str(),
                                builder->getUniformVariable(fColorEndUni).c_str(),
@@ -978,13 +978,13 @@ void GrGLGradientEffect::emitColor(GrGLShaderBuilder* builder,
         // The gradient SkShader reporting opaque is more restrictive than necessary in the two pt
         // case. Make sure the key reflects this optimization (and note that it can use the same
         // shader as thekBeforeIterp case). This same optimization applies to the 3 color case below.
-        if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(key)) {
+        if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(baseKey)) {
             builder->fsCodeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
         }
 
         builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
                                (GrGLSLExpr4(inputColor) * GrGLSLExpr4("colorTemp")).c_str());
-    } else if (SkGradientShaderBase::kThree_GpuColorType == ColorTypeFromKey(key)){
+    } else if (SkGradientShaderBase::kThree_GpuColorType == ColorTypeFromKey(baseKey)){
         builder->fsCodeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
                                gradientTValue);
         builder->fsCodeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
@@ -1002,7 +1002,7 @@ void GrGLGradientEffect::emitColor(GrGLShaderBuilder* builder,
         }
         builder->fsCodeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
                                builder->getUniformVariable(fColorEndUni).c_str());
-        if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(key)) {
+        if (GrGradientEffect::kAfterInterp_PremulType == PremulTypeFromKey(baseKey)) {
             builder->fsCodeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
         }
 
index 96135378032d52ade5e27b2c573408206543eb37..61acf3c8fe8075d015ba164d7577f775fdfd5fa6 100644 (file)
@@ -379,6 +379,29 @@ public:
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
 protected:
+    /**
+     * Subclasses must call this. It will return a key for the part of the shader code controlled
+     * by the base class. The subclasses must stick it in their key and then pass it to the below
+     * emit* functions from their emitCode function.
+     */
+    static uint32_t GenBaseGradientKey(const GrDrawEffect&);
+
+    // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
+    // should call this method from their emitCode().
+    void emitUniforms(GrGLShaderBuilder* builder, uint32_t baseKey);
+
+
+    // 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,
+                   uint32_t baseKey,
+                   const char* outputColor,
+                   const char* inputColor,
+                   const TextureSamplerArray& samplers);
+
+private:
     enum {
         kPremulTypeKeyBitCnt = 1,
         kPremulTypeMask = 1,
@@ -393,45 +416,24 @@ protected:
         // and combine with the result of GenBaseGradientKey.
         kBaseKeyBitCnt = (kPremulTypeKeyBitCnt + kColorKeyBitCnt)
     };
+    GR_STATIC_ASSERT(kBaseKeyBitCnt <= 32);
 
-    static SkGradientShaderBase::GpuColorType ColorTypeFromKey(EffectKey key){
-        if (kTwoColorKey == (key & kColorKeyMask)) {
+    static SkGradientShaderBase::GpuColorType ColorTypeFromKey(uint32_t baseKey){
+        if (kTwoColorKey == (baseKey & kColorKeyMask)) {
             return SkGradientShaderBase::kTwo_GpuColorType;
-        } else if (kThreeColorKey == (key & kColorKeyMask)) {
+        } else if (kThreeColorKey == (baseKey & kColorKeyMask)) {
             return SkGradientShaderBase::kThree_GpuColorType;
         } else {return SkGradientShaderBase::kTexture_GpuColorType;}
     }
 
-    static GrGradientEffect::PremulType PremulTypeFromKey(EffectKey key){
-        if (kPremulBeforeInterpKey == (key & kPremulTypeMask)) {
+    static GrGradientEffect::PremulType PremulTypeFromKey(uint32_t baseKey){
+        if (kPremulBeforeInterpKey == (baseKey & kPremulTypeMask)) {
             return GrGradientEffect::kBeforeInterp_PremulType;
         } else {
             return GrGradientEffect::kAfterInterp_PremulType;
         }
     }
 
-    /**
-     * Subclasses must call this. It will return a value restricted to the lower kBaseKeyBitCnt
-     * bits.
-     */
-    static EffectKey GenBaseGradientKey(const GrDrawEffect&);
-
-    // Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
-    // should call this method from their emitCode().
-    void emitUniforms(GrGLShaderBuilder* builder, EffectKey key);
-
-
-    // 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 TextureSamplerArray& samplers);
-
-private:
     SkScalar fCachedYCoord;
     GrGLUniformManager::UniformHandle fFSYUni;
     GrGLUniformManager::UniformHandle fColorStartUni;
index 332c9b4af92e5717f8ec5d8d24f2c5fc5ef9eeb6..9de459125a7639dd85404df19e1c55dea4f1679f 100644 (file)
@@ -461,14 +461,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-        return GenBaseGradientKey(drawEffect);
+    static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
+        b->add32(GenBaseGradientKey(drawEffect));
     }
 
 private:
@@ -538,15 +538,16 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
 
 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
                                   const GrDrawEffect&,
-                                  EffectKey key,
+                                  const GrEffectKey& key,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TransformedCoordsArray& coords,
                                   const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     SkString t = builder->ensureFSCoords2D(coords, 0);
     t.append(".x");
-    this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 /////////////////////////////////////////////////////////////////////
index e3aaea341f7ccc8644ebcdf49c6ea8cc19b98ef8..8a378aad09c573d60c4cf41a45d6181e849b99e2 100644 (file)
@@ -470,14 +470,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-        return GenBaseGradientKey(drawEffect);
+    static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
+        b->add32(GenBaseGradientKey(drawEffect));
     }
 
 private:
@@ -549,16 +549,17 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
 
 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
                                   const GrDrawEffect&,
-                                  EffectKey key,
+                                  const GrEffectKey& key,
                                   const char* outputColor,
                                   const char* inputColor,
                                   const TransformedCoordsArray& coords,
                                   const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     SkString t("length(");
     t.append(builder->ensureFSCoords2D(coords, 0));
     t.append(")");
-    this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 /////////////////////////////////////////////////////////////////////
index bb9d628968f3575d8bb98be299062cbead9cec6b..66e755a1bcdf9a8c695b9f738f63e1dc4b64bbd7 100644 (file)
@@ -186,14 +186,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-        return GenBaseGradientKey(drawEffect);
+    static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
+        b->add32(GenBaseGradientKey(drawEffect));
     }
 
 private:
@@ -256,12 +256,13 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
 
 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
                                  const GrDrawEffect&,
-                                 EffectKey key,
+                                 const GrEffectKey& key,
                                  const char* outputColor,
                                  const char* inputColor,
                                  const TransformedCoordsArray& coords,
                                  const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     SkString coords2D = builder->ensureFSCoords2D(coords, 0);
     const GrGLContextInfo ctxInfo = builder->ctxInfo();
     SkString t;
@@ -275,8 +276,7 @@ void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
         t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5",
                  coords2D.c_str(), coords2D.c_str());
     }
-    this->emitColor(builder, t.c_str(), key,
-                          outputColor, inputColor, samplers);
+    this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 /////////////////////////////////////////////////////////////////////
index 8beb6fb828c0859fe012a3a1af76586c33c6b6a2..76f9a492b8ee5f75c1dfb60b58d9d4b1eed44f24 100644 (file)
@@ -139,14 +139,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
     UniformHandle fParamUni;
@@ -219,12 +219,13 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac
 
 void GLEdge2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
                                       const GrDrawEffect&,
-                                      EffectKey key,
+                                      const GrEffectKey& key,
                                       const char* outputColor,
                                       const char* inputColor,
                                       const TransformedCoordsArray& coords,
                                       const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility,
                                          kFloat_GrSLType, "Conical2FSParams", 3);
 
@@ -268,7 +269,7 @@ void GLEdge2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(),
                            p2.c_str(), p0.c_str());
     builder->fsCodeAppend("\t");
-    this->emitColor(builder, tName.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, samplers);
     builder->fsCodeAppend("\t}\n");
 }
 
@@ -294,9 +295,9 @@ void GLEdge2PtConicalEffect::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GLEdge2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                     const GrGLCaps&) {
-    return GenBaseGradientKey(drawEffect);
+void GLEdge2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
+                                    const GrGLCaps&, GrEffectKeyBuilder* b) {
+    b->add32(GenBaseGradientKey(drawEffect));
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -414,14 +415,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
     UniformHandle fParamUni;
@@ -494,12 +495,13 @@ GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEf
 
 void GLFocalOutside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
                                               const GrDrawEffect&,
-                                              EffectKey key,
+                                              const GrEffectKey& key,
                                               const char* outputColor,
                                               const char* inputColor,
                                               const TransformedCoordsArray& coords,
                                               const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility,
                                          kFloat_GrSLType, "Conical2FSParams", 2);
     SkString tName("t");
@@ -535,7 +537,7 @@ void GLFocalOutside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
 
     builder->fsCodeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str());
     builder->fsCodeAppend("\t\t");
-    this->emitColor(builder, tName.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, samplers);
     builder->fsCodeAppend("\t}\n");
 }
 
@@ -559,18 +561,11 @@ void GLFocalOutside2PtConicalEffect::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GLFocalOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                             const GrGLCaps&) {
-    enum {
-        kIsFlipped = 1 << kBaseKeyBitCnt,
-    };
-
-    EffectKey key = GenBaseGradientKey(drawEffect);
-
-    if (drawEffect.castEffect<FocalOutside2PtConicalEffect>().isFlipped()) {
-        key |= kIsFlipped;
-    }
-    return key;
+void GLFocalOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
+                                            const GrGLCaps&, GrEffectKeyBuilder* b) {
+    uint32_t* key = b->add32n(2);
+    key[0] = GenBaseGradientKey(drawEffect);
+    key[1] = drawEffect.castEffect<FocalOutside2PtConicalEffect>().isFlipped();
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -625,14 +620,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
     UniformHandle fFocalUni;
@@ -702,12 +697,13 @@ GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffe
 
 void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
                                              const GrDrawEffect&,
-                                             EffectKey key,
+                                             const GrEffectKey& key,
                                              const char* outputColor,
                                              const char* inputColor,
                                              const TransformedCoordsArray& coords,
                                              const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fFocalUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                     kFloat_GrSLType, "Conical2FSParams");
     SkString tName("t");
@@ -724,7 +720,7 @@ void GLFocalInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppendf("\tfloat %s = %s.x * %s  + length(%s);\n", tName.c_str(),
                            coords2D, focal.c_str(), coords2D);
 
-    this->emitColor(builder, tName.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 void GLFocalInside2PtConicalEffect::setData(const GrGLUniformManager& uman,
@@ -739,9 +735,9 @@ void GLFocalInside2PtConicalEffect::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GLFocalInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                            const GrGLCaps&) {
-    return GenBaseGradientKey(drawEffect);
+void GLFocalInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
+                                           const GrGLCaps&, GrEffectKeyBuilder* b) {
+    b->add32(GenBaseGradientKey(drawEffect));
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -865,14 +861,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
     UniformHandle fCenterUni;
@@ -950,12 +946,13 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf
 
 void GLCircleInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
                                               const GrDrawEffect&,
-                                              EffectKey key,
+                                              const GrEffectKey& key,
                                               const char* outputColor,
                                               const char* inputColor,
                                               const TransformedCoordsArray& coords,
                                               const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fCenterUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                      kVec2f_GrSLType, "Conical2FSCenter");
     fParamUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
@@ -985,7 +982,7 @@ void GLCircleInside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
     builder->fsCodeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\n",
                            tName.c_str(), params.c_str(), params.c_str());
 
-    this->emitColor(builder, tName.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 void GLCircleInside2PtConicalEffect::setData(const GrGLUniformManager& uman,
@@ -1012,10 +1009,9 @@ void GLCircleInside2PtConicalEffect::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GLCircleInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                             const GrGLCaps&) {
-    EffectKey key = GenBaseGradientKey(drawEffect);
-    return key;
+void GLCircleInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
+                                            const GrGLCaps&, GrEffectKeyBuilder* b) {
+    b->add32(GenBaseGradientKey(drawEffect));
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1091,14 +1087,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
     UniformHandle fCenterUni;
@@ -1184,12 +1180,13 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend
 
 void GLCircleOutside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
                                                const GrDrawEffect&,
-                                               EffectKey key,
+                                               const GrEffectKey& key,
                                                const char* outputColor,
                                                const char* inputColor,
                                                const TransformedCoordsArray& coords,
                                                const TextureSamplerArray& samplers) {
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fCenterUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
                                      kVec2f_GrSLType, "Conical2FSCenter");
     fParamUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
@@ -1233,7 +1230,7 @@ void GLCircleOutside2PtConicalEffect::emitCode(GrGLShaderBuilder* builder,
 
     builder->fsCodeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(), params.c_str());
     builder->fsCodeAppend("\t\t");
-    this->emitColor(builder, tName.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, samplers);
     builder->fsCodeAppend("\t}\n");
 }
 
@@ -1265,18 +1262,11 @@ void GLCircleOutside2PtConicalEffect::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GLCircleOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                              const GrGLCaps&) {
-    enum {
-        kIsFlipped = 1 << kBaseKeyBitCnt,
-    };
-
-    EffectKey key = GenBaseGradientKey(drawEffect);
-
-    if (drawEffect.castEffect<CircleOutside2PtConicalEffect>().isFlipped()) {
-        key |= kIsFlipped;
-    }
-    return key;
+void GLCircleOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
+                                             const GrGLCaps&, GrEffectKeyBuilder* b) {
+    uint32_t* key = b->add32n(2);
+    key[0] = GenBaseGradientKey(drawEffect);
+    key[1] = drawEffect.castEffect<CircleOutside2PtConicalEffect>().isFlipped();
 }
 
 //////////////////////////////////////////////////////////////////////////////
index a97cc0c38d6646e2ce3b0bd1aa53c3d53984f74a..50152744137cb1de48b013416a119711afa0b671 100644 (file)
@@ -398,14 +398,14 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps& caps);
+    static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
 
 protected:
 
@@ -554,13 +554,13 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
 
 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
                                    const GrDrawEffect& drawEffect,
-                                   EffectKey key,
+                                   const GrEffectKey& key,
                                    const char* outputColor,
                                    const char* inputColor,
                                    const TransformedCoordsArray& coords,
                                    const TextureSamplerArray& samplers) {
-
-    this->emitUniforms(builder, key);
+    uint32_t baseKey = key.get32(0);
+    this->emitUniforms(builder, baseKey);
     fParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibility,
                                          kFloat_GrSLType, "Radial2FSParams", 6);
 
@@ -622,7 +622,7 @@ void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
         t.printf("-%s / %s", cName.c_str(), bVar.c_str());
     }
 
-    this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers);
+    this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, samplers);
 }
 
 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
@@ -659,17 +659,11 @@ void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
     }
 }
 
-GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect,
-                                                  const GrGLCaps&) {
-    enum {
-        kIsDegenerate = 1 << kBaseKeyBitCnt,
-    };
-
-    EffectKey key = GenBaseGradientKey(drawEffect);
-    if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) {
-        key |= kIsDegenerate;
-    }
-    return key;
+void GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect,
+                                 const GrGLCaps&, GrEffectKeyBuilder* b) {
+    uint32_t* key = b->add32n(2);
+    key[0] = GenBaseGradientKey(drawEffect);
+    key[1] = drawEffect.castEffect<GrRadial2Gradient>().isDegenerate();
 }
 
 /////////////////////////////////////////////////////////////////////
index 3116712ab002e477f286118987f228296e20608e..afcb987b39e062e828e599604748702bf0a6e24e 100644 (file)
@@ -533,7 +533,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -570,9 +570,7 @@ public:
             builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-            return 0x0;
-        }
+        static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
 
         virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
 
index 761c63f2bf1d99d0a8245529d21182370661c12f..59e9b6f810d70b565057c82e8caf8daab4c2b0c4 100644 (file)
@@ -46,7 +46,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -88,9 +88,7 @@ public:
                                    (GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-            return 0;
-        }
+        static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
 
         virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK_OVERRIDE {}
 
@@ -164,7 +162,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -221,9 +219,7 @@ public:
                                    (GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-            return 0;
-        }
+        static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
 
         virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK_OVERRIDE {}
 
index 648bc14f08d7c65da59c7be2f099ccae230f01b8..b604f021578b0de99268ad219b9bbae581056911 100644 (file)
@@ -97,7 +97,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -121,10 +121,10 @@ public:
                                    (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+        static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                           GrEffectKeyBuilder* b) {
             const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleEdgeEffect>();
-
-            return circleEffect.isStroked() ? 0x1 : 0x0;
+            b->add32(circleEffect.isStroked());
         }
 
         virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
@@ -208,7 +208,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -251,10 +251,10 @@ public:
                                    (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+        static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                           GrEffectKeyBuilder* b) {
             const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<EllipseEdgeEffect>();
-
-            return ellipseEffect.isStroked() ? 0x1 : 0x0;
+            b->add32(ellipseEffect.isStroked());
         }
 
         virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {
@@ -346,7 +346,7 @@ public:
 
         virtual void emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -407,10 +407,12 @@ public:
                                    (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
         }
 
-        static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
-            const DIEllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<DIEllipseEdgeEffect>();
+        static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                           GrEffectKeyBuilder* b) {
+            const DIEllipseEdgeEffect& ellipseEffect =
+                drawEffect.castEffect<DIEllipseEdgeEffect>();
 
-            return ellipseEffect.getMode();
+            b->add32(ellipseEffect.getMode());
         }
 
         virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {
index d710c641a541c578f950de2267e08a2b3eda8e4f..7337d8a7fc8f69bf7479565b3120b7f2e15ff31a 100644 (file)
@@ -19,13 +19,13 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
 
@@ -44,7 +44,7 @@ GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory,
 
 void GrGLConicEffect::emitCode(GrGLFullShaderBuilder* builder,
                                const GrDrawEffect& drawEffect,
-                               EffectKey key,
+                               const GrEffectKey& key,
                                const char* outputColor,
                                const char* inputColor,
                                const TransformedCoordsArray&,
@@ -117,9 +117,11 @@ void GrGLConicEffect::emitCode(GrGLFullShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
 }
 
-GrGLEffect::EffectKey GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+void GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                             GrEffectKeyBuilder* b) {
     const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>();
-    return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    b->add32(key);
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -167,13 +169,13 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
 
@@ -192,7 +194,7 @@ GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory,
 
 void GrGLQuadEffect::emitCode(GrGLFullShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -255,9 +257,11 @@ void GrGLQuadEffect::emitCode(GrGLFullShaderBuilder* builder,
     builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
 }
 
-GrGLEffect::EffectKey GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+void GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                            GrEffectKeyBuilder* b) {
     const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>();
-    return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    b->add32(key);
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -305,13 +309,13 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE {}
 
@@ -330,7 +334,7 @@ GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory,
 
 void GrGLCubicEffect::emitCode(GrGLFullShaderBuilder* builder,
                                const GrDrawEffect& drawEffect,
-                               EffectKey key,
+                               const GrEffectKey& key,
                                const char* outputColor,
                                const char* inputColor,
                                const TransformedCoordsArray&,
@@ -403,9 +407,11 @@ void GrGLCubicEffect::emitCode(GrGLFullShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
 }
 
-GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+void GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                             GrEffectKeyBuilder* b) {
     const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
-    return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
+    b->add32(key);
 }
 
 //////////////////////////////////////////////////////////////////////////////
index 118efaf68c02b883d5252f8f39ed62eb5000be8d..2b819f68424ce9fc9a8f6f71a7083e96d2dc3ea6 100644 (file)
@@ -26,7 +26,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -34,9 +34,10 @@ public:
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+    static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                              GrEffectKeyBuilder* b) {
         const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>().domain();
-        return GrTextureDomain::GLDomain::DomainKey(domain);
+        b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
     }
 
 private:
@@ -55,7 +56,7 @@ GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, cons
 
 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
                                  const GrDrawEffect& drawEffect,
-                                 EffectKey key,
+                                 const GrEffectKey& key,
                                  const char* outputColor,
                                  const char* inputColor,
                                  const TransformedCoordsArray& coords,
index c421867dd76e71a1bc0044f30921ccee34af2964..07529d04ff3839a2378a4fa14141acb74919e3ab 100644 (file)
@@ -25,7 +25,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect&,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray& coords,
@@ -71,9 +71,11 @@ public:
         builder->fsCodeAppend(modulate.c_str());
     }
 
-    static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+    static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                              GrEffectKeyBuilder* b) {
         const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigConversionEffect>();
-        return static_cast<EffectKey>(conv.swapsRedAndBlue()) | (conv.pmConversion() << 1);
+        uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() << 1);
+        b->add32(key);
     }
 
 private:
index dd104bde9d4dd9be1c83ead36b62997f38b15119..11109f7ed837c0bddd695998b21f84d4e4f09a73 100644 (file)
@@ -91,13 +91,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -115,7 +115,7 @@ GLAARectEffect::GLAARectEffect(const GrBackendEffectFactory& factory,
 
 void GLAARectEffect::emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -165,9 +165,10 @@ void GLAARectEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect&
     }
 }
 
-GrGLEffect::EffectKey GLAARectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+void GLAARectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                            GrEffectKeyBuilder* b) {
     const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
-    return aare.getEdgeType();
+    b->add32(aare.getEdgeType());
 }
 
 const GrBackendEffectFactory& AARectEffect::getFactory() const {
@@ -182,13 +183,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -206,7 +207,7 @@ GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendEffectFactory& factory
 
 void GrGLConvexPolyEffect::emitCode(GrGLShaderBuilder* builder,
                                     const GrDrawEffect& drawEffect,
-                                    EffectKey key,
+                                    const GrEffectKey& key,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TransformedCoordsArray&,
@@ -254,11 +255,12 @@ void GrGLConvexPolyEffect::setData(const GrGLUniformManager& uman, const GrDrawE
     }
 }
 
-GrGLEffect::EffectKey GrGLConvexPolyEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                   const GrGLCaps&) {
+void GrGLConvexPolyEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                  GrEffectKeyBuilder* b) {
     const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
     GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
-    return (cpe.getEdgeCount() << 3) | cpe.getEdgeType();
+    uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType();
+    b->add32(key);
 }
 
 //////////////////////////////////////////////////////////////////////////////
index 43ef7e7626cc9ca9d4b3e8ebbe2270b9e0b8921d..f20d1db997518ff701ce44dc80b35d008957faa3 100644 (file)
@@ -21,7 +21,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -29,7 +29,7 @@ public:
 
     virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
 private:
     int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
@@ -57,7 +57,7 @@ GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& facto
 
 void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
                                      const GrDrawEffect&,
-                                     EffectKey key,
+                                     const GrEffectKey& key,
                                      const char* outputColor,
                                      const char* inputColor,
                                      const TransformedCoordsArray& coords,
@@ -134,16 +134,16 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
     uman.set1fv(fKernelUni, this->width(), conv.kernel());
 }
 
-GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                    const GrGLCaps&) {
+void GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                   GrEffectKeyBuilder* b) {
     const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>();
-    EffectKey key = conv.radius();
+    uint32_t key = conv.radius();
     key <<= 2;
     if (conv.useBounds()) {
         key |= 0x2;
         key |= GrConvolutionEffect::kY_Direction == conv.direction() ? 0x1 : 0x0;
     }
-    return key;
+    b->add32(key);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
index feb9d627c66698adbac672cb0d6b48b58939ebe2..a24abf9f63d32b041a926ccbf036706f61d1ff13 100644 (file)
@@ -21,7 +21,7 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
index 488d1ba8ba4b233d5cb6e7c9322faa7a159b185f..9f6b77d64f3f16ed4281ada81e04d787d361d113 100644 (file)
@@ -470,13 +470,13 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -498,7 +498,7 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& facto
 
 void GLDashingCircleEffect::emitCode(GrGLFullShaderBuilder* builder,
                                     const GrDrawEffect& drawEffect,
-                                    EffectKey key,
+                                    const GrEffectKey& key,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TransformedCoordsArray&,
@@ -549,10 +549,10 @@ void GLDashingCircleEffect::setData(const GrGLUniformManager& uman, const GrDraw
     }
 }
 
-GrGLEffect::EffectKey GLDashingCircleEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                const GrGLCaps&) {
+void GLDashingCircleEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                   GrEffectKeyBuilder* b) {
     const DashingCircleEffect& dce = drawEffect.castEffect<DashingCircleEffect>();
-    return dce.getEdgeType();
+    b->add32(dce.getEdgeType());
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -675,13 +675,13 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -702,7 +702,7 @@ GLDashingLineEffect::GLDashingLineEffect(const GrBackendEffectFactory& factory,
 
 void GLDashingLineEffect::emitCode(GrGLFullShaderBuilder* builder,
                                     const GrDrawEffect& drawEffect,
-                                    EffectKey key,
+                                    const GrEffectKey& key,
                                     const char* outputColor,
                                     const char* inputColor,
                                     const TransformedCoordsArray&,
@@ -766,10 +766,10 @@ void GLDashingLineEffect::setData(const GrGLUniformManager& uman, const GrDrawEf
     }
 }
 
-GrGLEffect::EffectKey GLDashingLineEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                const GrGLCaps&) {
+void GLDashingLineEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                 GrEffectKeyBuilder* b) {
     const DashingLineEffect& de = drawEffect.castEffect<DashingLineEffect>();
-    return de.getEdgeType();
+    b->add32(de.getEdgeType());
 }
 
 //////////////////////////////////////////////////////////////////////////////
index f69980dc10b326d0d413dcfba50b802c00da93ac..0c0c1afc769ac15f2355e85c46deb83427b19c20 100755 (executable)
@@ -38,7 +38,7 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -148,11 +148,12 @@ public:
 #endif
     }
 
-    static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+    static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                              GrEffectKeyBuilder* b) {
         const GrDistanceFieldTextureEffect& dfTexEffect =
                                               drawEffect.castEffect<GrDistanceFieldTextureEffect>();
 
-        return dfTexEffect.isSimilarity() ? 0x1 : 0x0;
+        b->add32(dfTexEffect.isSimilarity());
     }
 
 private:
@@ -255,7 +256,7 @@ public:
 
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -412,11 +413,12 @@ public:
         }
     }
 
-    static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
+    static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                              GrEffectKeyBuilder* b) {
         const GrDistanceFieldLCDTextureEffect& dfTexEffect =
                                            drawEffect.castEffect<GrDistanceFieldLCDTextureEffect>();
 
-        return dfTexEffect.isUniformScale() ? 0x01 : 0x00;;
+        b->add32(dfTexEffect.isUniformScale());
     }
 
 private:
index 37354c6d7d6d3bedfa9bfadfeee42f4e38508cc3..a431897a4eaa2a987bb902f6a0504020bb3ed09b 100644 (file)
@@ -72,7 +72,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -89,7 +89,7 @@ GLDitherEffect::GLDitherEffect(const GrBackendEffectFactory& factory,
 
 void GLDitherEffect::emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
index a80b08d39dbd420ee2c3e4e28821b1178c4e723f..ebeb288c975ea3e865d56a2ca112d11b13ef5967 100644 (file)
@@ -102,13 +102,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -128,7 +128,7 @@ GLCircleEffect::GLCircleEffect(const GrBackendEffectFactory& factory,
 
 void GLCircleEffect::emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect& drawEffect,
-                              EffectKey key,
+                              const GrEffectKey& key,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray&,
@@ -161,10 +161,10 @@ void GLCircleEffect::emitCode(GrGLShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("d")).c_str());
 }
 
-GrGLEffect::EffectKey GLCircleEffect::GenKey(const GrDrawEffect& drawEffect,
-                                             const GrGLCaps&) {
+void GLCircleEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                            GrEffectKeyBuilder* b) {
     const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
-    return ce.getEdgeType();
+    b->add32(ce.getEdgeType());
 }
 
 void GLCircleEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
@@ -274,13 +274,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -300,7 +300,7 @@ GLEllipseEffect::GLEllipseEffect(const GrBackendEffectFactory& factory,
 
 void GLEllipseEffect::emitCode(GrGLShaderBuilder* builder,
                                const GrDrawEffect& drawEffect,
-                               EffectKey key,
+                               const GrEffectKey& key,
                                const char* outputColor,
                                const char* inputColor,
                                const TransformedCoordsArray&,
@@ -346,10 +346,10 @@ void GLEllipseEffect::emitCode(GrGLShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
 }
 
-GrGLEffect::EffectKey GLEllipseEffect::GenKey(const GrDrawEffect& drawEffect,
-                                              const GrGLCaps&) {
+void GLEllipseEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                             GrEffectKeyBuilder* b) {
     const EllipseEffect& ee = drawEffect.castEffect<EllipseEffect>();
-    return ee.getEdgeType();
+    b->add32(ee.getEdgeType());
 }
 
 void GLEllipseEffect::setData(const GrGLUniformManager& uman, const GrDrawEffect& drawEffect) {
index efad436888d5a686bb0a9bff01076888d55e9eb0..277f6df1a7df39b49440b1451b4edb9ad169214c 100644 (file)
@@ -136,13 +136,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -161,7 +161,7 @@ GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendEffectFactory& facto
 
 void GLCircularRRectEffect::emitCode(GrGLShaderBuilder* builder,
                              const GrDrawEffect& drawEffect,
-                             EffectKey key,
+                             const GrEffectKey& key,
                              const char* outputColor,
                              const char* inputColor,
                              const TransformedCoordsArray&,
@@ -291,11 +291,11 @@ void GLCircularRRectEffect::emitCode(GrGLShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
 }
 
-GrGLEffect::EffectKey GLCircularRRectEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                    const GrGLCaps&) {
+void GLCircularRRectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                   GrEffectKeyBuilder* b) {
     const CircularRRectEffect& crre = drawEffect.castEffect<CircularRRectEffect>();
     GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
-    return (crre.getCircularCornerFlags() << 3) | crre.getEdgeType();
+    b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType());
 }
 
 void GLCircularRRectEffect::setData(const GrGLUniformManager& uman,
@@ -488,13 +488,13 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
                           const TextureSamplerArray&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
@@ -513,7 +513,7 @@ GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendEffectFactory& f
 
 void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
                                        const GrDrawEffect& drawEffect,
-                                       EffectKey key,
+                                       const GrEffectKey& key,
                                        const char* outputColor,
                                        const char* inputColor,
                                        const TransformedCoordsArray&,
@@ -586,11 +586,11 @@ void GLEllipticalRRectEffect::emitCode(GrGLShaderBuilder* builder,
                            (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
 }
 
-GrGLEffect::EffectKey GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                      const GrGLCaps&) {
+void GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                     GrEffectKeyBuilder* b) {
     const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEffect>();
     GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3));
-    return erre.getRRect().getType() | erre.getEdgeType() << 3;
+    b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3);
 }
 
 void GLEllipticalRRectEffect::setData(const GrGLUniformManager& uman,
index c93abf921c786551a32cfd3b46ec166f007daa4c..74926bc1455aa1c556e439d65b1c34d871018d94 100644 (file)
@@ -21,7 +21,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray& coords,
index 108ec78740821b34ef9e54a28ea0e9eb4d10b756..5af5bc86f3a95eb339a7bc824fa114234f8f5eb5 100644 (file)
@@ -147,7 +147,7 @@ public:
 
     virtual void emitCode(GrGLShaderBuilder*,
                           const GrDrawEffect&,
-                          EffectKey,
+                          const GrEffectKey&,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray&,
@@ -155,7 +155,7 @@ public:
 
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVERRIDE;
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
+    static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
 
 private:
     GrTextureDomain::GLDomain         fGLDomain;
@@ -169,7 +169,7 @@ GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f
 
 void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
                                        const GrDrawEffect& drawEffect,
-                                       EffectKey key,
+                                       const GrEffectKey& key,
                                        const char* outputColor,
                                        const char* inputColor,
                                        const TransformedCoordsArray& coords,
@@ -188,10 +188,10 @@ void GrGLTextureDomainEffect::setData(const GrGLUniformManager& uman,
     fGLDomain.setData(uman, domain, effect.texture(0)->origin());
 }
 
-GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect,
-                                                      const GrGLCaps&) {
+void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
+                                     GrEffectKeyBuilder* b) {
     const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect>().textureDomain();
-    return GrTextureDomain::GLDomain::DomainKey(domain);
+    b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
 }
 
 
index dc781870ceeaa48ab5a86a81128e207445c8aa19..80a617ef722eff937f9eb1ef381b97b83768605b 100644 (file)
@@ -108,7 +108,7 @@ public:
          * GrGLEffect::GenKey() must call this and include the returned value in it's computed key.
          * The returned will be limited to the lower kDomainKeyBits bits.
          */
-        static GrGLEffect::EffectKey DomainKey(const GrTextureDomain& domain) {
+        static uint32_t DomainKey(const GrTextureDomain& domain) {
             GR_STATIC_ASSERT(kModeCount <= 4);
             return domain.mode();
         }
index 76b85810c1210bb4a37784ea830d6b6389b923ad..15e51a2c625d06373cb14503f90cf27efcf0a386 100644 (file)
@@ -37,7 +37,7 @@ public:
     class GLEffect : public GrGLEffect {
     public:
         // this class always generates the same code.
-        static EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { return 0; }
+        static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
 
         GLEffect(const GrBackendEffectFactory& factory,
                  const GrDrawEffect&)
@@ -46,7 +46,7 @@ public:
 
         virtual void emitCode(GrGLShaderBuilder* builder,
                               const GrDrawEffect&,
-                              EffectKey,
+                              const GrEffectKey&,
                               const char* outputColor,
                               const char* inputColor,
                               const TransformedCoordsArray& coords,
index 0727372e62ddc7e7f7e082328f398185164d3b28..f9235db238d5abc0e1c547d08b5d35a474cb8e5d 100644 (file)
@@ -20,7 +20,7 @@ class GrGLShaderBuilder;
     include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the
     GLSL code that implements a GrEffect and for uploading uniforms at draw time. If they don't
     always emit the same GLSL code, they must have a function:
-        static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&)
+        static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
     that is used to implement a program cache. When two GrEffects produce the same key this means
     that their GrGLEffects would emit the same GLSL code.
 
@@ -39,7 +39,6 @@ class GrGLVertexEffect;
 class GrGLEffect {
 
 public:
-    typedef GrBackendEffectFactory::EffectKey EffectKey;
     typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray;
     typedef GrGLProgramEffects::TextureSampler TextureSampler;
     typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray;
@@ -58,8 +57,6 @@ public:
         @param builder      Interface used to emit code in the shaders.
         @param drawEffect   A wrapper on the effect that generated this program stage.
         @param key          The key that was computed by GenKey() from the generating GrEffect.
-                            Only the bits indicated by GrBackendEffectFactory::kEffectKeyBits are
-                            guaranteed to match the value produced by GenKey();
         @param outputColor  A predefined vec4 in the FS in which the stage should place its output
                             color (or coverage).
         @param inputColor   A vec4 that holds the input color to the stage in the FS. This may be
@@ -73,24 +70,24 @@ public:
         */
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray& coords,
                           const TextureSamplerArray& samplers) = 0;
 
     /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
-        key; this function reads data from a stage and uploads any uniform variables required
-        by the shaders created in emitCode(). The GrEffect installed in the GrEffectStage is
+        key; this function reads data from a GrEffect and uploads any uniform variables required
+        by the shaders created in emitCode(). The GrEffect installed in the GrDrawEffect is
         guaranteed to be of the same type that created this GrGLEffect and to have an identical
-        EffectKey as the one that created this GrGLEffect. Effects that use local coords have
+        effect key as the one that created this GrGLEffect. Effects that use local coords have
         to consider whether the GrEffectStage's coord change matrix should be used. When explicit
         local coordinates are used it can be ignored. */
     virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) {}
 
     const char* name() const { return fFactory.name(); }
 
-    static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { return 0; }
+    static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
 
     /** Used by the system when generating shader code, to see if this effect can be downcasted to
         the internal GrGLVertexEffect type */
index c8aae19503ff6a1654e5976112d07d6972c5dfad..a8d27ab26976c33b0a425a009885ac7759d4b09b 100644 (file)
@@ -24,9 +24,7 @@ class GrGpuGL;
 
 
 /** This class describes a program to generate. It also serves as a program cache key. Very little
-    of this is GL-specific. There is the generation of GrGLEffect::EffectKeys and the dst-read part
-    of the key set by GrGLShaderBuilder. If the interfaces that set those portions were abstracted
-    to be API-neutral then so could this class. */
+    of this is GL-specific. The GL-specific parts could be factored out into a subclass. */
 class GrGLProgramDesc {
 public:
     GrGLProgramDesc() {}
@@ -196,8 +194,6 @@ private:
         return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET);
     }
 
-    typedef GrBackendEffectFactory::EffectKey EffectKey;
-
     KeyHeader* header() { return this->atOffset<KeyHeader, kHeaderOffset>(); }
 
     // Shared code between setRandom() and Build().
@@ -227,13 +223,17 @@ private:
             fBaseIndex = kColor_EffectType == type ? 0 : desc->numColorEffects();
         }
 
-        EffectKey get(int index) const {
-            const uint16_t* offsets = reinterpret_cast<const uint16_t*>(
+        GrEffectKey get(int index) const {
+            const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t*>(
                 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset);
             // We store two uint16_ts per effect, one for the offset to the effect's key and one for
             // its length. Here we just need the offset.
-            uint16_t offset = offsets[2 * (fBaseIndex + index)];
-            return *reinterpret_cast<const EffectKey*>(fDesc->fKey.begin() + offset);
+            uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0];
+            uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1];
+            // Currently effects must add to the key in units of uint32_t.
+            SkASSERT(0 == (length % sizeof(uint32_t)));
+            return GrEffectKey(reinterpret_cast<const uint32_t*>(fDesc->fKey.begin() + offset),
+                               length / sizeof(uint32_t));
         }
     private:
         const GrGLProgramDesc*  fDesc;
index 9936aa54ad975897143549bc624a0272ebe25879..05b15013c21a8b63d5b0d58ceb34e434cb83b365 100644 (file)
@@ -12,7 +12,6 @@
 #include "gl/GrGLVertexEffect.h"
 #include "gl/GrGpuGL.h"
 
-typedef GrGLProgramEffects::EffectKey EffectKey;
 typedef GrGLProgramEffects::TransformedCoords TransformedCoords;
 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray;
 typedef GrGLProgramEffects::TextureSampler TextureSampler;
@@ -69,7 +68,7 @@ inline bool swizzle_requires_alpha_remapping(const GrGLCaps& caps,
 /**
  * Retrieves the matrix type from transformKey for the transform at transformIdx.
  */
-MatrixType get_matrix_type(EffectKey transformKey, int transformIdx) {
+MatrixType get_matrix_type(uint32_t transformKey, int transformIdx) {
     return static_cast<MatrixType>(
                (transformKey >> (kTransformKeyBits * transformIdx)) & kMatrixTypeKeyMask);
 }
@@ -79,7 +78,7 @@ MatrixType get_matrix_type(EffectKey transformKey, int transformIdx) {
  * the same coordinate set as the original GrCoordTransform if the position and local coords are
  * identical for this program.
  */
-GrCoordSet get_source_coords(EffectKey transformKey, int transformIdx) {
+GrCoordSet get_source_coords(uint32_t transformKey, int transformIdx) {
     return (transformKey >> (kTransformKeyBits * transformIdx)) & kPositionCoords_Flag ?
                kPosition_GrCoordSet :
                kLocal_GrCoordSet;
@@ -117,9 +116,9 @@ SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx)
 bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps,
                                           GrEffectKeyBuilder* b) {
 
-    EffectKey textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps);
-    EffectKey transformKey = GrGLProgramEffects::GenTransformKey(drawEffect);
-    EffectKey attribKey = GrGLProgramEffects::GenAttribKey(drawEffect);
+    uint32_t textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps);
+    uint32_t transformKey = GrGLProgramEffects::GenTransformKey(drawEffect);
+    uint32_t attribKey = GrGLProgramEffects::GenAttribKey(drawEffect);
     uint32_t classID = drawEffect.effect()->getFactory().effectClassID();
 
     // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
@@ -135,24 +134,24 @@ bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const
     return true;
 }
 
-EffectKey GrGLProgramEffects::GenAttribKey(const GrDrawEffect& drawEffect) {
-    EffectKey key = 0;
+uint32_t GrGLProgramEffects::GenAttribKey(const GrDrawEffect& drawEffect) {
+    uint32_t key = 0;
     int numAttributes = drawEffect.getVertexAttribIndexCount();
     SkASSERT(numAttributes <= 2);
     const int* attributeIndices = drawEffect.getVertexAttribIndices();
     for (int a = 0; a < numAttributes; ++a) {
-        EffectKey value = attributeIndices[a] << 3 * a;
+        uint32_t value = attributeIndices[a] << 3 * a;
         SkASSERT(0 == (value & key)); // keys for each attribute ought not to overlap
         key |= value;
     }
     return key;
 }
 
-EffectKey GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
-    EffectKey totalKey = 0;
+uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
+    uint32_t totalKey = 0;
     int numTransforms = drawEffect.effect()->numTransforms();
     for (int t = 0; t < numTransforms; ++t) {
-        EffectKey key = 0;
+        uint32_t key = 0;
         const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(t);
         SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType();
         SkMatrix::TypeMask type1;
@@ -182,8 +181,8 @@ EffectKey GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
     return totalKey;
 }
 
-EffectKey GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) {
-    EffectKey key = 0;
+uint32_t GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) {
+    uint32_t key = 0;
     int numTextures = drawEffect.effect()->numTextures();
     for (int t = 0; t < numTextures; ++t) {
         const GrTextureAccess& access = drawEffect.effect()->textureAccess(t);
@@ -250,7 +249,7 @@ void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int
 
 void GrGLVertexProgramEffects::emitEffect(GrGLFullShaderBuilder* builder,
                                           const GrEffectStage& stage,
-                                          EffectKey key,
+                                          const GrEffectKey& key,
                                           const char* outColor,
                                           const char* inColor,
                                           int stageIndex) {
@@ -301,7 +300,7 @@ void GrGLVertexProgramEffects::emitTransforms(GrGLFullShaderBuilder* builder,
                                               const GrDrawEffect& drawEffect,
                                               TransformedCoordsArray* outCoords) {
     SkTArray<Transform, true>& transforms = fTransforms.push_back();
-    EffectKey totalKey = GenTransformKey(drawEffect);
+    uint32_t totalKey = GenTransformKey(drawEffect);
     int numTransforms = drawEffect.effect()->numTransforms();
     transforms.push_back_n(numTransforms);
     for (int t = 0; t < numTransforms; t++) {
@@ -396,7 +395,7 @@ GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB
 }
 
 void GrGLVertexProgramEffectsBuilder::emitEffect(const GrEffectStage& stage,
-                                                 GrGLProgramEffects::EffectKey key,
+                                                 const GrEffectKey& key,
                                                  const char* outColor,
                                                  const char* inColor,
                                                  int stageIndex) {
@@ -408,7 +407,7 @@ void GrGLVertexProgramEffectsBuilder::emitEffect(const GrEffectStage& stage,
 
 void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyShaderBuilder* builder,
                                           const GrEffectStage& stage,
-                                          EffectKey key,
+                                          const GrEffectKey& key,
                                           const char* outColor,
                                           const char* inColor,
                                           int stageIndex) {
@@ -439,7 +438,7 @@ void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyShaderBuilder
                                            const GrDrawEffect& drawEffect,
                                            TransformedCoordsArray* outCoords) {
     int numTransforms = drawEffect.effect()->numTransforms();
-    EffectKey totalKey = GenTransformKey(drawEffect);
+    uint32_t totalKey = GenTransformKey(drawEffect);
     int texCoordIndex = builder->addTexCoordSets(numTransforms);
     SkNEW_APPEND_TO_TARRAY(&fTransforms, Transforms, (totalKey, texCoordIndex));
     SkString name;
@@ -469,7 +468,7 @@ void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu,
 void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
                                               const GrDrawEffect& drawEffect,
                                               int effectIdx) {
-    EffectKey totalKey = fTransforms[effectIdx].fTransformKey;
+    uint32_t totalKey = fTransforms[effectIdx].fTransformKey;
     int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
     int numTransforms = drawEffect.effect()->numTransforms();
     for (int t = 0; t < numTransforms; ++t) {
@@ -502,7 +501,7 @@ GrGLPathTexGenProgramEffectsBuilder::GrGLPathTexGenProgramEffectsBuilder(
 }
 
 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage,
-                                                     GrGLProgramEffects::EffectKey key,
+                                                     const GrEffectKey& key,
                                                      const char* outColor,
                                                      const char* inColor,
                                                      int stageIndex) {
index c4d884392a26c23488bd459789eccca1a716f170..c9ba9135a9bcc4d11ebaa069cf10ad86ff4672cd 100644 (file)
@@ -27,7 +27,6 @@ class GrGLFragmentOnlyShaderBuilder;
  */
 class GrGLProgramEffects : public SkRefCnt {
 public:
-    typedef GrBackendEffectFactory::EffectKey EffectKey;
     typedef GrGLUniformManager::UniformHandle UniformHandle;
 
     /**
@@ -104,9 +103,9 @@ protected:
     /**
      * Helpers for GenEffectMetaKey.
      */
-    static EffectKey GenAttribKey(const GrDrawEffect&);
-    static EffectKey GenTransformKey(const GrDrawEffect&);
-    static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
+    static uint32_t GenAttribKey(const GrDrawEffect&);
+    static uint32_t GenTransformKey(const GrDrawEffect&);
+    static uint32_t GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
 
     GrGLProgramEffects(int reserveCount)
         : fGLEffects(reserveCount)
@@ -149,7 +148,7 @@ public:
      * Emits the effect's shader code, and stores the necessary uniforms internally.
      */
     virtual void emitEffect(const GrEffectStage&,
-                            GrGLProgramEffects::EffectKey,
+                            const GrEffectKey&,
                             const char* outColor,
                             const char* inColor,
                             int stageIndex) = 0;
@@ -181,7 +180,7 @@ private:
      */
     void emitEffect(GrGLFullShaderBuilder*,
                     const GrEffectStage&,
-                    GrGLProgramEffects::EffectKey,
+                    const GrEffectKey&,
                     const char* outColor,
                     const char* inColor,
                     int stageIndex);
@@ -228,7 +227,7 @@ public:
     virtual ~GrGLVertexProgramEffectsBuilder() { }
 
     virtual void emitEffect(const GrEffectStage&,
-                            GrGLProgramEffects::EffectKey,
+                            const GrEffectKey&,
                             const char* outColor,
                             const char* inColor,
                             int stageIndex) SK_OVERRIDE;
@@ -272,7 +271,7 @@ private:
      */
     void emitEffect(GrGLFragmentOnlyShaderBuilder*,
                     const GrEffectStage&,
-                    GrGLProgramEffects::EffectKey,
+                    const GrEffectKey&,
                     const char* outColor,
                     const char* inColor,
                     int stageIndex);
@@ -295,10 +294,10 @@ private:
     void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx);
 
     struct Transforms {
-        Transforms(EffectKey transformKey, int texCoordIndex)
+        Transforms(uint32_t transformKey, int texCoordIndex)
             : fTransformKey(transformKey), fTexCoordIndex(texCoordIndex) {}
-        EffectKey fTransformKey;
-        int fTexCoordIndex;
+        uint32_t    fTransformKey;
+        int         fTexCoordIndex;
     };
 
     SkTArray<Transforms> fTransforms;
@@ -315,7 +314,7 @@ public:
     virtual ~GrGLPathTexGenProgramEffectsBuilder() { }
 
     virtual void emitEffect(const GrEffectStage&,
-                            GrGLProgramEffects::EffectKey,
+                            const GrEffectKey&,
                             const char* outColor,
                             const char* inColor,
                             int stageIndex) SK_OVERRIDE;
index c28cd0999bf3c70f4824770b06478b327a12e5f3..73e9a8f8032fe861691f32474b881de377f7621a 100644 (file)
@@ -31,7 +31,6 @@ class GrGLProgramDesc;
 class GrGLShaderBuilder {
 public:
     typedef GrTAllocator<GrGLShaderVar> VarArray;
-    typedef GrBackendEffectFactory::EffectKey EffectKey;
     typedef GrGLProgramEffects::TextureSampler TextureSampler;
     typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray;
     typedef GrGLUniformManager::BuilderUniform BuilderUniform;
index 40b4b34004d086694f95820c204d3c94bbc58eec..eba1fbe79573913a9b17cfab291ae05b571a2da9 100644 (file)
@@ -26,7 +26,7 @@ public:
      */
     virtual void emitCode(GrGLFullShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray& coords,
@@ -37,7 +37,7 @@ public:
      */
     virtual void emitCode(GrGLShaderBuilder* builder,
                           const GrDrawEffect& drawEffect,
-                          EffectKey key,
+                          const GrEffectKey& key,
                           const char* outputColor,
                           const char* inputColor,
                           const TransformedCoordsArray& coords,