Lift GrRenderTarget::transferFrom to GrSurfaceContext.

Added virtual transferFrom to GrOpList and implemented in both
subclasses.

Bug: skia:9269
Change-Id: Ic930e46b172879e592897512c81a0cfe79f20d19
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230129
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 1a0754e..735c6dd 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -44,6 +44,8 @@
     int width() const { return this->asSurfaceProxy()->width(); }
     int height() const { return this->asSurfaceProxy()->height(); }
 
+    const GrCaps* caps() const;
+
     /**
      * Reads a rectangle of pixels from the render target context.
      * @param dstInfo       image info for the destination
@@ -120,6 +122,20 @@
                                          SkSurface::RescaleGamma rescaleGamma,
                                          SkFilterQuality rescaleQuality);
 
+    // Inserts a transfer, part of the implementation of asyncReadPixels and
+    // asyncRescaleAndReadPixelsYUV420().
+    struct PixelTransferResult {
+        using ConversionFn = void(void* dst, const void* mappedBuffer);
+        // If null then the transfer could not be performed. Otherwise this buffer will contain
+        // the pixel data when the transfer is complete.
+        sk_sp<GrGpuBuffer> fTransferBuffer;
+        // If this is null then the transfer buffer will contain the data in the requested
+        // color type. Otherwise, when the transfer is done this must be called to convert
+        // from the transfer buffer's color type to the requested color type.
+        std::function<ConversionFn> fPixelConverter;
+    };
+    PixelTransferResult transferPixels(GrColorType colorType, const SkIRect& rect);
+
 private:
     friend class GrSurfaceProxy; // for copy