Reland "Fix texture barriers on DMSAA"

This reverts commit 9a2d3d1e19e7bd15f7aa0c054197c980eb356477.

Reason for revert: relanding with fix

Original change's description:
> Revert "Fix texture barriers on DMSAA"
>
> This reverts commit 1a3f4ab4901c2294d13c785717655ce059eb42fa.
>
> Reason for revert: breaking dmsaa test on intel hd405, https://ci.chromium.org/raw/build/logs.chromium.org/skia/54538c41f1c1b111/+/annotations
>
> Original change's description:
> > Fix texture barriers on DMSAA
> >
> > Bug: skia:11396
> > Change-Id: Iad74958c05ed086fe85656b9dc5418d5ab4589e7
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419838
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Chris Dalton <csmartdalton@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com
>
> Change-Id: I8be8107a98584dfb7f831a296078753fecfcebcf
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11396
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421056
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:11396
Change-Id: I6c65a3639e87b32a30774f33445bb3174a4fdffa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421058
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrOpsTask.cpp b/src/gpu/GrOpsTask.cpp
index 5f2884c..e721f88 100644
--- a/src/gpu/GrOpsTask.cpp
+++ b/src/gpu/GrOpsTask.cpp
@@ -434,7 +434,8 @@
     // can end up with GrOpsTasks that only have a discard load op and no ops. For vulkan validation
     // we need to keep that discard and not drop it. Once we have reduce op list splitting enabled
     // we shouldn't end up with GrOpsTasks with only discard.
-    if (this->isNoOp() || (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
+    if (this->isColorNoOp() ||
+        (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
         return;
     }
     TRACE_EVENT0("skia.gpu", TRACE_FUNC);
@@ -459,7 +460,8 @@
     // can end up with GrOpsTasks that only have a discard load op and no ops. For vulkan validation
     // we need to keep that discard and not drop it. Once we have reduce op list splitting enabled
     // we shouldn't end up with GrOpsTasks with only discard.
-    if (this->isNoOp() || (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
+    if (this->isColorNoOp() ||
+        (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
         return;
     }
     TRACE_EVENT0("skia.gpu", TRACE_FUNC);
@@ -540,7 +542,8 @@
     // can end up with GrOpsTasks that only have a discard load op and no ops. For vulkan validation
     // we need to keep that discard and not drop it. Once we have reduce op list splitting enabled
     // we shouldn't end up with GrOpsTasks with only discard.
-    if (this->isNoOp() || (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
+    if (this->isColorNoOp() ||
+        (fClippedContentBounds.isEmpty() && fColorLoadOp != GrLoadOp::kDiscard)) {
         return false;
     }
 
@@ -676,12 +679,17 @@
     fRenderPassXferBarriers = GrXferBarrierFlags::kNone;
 }
 
+bool GrOpsTask::canMerge(const GrOpsTask* opsTask) const {
+    return this->target(0) == opsTask->target(0) &&
+           fArenas == opsTask->fArenas &&
+           !opsTask->fCannotMergeBackward;
+}
+
 int GrOpsTask::mergeFrom(SkSpan<const sk_sp<GrRenderTask>> tasks) {
     int mergedCount = 0;
     for (const sk_sp<GrRenderTask>& task : tasks) {
         auto opsTask = task->asOpsTask();
-        if (!opsTask || opsTask->target(0) != this->target(0)
-                     || this->fArenas != opsTask->fArenas) {
+        if (!opsTask || !this->canMerge(opsTask)) {
             break;
         }
         SkASSERT(fTargetSwizzle == opsTask->fTargetSwizzle);
@@ -863,7 +871,7 @@
     this->deleteOps();
     fDeferredProxies.reset();
     fColorLoadOp = GrLoadOp::kLoad;
-    SkASSERT(this->isNoOp());
+    SkASSERT(this->isColorNoOp());
 }
 
 bool GrOpsTask::onIsUsed(GrSurfaceProxy* proxyToCheck) const {
@@ -890,7 +898,7 @@
 
 void GrOpsTask::gatherProxyIntervals(GrResourceAllocator* alloc) const {
     SkASSERT(this->isClosed());
-    if (this->isNoOp()) {
+    if (this->isColorNoOp()) {
         return;
     }
 
@@ -1043,7 +1051,7 @@
 GrRenderTask::ExpectedOutcome GrOpsTask::onMakeClosed(GrRecordingContext* rContext,
                                                       SkIRect* targetUpdateBounds) {
     this->forwardCombine(*rContext->priv().caps());
-    if (!this->isNoOp()) {
+    if (!this->isColorNoOp()) {
         GrSurfaceProxy* proxy = this->target(0);
         // Use the entire backing store bounds since the GPU doesn't clip automatically to the
         // logical dimensions.