A few fixes to recent gpu Copy Op changes.

Make sure we make the dst be visited so that the allocator knows
it can reuse the dst copy texture.

Don't flip the copy rect for origin until after setting the bounds on
the copy op

Bug: chromium:972587
Change-Id: Ibb37e41b45e773e5df2c79c2e0e3ec79a871632f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220219
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ops/GrCopySurfaceOp.cpp b/src/gpu/ops/GrCopySurfaceOp.cpp
index 0dfcc29..aef1828 100644
--- a/src/gpu/ops/GrCopySurfaceOp.cpp
+++ b/src/gpu/ops/GrCopySurfaceOp.cpp
@@ -31,28 +31,9 @@
         return nullptr;
     }
 
-    SkASSERT(dstProxy->origin() == srcProxy->origin());
-    SkIRect adjSrcRect;
-    adjSrcRect.fLeft = clippedSrcRect.fLeft;
-    adjSrcRect.fRight = clippedSrcRect.fRight;
-    SkIPoint adjDstPoint;
-    adjDstPoint.fX = clippedDstPoint.fX;
-
-    // If it is bottom left origin we must flip the rects.
-    SkASSERT(dstProxy->origin() == srcProxy->origin());
-    if (kBottomLeft_GrSurfaceOrigin == srcProxy->origin()) {
-        adjSrcRect.fTop = srcProxy->height() - clippedSrcRect.fBottom;
-        adjSrcRect.fBottom = srcProxy->height() - clippedSrcRect.fTop;
-        adjDstPoint.fY = dstProxy->height() - clippedDstPoint.fY - clippedSrcRect.height();
-    } else {
-        adjSrcRect.fTop = clippedSrcRect.fTop;
-        adjSrcRect.fBottom = clippedSrcRect.fBottom;
-        adjDstPoint.fY = clippedDstPoint.fY;
-    }
-
     GrOpMemoryPool* pool = context->priv().opMemoryPool();
 
-    return pool->allocate<GrCopySurfaceOp>(srcProxy, dstProxy, adjSrcRect, adjDstPoint);
+    return pool->allocate<GrCopySurfaceOp>(srcProxy, dstProxy, clippedSrcRect, clippedDstPoint);
 }
 
 void GrCopySurfaceOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
diff --git a/src/gpu/ops/GrCopySurfaceOp.h b/src/gpu/ops/GrCopySurfaceOp.h
index 0516a2f..69652bd 100644
--- a/src/gpu/ops/GrCopySurfaceOp.h
+++ b/src/gpu/ops/GrCopySurfaceOp.h
@@ -27,6 +27,7 @@
 
     void visitProxies(const VisitProxyFunc& func) const override {
         func(fSrc.get(), GrMipMapped::kNo);
+        func(fDst.get(), GrMipMapped::kNo);
     }
 
 #ifdef SK_DEBUG
@@ -56,6 +57,15 @@
                 SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
                                  SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
         this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
+
+        SkASSERT(dst->origin() == src->origin());
+        if (kBottomLeft_GrSurfaceOrigin == src->origin()) {
+            int rectHeight = fSrcRect.height();
+            fSrcRect.fTop = src->height() - fSrcRect.fBottom;
+            fSrcRect.fBottom = fSrcRect.fTop + rectHeight;
+            fDstPoint.fY = dst->height() - fDstPoint.fY - rectHeight;
+        }
+
     }
 
     void onPrepare(GrOpFlushState*) override {}