Make GrPipelineAnalysis a nested class of GrProcessorSet.

It is renamed to FragmentProcessorAnalysis since it represents the outputs of the final FPs.

It now stores the analysis results that are subsequently needed rather than exposing GrProcOptInfo.

GrProcOptInfo is now only used on color FPs (not coverage).

Miscellaneous related renamings.


Change-Id: I95c518a7a76df6dc294a9fa67c611f8f653247bc
Reviewed-on: https://skia-review.googlesource.com/8534
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp
index 595d05c..1794562 100644
--- a/src/gpu/GrProcessorSet.cpp
+++ b/src/gpu/GrProcessorSet.cpp
@@ -6,6 +6,9 @@
  */
 
 #include "GrProcessorSet.h"
+#include "GrAppliedClip.h"
+#include "GrCaps.h"
+#include "GrProcOptInfo.h"
 
 GrProcessorSet::GrProcessorSet(GrPaint&& paint) {
     fXPFactory = paint.fXPFactory;
@@ -29,3 +32,72 @@
         fFlags |= kAllowSRGBInputs_Flag;
     }
 }
+
+//////////////////////////////////////////////////////////////////////////////
+
+void GrProcessorSet::FragmentProcessorAnalysis::internalReset(const GrPipelineInput& colorInput,
+                                                              const GrPipelineInput coverageInput,
+                                                              const GrProcessorSet& processors,
+                                                              bool usesPLSDstRead,
+                                                              const GrFragmentProcessor* clipFP,
+                                                              const GrCaps& caps) {
+    GrProcOptInfo colorInfo(colorInput);
+    fUsesPLSDstRead = usesPLSDstRead;
+    fCompatibleWithCoverageAsAlpha = !coverageInput.isLCDCoverage();
+
+    const GrFragmentProcessor* const* fps = processors.fFragmentProcessors.get();
+    colorInfo.analyzeProcessors(fps, processors.fColorFragmentProcessorCnt);
+    fCompatibleWithCoverageAsAlpha &= colorInfo.allProcessorsCompatibleWithCoverageAsAlpha();
+    fps += processors.fColorFragmentProcessorCnt;
+    int n = processors.numCoverageFragmentProcessors();
+    bool hasCoverageFP = n > 0;
+    for (int i = 0; i < n && fCompatibleWithCoverageAsAlpha; ++i) {
+        if (!fps[i]->compatibleWithCoverageAsAlpha()) {
+            fCompatibleWithCoverageAsAlpha = false;
+            // Other than tests that exercise atypical behavior we expect all coverage FPs to be
+            // compatible with the coverage-as-alpha optimization.
+            GrCapsDebugf(&caps, "Coverage FP is not compatible with coverage as alpha.\n");
+            break;
+        }
+    }
+
+    if (clipFP) {
+        fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
+        hasCoverageFP = true;
+    }
+    fInitialColorProcessorsToEliminate =
+            colorInfo.initialProcessorsToEliminate(&fOverrideInputColor);
+
+    bool opaque = colorInfo.isOpaque();
+    if (colorInfo.hasKnownOutputColor(&fKnownOutputColor)) {
+        fColorType = opaque ? ColorType::kOpaqueConstant : ColorType::kConstant;
+    } else if (opaque) {
+        fColorType = ColorType::kOpaque;
+    } else {
+        fColorType = ColorType::kUnknown;
+    }
+
+    if (coverageInput.isLCDCoverage()) {
+        fCoverageType = CoverageType::kLCD;
+    } else {
+        fCoverageType = hasCoverageFP || !coverageInput.isSolidWhite()
+                                ? CoverageType::kSingleChannel
+                                : CoverageType::kNone;
+    }
+}
+
+void GrProcessorSet::FragmentProcessorAnalysis::reset(const GrPipelineInput& colorInput,
+                                                      const GrPipelineInput coverageInput,
+                                                      const GrProcessorSet& processors,
+                                                      bool usesPLSDstRead,
+                                                      const GrAppliedClip& appliedClip,
+                                                      const GrCaps& caps) {
+    this->internalReset(colorInput, coverageInput, processors, usesPLSDstRead,
+                        appliedClip.clipCoverageFragmentProcessor(), caps);
+}
+
+GrProcessorSet::FragmentProcessorAnalysis::FragmentProcessorAnalysis(
+        const GrPipelineInput& colorInput, const GrPipelineInput coverageInput, const GrCaps& caps)
+        : FragmentProcessorAnalysis() {
+    this->internalReset(colorInput, coverageInput, GrProcessorSet(GrPaint()), false, nullptr, caps);
+}