Don't look at current vertex layout when vertex source hasn't been set

Review URL: http://codereview.appspot.com/5959047



git-svn-id: http://skia.googlecode.com/svn/trunk@3545 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 5cce435..ef03a61 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -853,9 +853,7 @@
            kISC_BlendCoeff == dstCoeff;
 }
 
-
-bool GrDrawTarget::srcAlphaWillBeOne() const {
-    const GrVertexLayout& layout = this->getGeomSrc().fVertexLayout;
+bool GrDrawTarget::srcAlphaWillBeOne(GrVertexLayout layout) const {
     const GrDrawState& drawState = this->getDrawState();
 
     // Check if per-vertex or constant color may have partial alpha
@@ -882,12 +880,28 @@
     return true;
 }
 
+namespace {
+GrVertexLayout default_blend_opts_vertex_layout() {
+    GrVertexLayout layout = 0;
+    for (int s = 0; s < GrDrawState::kNumStages; ++s) {
+        layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(s);
+    }
+    return layout;
+}
+}
+
 GrDrawTarget::BlendOptFlags
 GrDrawTarget::getBlendOpts(bool forceCoverage,
                            GrBlendCoeff* srcCoeff,
                            GrBlendCoeff* dstCoeff) const {
 
-    const GrVertexLayout& layout = this->getGeomSrc().fVertexLayout;
+    GrVertexLayout layout;
+    if (kNone_GeometrySrcType == this->getGeomSrc().fVertexSrc) {
+        layout = default_blend_opts_vertex_layout();
+    } else {
+        layout = this->getVertexLayout();
+    }
+
     const GrDrawState& drawState = this->getDrawState();
 
     GrBlendCoeff bogusSrcCoeff, bogusDstCoeff;
@@ -917,7 +931,7 @@
         *dstCoeff = kOne_BlendCoeff;
     }
 
-    bool srcAIsOne = this->srcAlphaWillBeOne();
+    bool srcAIsOne = this->srcAlphaWillBeOne(layout);
     bool dstCoeffIsOne = kOne_BlendCoeff == *dstCoeff ||
                          (kSA_BlendCoeff == *dstCoeff && srcAIsOne);
     bool dstCoeffIsZero = kZero_BlendCoeff == *dstCoeff ||
@@ -1022,11 +1036,6 @@
            kNone_BlendOpt != this->getBlendOpts(true);
 }
 
-bool GrDrawTarget::drawWillReadDst() const {
-    return SkToBool((kDisableBlend_BlendOptFlag | kSkipDraw_BlendOptFlag) &
-                    this->getBlendOpts());
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 
 void GrDrawTarget::drawIndexedInstances(GrPrimitiveType type,