Stop lieing about GrBatch color for Rects

BUG=skia:

Review URL: https://codereview.chromium.org/920423003
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 6b825e7..e3e0d5d 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -711,10 +711,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -865,7 +861,6 @@
         bool fCoverageIgnored;
     };
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
 };
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index cbce6aa..9a37427 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -727,10 +727,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -813,7 +809,6 @@
         bool fCoverageIgnored;
     };
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
     const GrIndexBuffer* fLinesIndexBuffer;
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 420c9e7..7e86c0b 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -70,24 +70,11 @@
 
     void getInvariantOutputColor(GrInitInvariantOutput* out) const SK_OVERRIDE {
         // When this is called on a batch, there is only one geometry bundle
-        if (!this->canTweakAlphaForCoverage() && GrColorIsOpaque(fGeoData[0].fColor)) {
-            out->setUnknownOpaqueFourComponents();
-        } else {
-            out->setUnknownFourComponents();
-        }
+        out->setKnownFourComponents(fGeoData[0].fColor);
     }
 
     void getInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERRIDE {
-        if (this->canTweakAlphaForCoverage()) {
-            // uniform coverage
-            out->setKnownSingleComponent(0xff);
-        } else {
-            out->setUnknownSingleComponent();
-        }
-    }
-
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
+        out->setUnknownSingleComponent();
     }
 
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
@@ -103,6 +90,7 @@
         fBatch.fColor = fGeoData[0].fColor;
         fBatch.fUsesLocalCoords = init.fUsesLocalCoords;
         fBatch.fCoverageIgnored = init.fCoverageIgnored;
+        fBatch.fCanTweakAlphaForCoverage = init.fCanTweakAlphaForCoverage;
     }
 
     void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) SK_OVERRIDE {
@@ -194,19 +182,12 @@
 
     GrColor color() const { return fBatch.fColor; }
     bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
-    bool canTweakAlphaForCoverage() const { return fBatchOpt.fCanTweakAlphaForCoverage; }
+    bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCoverage; }
     bool colorIgnored() const { return fBatch.fColorIgnored; }
     const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
 
     bool onCombineIfPossible(GrBatch* t) SK_OVERRIDE {
         AAFillRectBatch* that = t->cast<AAFillRectBatch>();
-        if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
-            return false;
-        }
-
-        if (this->colorIgnored() != that->colorIgnored()) {
-            return false;
-        }
 
         SkASSERT(this->usesLocalCoords() == that->usesLocalCoords());
         // We apply the viewmatrix to the rect points on the cpu.  However, if the pipeline uses
@@ -219,6 +200,13 @@
         if (this->color() != that->color()) {
             fBatch.fColor = GrColor_ILLEGAL;
         }
+
+        // In the event of two batches, one who can tweak, one who cannot, we just fall back to
+        // not tweaking
+        if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
+            fBatch.fCanTweakAlphaForCoverage = false;
+        }
+
         fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
         return true;
     }
@@ -321,9 +309,9 @@
         bool fUsesLocalCoords;
         bool fColorIgnored;
         bool fCoverageIgnored;
+        bool fCanTweakAlphaForCoverage;
     };
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     const GrIndexBuffer* fIndexBuffer;
     SkSTArray<1, Geometry, true> fGeoData;
diff --git a/src/gpu/GrBatch.h b/src/gpu/GrBatch.h
index 2f1afee..48327c6 100644
--- a/src/gpu/GrBatch.h
+++ b/src/gpu/GrBatch.h
@@ -39,10 +39,6 @@
  * information will be communicated to the GrBatch prior to geometry generation.
  */
 
-struct GrBatchOpt {
-  bool fCanTweakAlphaForCoverage;
-};
-
 class GrBatch : public SkRefCnt {
 public:
     SK_DECLARE_INST_COUNT(GrBatch)
@@ -54,13 +50,9 @@
     virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const = 0;
 
     /*
-     * initBatchOpt is used to communicate possible optimizations to the GrBatch.  initBatchTracker
-     * is a hook for the some additional overrides from the GrXferProcessor.  This is a bit
-     * confusing but has to be like this until GrBatch is everywhere.
-     *
-     * TODO combine to a single init call when GrBatch is everywhere.
+     * initBatchTracker is a hook for the some additional overrides / optimization possibilities
+     * from the GrXferProcessor.
      */
-    virtual void initBatchOpt(const GrBatchOpt&) = 0;
     virtual void initBatchTracker(const GrPipelineInfo& init) = 0;
 
     bool combineIfPossible(GrBatch* that) {
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e22c45b..7ccdce5 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -545,11 +545,6 @@
         return;
     }
 
-    // init batch and my other crap
-    GrBatchOpt batchOpt;
-    batchOpt.fCanTweakAlphaForCoverage = pipelineBuilder->canTweakAlphaForCoverage();
-    batch->initBatchOpt(batchOpt);
-
     GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, devBounds, this);
     if (pipelineInfo.mustSkipDraw()) {
         return;
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 481501f..d7f88fe 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -711,10 +711,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -873,7 +869,6 @@
     static const int kVertsPerCircle = 4;
     static const int kIndicesPerCircle = 6;
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
 };
@@ -966,10 +961,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -1133,7 +1124,6 @@
     static const int kVertsPerEllipse = 4;
     static const int kIndicesPerEllipse = 6;
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
 };
@@ -1267,10 +1257,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -1425,7 +1411,6 @@
     static const int kVertsPerEllipse = 4;
     static const int kIndicesPerEllipse = 6;
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
 };
@@ -1655,10 +1640,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -1831,7 +1812,6 @@
         bool fCoverageIgnored;
     };
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
     const GrIndexBuffer* fIndexBuffer;
@@ -1864,10 +1844,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {
-        fBatchOpt = batchOpt;
-    }
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {
@@ -2050,7 +2026,6 @@
         bool fCoverageIgnored;
     };
 
-    GrBatchOpt fBatchOpt;
     BatchTracker fBatch;
     SkSTArray<1, Geometry, true> fGeoData;
     const GrIndexBuffer* fIndexBuffer;
diff --git a/src/gpu/GrTestBatch.h b/src/gpu/GrTestBatch.h
index ebff721..677abaf 100644
--- a/src/gpu/GrTestBatch.h
+++ b/src/gpu/GrTestBatch.h
@@ -35,8 +35,6 @@
         out->setUnknownSingleComponent();
     }
 
-    void initBatchOpt(const GrBatchOpt& batchOpt) {}
-
     void initBatchTracker(const GrPipelineInfo& init) SK_OVERRIDE {
         // Handle any color overrides
         if (init.fColorIgnored) {