Experimental: Add R_16 and RG_1616 to Ganesh (take 2)

This is to support the P016 and P010 YUV formats. Initially, only Vulkan and GL support these formats.

Change-Id: I4e896f1d3fb32207227a755517ae5a00a58e6045
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219403
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 2c67f70..8f67be7 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -589,3 +589,46 @@
     return 4 * width * height;
 }
 
+size_t GrGLBytesPerFormat(GrGLenum glFormat) {
+    switch (glFormat) {
+        case GR_GL_LUMINANCE8:
+        case GR_GL_ALPHA8:
+        case GR_GL_R8:
+            return 1;
+
+        case GR_GL_RGB565:
+        case GR_GL_RGBA4:
+        case GR_GL_RG8:
+        case GR_GL_R16F:
+            return 2;
+
+        case GR_GL_RGB8:
+            return 3;
+
+        case GR_GL_RGBA8:
+        case GR_GL_SRGB8_ALPHA8:
+        case GR_GL_BGRA8:
+        case GR_GL_RGB10_A2:
+            return 4;
+
+        case GR_GL_RGBA16F:
+        case GR_GL_RG32F:
+            return 8;
+
+        case GR_GL_RGBA32F:
+            return 16;
+
+        case GR_GL_COMPRESSED_RGB8_ETC2: // fall through
+        case GR_GL_COMPRESSED_ETC1_RGB8:
+            return 0;
+
+        // Experimental (for P016 and P010)
+        case GR_GL_R16:
+            return 2;
+        case GR_GL_RG16:
+            return 4;
+    }
+
+    SK_ABORT("Invalid GL format");
+    return 0;
+}