Rename GrDrawOp::xpRequiresDstTexture to finalize and change return type to an enum

Bug: skia:
Change-Id: I0f9d9d3ef1dd20821f171f7d6237491921fbbd97
Reviewed-on: https://skia-review.googlesource.com/20142
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 17a7db8..a6dcdf6 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1790,7 +1790,7 @@
     }
 
     GrXferProcessor::DstProxy dstProxy;
-    if (op->xpRequiresDstTexture(*this->caps(), &appliedClip)) {
+    if (op->finalize(*this->caps(), &appliedClip) == GrDrawOp::RequiresDstTexture::kYes) {
         if (!this->setupDstProxy(this->asRenderTargetProxy(), clip, op->bounds(), &dstProxy)) {
             return SK_InvalidUniqueID;
         }
diff --git a/src/gpu/instanced/InstancedOp.cpp b/src/gpu/instanced/InstancedOp.cpp
index 40e3c5e..9b80540 100644
--- a/src/gpu/instanced/InstancedOp.cpp
+++ b/src/gpu/instanced/InstancedOp.cpp
@@ -120,7 +120,7 @@
     fInfo.fHasParams = true;
 }
 
-bool InstancedOp::xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) {
+GrDrawOp::RequiresDstTexture InstancedOp::finalize(const GrCaps& caps, const GrAppliedClip* clip) {
     GrProcessorAnalysisCoverage coverageInput;
     bool isMixedSamples = false;
     if (GrAAType::kCoverage == fInfo.aaType() ||
@@ -151,7 +151,7 @@
 
     fInfo.fUsesLocalCoords = analysis.usesLocalCoords();
     fRequiresBarrierOnOverlap = analysis.requiresBarrierBetweenOverlappingDraws();
-    return analysis.requiresDstTexture();
+    return analysis.requiresDstTexture() ? RequiresDstTexture::kYes : RequiresDstTexture::kNo;
 }
 
 void InstancedOp::wasRecorded(GrRenderTargetOpList* opList) {
diff --git a/src/gpu/instanced/InstancedOp.h b/src/gpu/instanced/InstancedOp.h
index 7848eff..204a944 100644
--- a/src/gpu/instanced/InstancedOp.h
+++ b/src/gpu/instanced/InstancedOp.h
@@ -64,7 +64,7 @@
         return GrAATypeIsHW(fInfo.aaType()) ? FixedFunctionFlags::kUsesHWAA
                                             : FixedFunctionFlags::kNone;
     }
-    bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) override;
+    RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override;
 
     // Registers the op with the InstancedRendering list of tracked ops.
     void wasRecorded(GrRenderTargetOpList*) override;
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index f0207f4..261f0c4 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -757,7 +757,7 @@
 
     FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             &fPaths.back().fColor);
     }
diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp
index db856b2..30023f3 100644
--- a/src/gpu/ops/GrAAFillRectOp.cpp
+++ b/src/gpu/ops/GrAAFillRectOp.cpp
@@ -219,9 +219,9 @@
 
     FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor color = this->first()->color();
-        bool result = fHelper.xpRequiresDstTexture(
+        auto result = fHelper.xpRequiresDstTexture(
                 caps, clip, GrProcessorAnalysisCoverage::kSingleChannel, &color);
         this->first()->setColor(color);
         return result;
diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp
index e423583..662ce66 100644
--- a/src/gpu/ops/GrAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrAAStrokeRectOp.cpp
@@ -191,7 +191,7 @@
 
     FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             &fRects.back().fColor);
     }
diff --git a/src/gpu/ops/GrDrawOp.h b/src/gpu/ops/GrDrawOp.h
index d7887b6..36f4da4 100644
--- a/src/gpu/ops/GrDrawOp.h
+++ b/src/gpu/ops/GrDrawOp.h
@@ -72,14 +72,15 @@
     GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(FixedFunctionFlags);
     virtual FixedFunctionFlags fixedFunctionFlags() const = 0;
 
+    enum class RequiresDstTexture : bool { kNo = false, kYes = true };
     /**
      * This is called after the GrAppliedClip has been computed and just prior to recording the op
-     * or combining it with a previously recorded op. It is used to determine whether a copy of the
-     * destination (or destination texture itself) needs to be provided to the xp when this op
-     * executes. This is guaranteed to be called before an op is recorded. However, this is also
-     * called on ops that are not recorded because they combine with a previously recorded op.
+     * or combining it with a previously recorded op. The op should convert any proxies or resources
+     * it owns to "pending io" status so that resource allocation can be more optimal. Additionally,
+     * at this time the op must report whether a copy of the destination (or destination texture
+     * itself) needs to be provided to the GrXferProcessor when this op executes.
      */
-    virtual bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) = 0;
+    virtual RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) = 0;
 
 protected:
     static SkString DumpPipelineInfo(const GrPipeline& pipeline);
diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h
index 8df85b4..ce9e6e0 100644
--- a/src/gpu/ops/GrDrawPathOp.h
+++ b/src/gpu/ops/GrDrawPathOp.h
@@ -30,8 +30,9 @@
         }
         return FixedFunctionFlags::kUsesStencil;
     }
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
-        return this->doProcessorAnalysis(caps, clip).requiresDstTexture();
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
+        return this->doProcessorAnalysis(caps, clip).requiresDstTexture() ? RequiresDstTexture::kYes
+                                                                          : RequiresDstTexture::kNo;
     }
 
 protected:
diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h
index 349e8b6..bf467e0 100644
--- a/src/gpu/ops/GrMeshDrawOp.h
+++ b/src/gpu/ops/GrMeshDrawOp.h
@@ -131,9 +131,9 @@
         SkFAIL("This should never be called for legacy mesh draw ops.");
         return FixedFunctionFlags::kNone;
     }
-    bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) override {
+    RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
         SkFAIL("Should never be called for legacy mesh draw ops.");
-        return false;
+        return RequiresDstTexture::kNo;
     }
 
 protected:
diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp
index 2fd44f8..c971e2f 100644
--- a/src/gpu/ops/GrNonAAFillRectOp.cpp
+++ b/src/gpu/ops/GrNonAAFillRectOp.cpp
@@ -154,7 +154,7 @@
         return str;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fRects.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kNone, color);
     }
@@ -272,7 +272,7 @@
         return str;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fRects.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kNone, color);
     }
diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
index 016c637..2c3d822 100644
--- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp
+++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp
@@ -119,10 +119,9 @@
 
     FixedFunctionFlags fixedFunctionFlags() const override { return fHelper.fixedFunctionFlags(); }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
-        bool result = fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kNone,
-                                                   &fColor);
-        return result;
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
+        return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kNone,
+                                            &fColor);
     }
 
 private:
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index 0eedc42..45b290b 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -800,7 +800,7 @@
         return string;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fCircles.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             color);
@@ -1263,7 +1263,7 @@
         return string;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fEllipses.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             color);
@@ -1489,7 +1489,7 @@
         return string;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fEllipses.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             color);
@@ -1802,7 +1802,7 @@
         return string;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fRRects.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             color);
@@ -2156,7 +2156,7 @@
         return string;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) override {
+    RequiresDstTexture finalize(const GrCaps& caps, const GrAppliedClip* clip) override {
         GrColor* color = &fRRects.front().fColor;
         return fHelper.xpRequiresDstTexture(caps, clip, GrProcessorAnalysisCoverage::kSingleChannel,
                                             color);
diff --git a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
index 543f977..9bdafc8 100644
--- a/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
+++ b/src/gpu/ops/GrSimpleMeshDrawOpHelper.h
@@ -94,8 +94,9 @@
         return result;
     }
 
-    bool xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip,
-                              GrProcessorAnalysisCoverage geometryCoverage, GrColor* color) {
+    GrDrawOp::RequiresDstTexture xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip,
+                                                      GrProcessorAnalysisCoverage geometryCoverage,
+                                                      GrColor* color) {
         SkDEBUGCODE(fDidAnalysis = true);
         GrProcessorSet::Analysis analysis;
         if (fProcessors) {
@@ -113,7 +114,8 @@
         fRequiresDstTexture = analysis.requiresDstTexture();
         fUsesLocalCoords = analysis.usesLocalCoords();
         fCompatibleWithAlphaAsCoveage = analysis.isCompatibleWithCoverageAsAlpha();
-        return analysis.requiresDstTexture();
+        return analysis.requiresDstTexture() ? GrDrawOp::RequiresDstTexture::kYes
+                                             : GrDrawOp::RequiresDstTexture::kNo;
     }
 
     bool usesLocalCoords() const {
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index e4663e1..0e67acf 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -262,7 +262,9 @@
 private:
     const char* name() const override { return "GrMeshTestOp"; }
     FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
-    bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) override { return false; }
+    RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
+        return RequiresDstTexture::kNo;
+    }
     bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; }
     void onPrepare(GrOpFlushState*) override {}
     void onExecute(GrOpFlushState* state) override {
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 6c01400..007702a 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -119,7 +119,9 @@
 private:
     const char* name() const override { return "GrPipelineDynamicStateTestOp"; }
     FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
-    bool xpRequiresDstTexture(const GrCaps&, const GrAppliedClip*) override { return false; }
+    RequiresDstTexture finalize(const GrCaps&, const GrAppliedClip*) override {
+        return RequiresDstTexture::kNo;
+    }
     bool onCombineIfPossible(GrOp* other, const GrCaps& caps) override { return false; }
     void onPrepare(GrOpFlushState*) override {}
     void onExecute(GrOpFlushState* state) override {