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.h b/src/gpu/GrProcessorSet.h
index 19c3b22..bd78dc9 100644
--- a/src/gpu/GrProcessorSet.h
+++ b/src/gpu/GrProcessorSet.h
@@ -10,9 +10,10 @@
 
 #include "GrFragmentProcessor.h"
 #include "GrPaint.h"
-#include "GrPipeline.h"
+#include "GrPipelineInput.h"
 #include "SkTemplates.h"
 
+class GrAppliedClip;
 class GrXPFactory;
 
 class GrProcessorSet : private SkNoncopyable {
@@ -43,19 +44,65 @@
 
     const GrXPFactory* xpFactory() const { return fXPFactory; }
 
-    void analyzeFragmentProcessors(GrPipelineAnalysis* analysis) const {
-        const GrFragmentProcessor* const* fps = fFragmentProcessors.get();
-        analysis->fColorPOI.analyzeProcessors(fps, fColorFragmentProcessorCnt);
-        fps += fColorFragmentProcessorCnt;
-        analysis->fCoveragePOI.analyzeProcessors(fps, this->numCoverageFragmentProcessors());
-    }
-
     bool usesDistanceVectorField() const { return SkToBool(fFlags & kUseDistanceVectorField_Flag); }
     bool disableOutputConversionToSRGB() const {
         return SkToBool(fFlags & kDisableOutputConversionToSRGB_Flag);
     }
     bool allowSRGBInputs() const { return SkToBool(fFlags & kAllowSRGBInputs_Flag); }
 
+    /**
+     * This is used to track analysis of color and coverage values through the fragment processors.
+     */
+    class FragmentProcessorAnalysis {
+    public:
+        FragmentProcessorAnalysis() = default;
+        // This version is used by a unit test that assumes no clip, no processors, and no PLS.
+        FragmentProcessorAnalysis(const GrPipelineInput& colorInput,
+                                  const GrPipelineInput coverageInput, const GrCaps&);
+
+        void reset(const GrPipelineInput& colorInput, const GrPipelineInput coverageInput,
+                   const GrProcessorSet&, bool usesPLSDstRead, const GrAppliedClip&, const GrCaps&);
+
+        int initialColorProcessorsToEliminate(GrColor* newInputColor) const {
+            if (fInitialColorProcessorsToEliminate > 0) {
+                *newInputColor = fOverrideInputColor;
+            }
+            return fInitialColorProcessorsToEliminate;
+        }
+
+        bool usesPLSDstRead() const { return fUsesPLSDstRead; }
+        bool isCompatibleWithCoverageAsAlpha() const { return fCompatibleWithCoverageAsAlpha; }
+        bool isOutputColorOpaque() const {
+            return ColorType::kOpaque == fColorType || ColorType::kOpaqueConstant == fColorType;
+        }
+        bool hasKnownOutputColor(GrColor* color = nullptr) const {
+            bool constant =
+                    ColorType::kConstant == fColorType || ColorType::kOpaqueConstant == fColorType;
+            if (constant && color) {
+                *color = fKnownOutputColor;
+            }
+            return constant;
+        }
+        bool hasCoverage() const { return CoverageType::kNone != fCoverageType; }
+        bool hasLCDCoverage() const { return CoverageType::kLCD == fCoverageType; }
+
+    private:
+        void internalReset(const GrPipelineInput& colorInput, const GrPipelineInput coverageInput,
+                           const GrProcessorSet&, bool usesPLSDstRead,
+                           const GrFragmentProcessor* clipFP, const GrCaps&);
+
+        enum class ColorType { kUnknown, kOpaqueConstant, kConstant, kOpaque };
+        enum class CoverageType { kNone, kSingleChannel, kLCD };
+
+        bool fUsesPLSDstRead = false;
+        bool fCompatibleWithCoverageAsAlpha = true;
+        CoverageType fCoverageType = CoverageType::kNone;
+        ColorType fColorType = ColorType::kUnknown;
+        int fInitialColorProcessorsToEliminate = 0;
+        GrColor fOverrideInputColor;
+        GrColor fKnownOutputColor;
+    };
+
 private:
     const GrXPFactory* fXPFactory = nullptr;
     SkAutoSTArray<4, const GrFragmentProcessor*> fFragmentProcessors;