Add function to GrDataUtils to handle color conversions.

Like SkConvertPixels but knows about all GrColorTypes, origin, and can
apply an arbitrary GrSwizzle.

Use in GrSurfaceContext read/write pixels methods.

Add support for '0' to GrSwizzle.


Change-Id: Ib9dd215fcb0ee8b33c4020893c22b4ab7ce1f40b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/220761
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrSwizzle.cpp b/src/gpu/GrSwizzle.cpp
index 21fe834..138b24f 100644
--- a/src/gpu/GrSwizzle.cpp
+++ b/src/gpu/GrSwizzle.cpp
@@ -11,11 +11,17 @@
 void GrSwizzle::apply(SkRasterPipeline* pipeline) const {
     SkASSERT(pipeline);
     switch (fKey) {
-        case GrSwizzle::RGBA().asKey():
+        case GrSwizzle("rgba").asKey():
             return;
-        case GrSwizzle::BGRA().asKey():
+        case GrSwizzle("bgra").asKey():
             pipeline->append(SkRasterPipeline::swap_rb);
             return;
+        case GrSwizzle("aaa1").asKey():
+            pipeline->append(SkRasterPipeline::alpha_to_gray);
+            return;
+        case GrSwizzle("rgb1").asKey():
+            pipeline->append(SkRasterPipeline::force_opaque);
+            return;
         default: {
             GR_STATIC_ASSERT(sizeof(uintptr_t) >= 4 * sizeof(char));
             // Rather than allocate the 4 control bytes on the heap somewhere, just jam them right