Add GrFragmentProcessor flag indicating dest-color readback.

The GrProcessor analysis pass needs to know if the dest-texture is
required. XPs already had a flag for this; now FPs have one as well.

Change-Id: I4ff88edfc7e9c735e9c2e23327c65e9f569a6b60
Bug: skia:12066
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415166
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/GrProcessorAnalysis.cpp b/src/gpu/GrProcessorAnalysis.cpp
index 76f52da..72285e6 100644
--- a/src/gpu/GrProcessorAnalysis.cpp
+++ b/src/gpu/GrProcessorAnalysis.cpp
@@ -5,6 +5,7 @@
  * found in the LICENSE file.
  */
 
+#include "src/gpu/GrCaps.h"
 #include "src/gpu/GrGeometryProcessor.h"
 #include "src/gpu/GrProcessorAnalysis.h"
 #include "src/gpu/ops/GrDrawOp.h"
@@ -16,6 +17,7 @@
     fCompatibleWithCoverageAsAlpha = true;
     fIsOpaque = input.isOpaque();
     fUsesLocalCoords = false;
+    fWillReadDstColor = false;
     fProcessorsToEliminate = 0;
     fOutputColorKnown = input.isConstant(&fLastKnownOutputColor);
     for (int i = 0; i < count; ++i) {
@@ -27,6 +29,7 @@
             // We reset these flags since the earlier fragment processors are being eliminated.
             fCompatibleWithCoverageAsAlpha = true;
             fUsesLocalCoords = false;
+            fWillReadDstColor = false;
             continue;
         }
 
@@ -40,5 +43,12 @@
         if (fp->usesVaryingCoords()) {
             fUsesLocalCoords = true;
         }
+        if (fp->willReadDstColor()) {
+            fWillReadDstColor = true;
+        }
     }
 }
+
+bool GrColorFragmentProcessorAnalysis::requiresDstTexture(const GrCaps& caps) const {
+    return this->willReadDstColor() && !caps.shaderCaps()->dstReadInShaderSupport();
+}