Don't make dst copies when color stage requires dst but color writes are disabled.

R=robertphillips@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@9146 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 068f321..64893b4 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -973,12 +973,14 @@
     GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
     GrDrawState::AutoStageDisable atr(fDrawState);
 
-    bool prAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
+    bool useAA = paint.isAntiAlias() &&
+                 !this->getRenderTarget()->isMultisampled() &&
+                 !disable_coverage_aa_for_blend(target);
 
-    if (!fOvalRenderer->drawSimpleRRect(target, this, prAA, rect, stroke)) {
+    if (!fOvalRenderer->drawSimpleRRect(target, this, useAA, rect, stroke)) {
         SkPath path;
         path.addRRect(rect);
-        this->internalDrawPath(target, prAA, path, stroke);
+        this->internalDrawPath(target, useAA, path, stroke);
     }
 }
 
@@ -991,7 +993,9 @@
     GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
     GrDrawState::AutoStageDisable atr(fDrawState);
 
-    bool useAA = paint.isAntiAlias() && !this->getRenderTarget()->isMultisampled();
+    bool useAA = paint.isAntiAlias() &&
+                 !this->getRenderTarget()->isMultisampled() &&
+                 !disable_coverage_aa_for_blend(target);
 
     if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) {
         SkPath path;
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index 90188ea..591e157 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -163,6 +163,16 @@
     return true;
 }
 
+bool GrDrawState::willEffectReadDstColor() const {
+    int startStage = this->isColorWriteDisabled() ? this->getFirstCoverageStage() : 0;
+    for (int s = startStage; s < kNumStages; ++s) {
+        if (this->isStageEnabled(s) && (*this->getStage(s).getEffect())->willReadDstColor()) {
+            return true;
+        }
+    }
+    return false;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 
 bool GrDrawState::srcAlphaWillBeOne() const {
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 230b2fa..80ad28e 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -451,14 +451,7 @@
     /**
      * Checks whether any of the effects will read the dst pixel color.
      */
-    bool willEffectReadDstColor() const {
-        for (int s = 0; s < kNumStages; ++s) {
-            if (this->isStageEnabled(s) && (*this->getStage(s).getEffect())->willReadDstColor()) {
-                return true;
-            }
-        }
-        return false;
-    }
+    bool willEffectReadDstColor() const;
 
     /// @}