Pass alpha type to GrSurfaceContext::read/writePixels and remove flags.

We deduce whether to premul or unpremul based on the the input/output
alpha types. This means we also now support unpremuling on write and
premuling on read.

Class-ify former struct GrPixelInfo. Remove origin and instead pass a
flip bool to GrConvertPixels.

Unifies read/write methods on GrSurfaceContext via automatic conversion
of SkImageInfo to GrPixelInfo and making GrDirectContext an optional
parameter.

Bug: skia:7580

Change-Id: I42f6997852b4b902fb81264c6de68ca9537606aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/224281
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index e52c476..10fa09e 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -179,8 +179,9 @@
      *                      to top-to-bottom (skia's usual order)
      *
      * @return true if the read succeeded, false if not. The read can fail
-     *              because of a unsupported pixel config or because no render
-     *              target is currently set.
+     *              because of the surface doesn't support reading, the color type
+     *              is not allowed for the format of the surface or if the rectangle
+     *              read is not contained in the surface.
      */
     bool readPixels(GrSurface* surface, int left, int top, int width, int height,
                     GrColorType dstColorType, void* buffer, size_t rowBytes);
@@ -196,6 +197,11 @@
      * @param srcColorType  the color type of the source buffer.
      * @param texels        array of mipmap levels containing texture data
      * @param mipLevelCount number of levels in 'texels'
+     *
+     * @return true if the write succeeded, false if not. The read can fail
+     *              because of the surface doesn't support writing (e.g. read only),
+     *              the color type is not allowed for the format of the surface or
+     *              if the rectangle written is not contained in the surface.
      */
     bool writePixels(GrSurface* surface, int left, int top, int width, int height,
                      GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount);