Don't compare coord change matrices to determine effect compatibility when using explicit local coords.

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/438053002
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index 5c8817c..90514b2 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -33,3 +33,7 @@
 ## epoger will rebaseline by 25 Dec 2013
 #gradtext
 
+#bsalomon: Slight AA changes to a rect in GPU configs after change that increases
+#batching
+bleed
+
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index fb0620d..65c7beb 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -40,27 +40,32 @@
         memcpy(fVertexAttribIndices, other.fVertexAttribIndices, sizeof(fVertexAttribIndices));
         return *this;
     }
+    
+    static bool AreCompatible(const GrEffectStage& a, const GrEffectStage& b,
+                              bool usingExplicitLocalCoords) {
+        SkASSERT(NULL != a.fEffect.get());
+        SkASSERT(NULL != b.fEffect.get());
 
-    bool operator== (const GrEffectStage& other) const {
-        SkASSERT(NULL != fEffect.get());
-        SkASSERT(NULL != other.fEffect.get());
-
-        if (!this->getEffect()->isEqual(*other.getEffect())) {
+        if (!a.getEffect()->isEqual(*b.getEffect())) {
             return false;
         }
 
-        if (fCoordChangeMatrixSet != other.fCoordChangeMatrixSet) {
-            return false;
-        }
-
-        if (!fCoordChangeMatrixSet) {
+        // We always track the coord change matrix, but it has no effect when explicit local coords
+        // are used.
+        if (usingExplicitLocalCoords) {
             return true;
         }
 
-        return fCoordChangeMatrix == other.fCoordChangeMatrix;
-    }
+        if (a.fCoordChangeMatrixSet != b.fCoordChangeMatrixSet) {
+            return false;
+        }
 
-    bool operator!= (const GrEffectStage& s) const { return !(*this == s); }
+        if (!a.fCoordChangeMatrixSet) {
+            return true;
+        }
+
+        return a.fCoordChangeMatrix == b.fCoordChangeMatrix;
+    }
 
     /**
      * This is called when the coordinate system in which the geometry is specified will change.
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index d1b7a66..b894cb5 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -893,13 +893,17 @@
             fDrawFace != that.fDrawFace) {
             return false;
         }
+
+        bool explicitLocalCoords = this->hasLocalCoordAttribute();
         for (int i = 0; i < fColorStages.count(); i++) {
-            if (fColorStages[i] != that.fColorStages[i]) {
+            if (!GrEffectStage::AreCompatible(fColorStages[i], that.fColorStages[i],
+                explicitLocalCoords)) {
                 return false;
             }
         }
         for (int i = 0; i < fCoverageStages.count(); i++) {
-            if (fCoverageStages[i] != that.fCoverageStages[i]) {
+            if (!GrEffectStage::AreCompatible(fCoverageStages[i], that.fCoverageStages[i],
+                explicitLocalCoords)) {
                 return false;
             }
         }
diff --git a/src/gpu/gl/GrGLProgramEffects.cpp b/src/gpu/gl/GrGLProgramEffects.cpp
index cff31e2..3fa4f15 100644
--- a/src/gpu/gl/GrGLProgramEffects.cpp
+++ b/src/gpu/gl/GrGLProgramEffects.cpp
@@ -90,8 +90,11 @@
 SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx) {
     const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(transformIdx);
     SkMatrix combined;
-    if (kLocal_GrCoordSet == coordTransform.sourceCoords() &&
-        !drawEffect.programHasExplicitLocalCoords()) {
+
+    if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
+        // If we have explicit local coords then we shouldn't need a coord change.
+        SkASSERT(!drawEffect.programHasExplicitLocalCoords() ||
+                 drawEffect.getCoordChangeMatrix().isIdentity());
         combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChangeMatrix());
     } else {
         combined = coordTransform.getMatrix();