let's like, chill out about all these rules, man

There's really no reason to prevent any of these conversions;
they all have somewhat reasonable behavior:

   - converting between grey in different color spaces
     should probably work just fine
   - we'll convert color to gray using a fixed set of
     luminance coefficients, but that's better than failing
   - we'll invent {r,g,b} = {0,0,0} if we convert alpha
     to something with color
   - converting to opaque formats without thinking about
     premul/unpremul is probably fine, better than just
     not working at all
   - a missing src color space can always be assumed to be sRGB

Updates to ReadPixelsTest:
   - skip more supported test cases in test_conversion(),
     each with a TODO
   - conversions from non-opaque to opaque should now work
   - conversion from A8 to non-A8 should sometimes now
     work on GPUs, and the test needed a little bit of
     a tweak to not expect A8 to carry around color somehow.

Updates to SRGBReadWritePixelsTest:
   - writing untagged pixels shouldn't fail anymore;
     instead, it should behave like it was tagged sRGB

Change-Id: I19e78f3a6c89ef74fbcbc985d3fbd77fa984b1c2
Reviewed-on: https://skia-review.googlesource.com/147815
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index af46d7d..0bb7694 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -211,21 +211,6 @@
     return surfaceContext;
 }
 
-static void text_write_fails(Encoding contextEncoding, Encoding writeEncoding, GrContext* context,
-                             skiatest::Reporter* reporter) {
-    auto surfaceContext = make_surface_context(contextEncoding, context, reporter);
-    if (!surfaceContext) {
-        return;
-    }
-    auto writeII = SkImageInfo::Make(kW, kH, kRGBA_8888_SkColorType, kPremul_SkAlphaType,
-                                     encoding_as_color_space(writeEncoding));
-    auto data = make_data();
-    if (surfaceContext->writePixels(writeII, data.get(), 0, 0, 0)) {
-        ERRORF(reporter, "Expected %s write to %s surface context to fail.",
-               encoding_as_str(writeEncoding), encoding_as_str(contextEncoding));
-    }
-}
-
 static void test_write_read(Encoding contextEncoding, Encoding writeEncoding, Encoding readEncoding,
                             float error, CheckFn check, GrContext* context,
                             skiatest::Reporter* reporter) {
@@ -280,8 +265,9 @@
     test_write_read(Encoding::kSRGB, Encoding::kSRGB, Encoding::kLinear, error,
                     check_srgb_to_linear_conversion, context, reporter);
 
-    // Currently writing untagged data to kSRGB fails because SkImageInfoValidConversion fails.
-    text_write_fails(Encoding::kSRGB, Encoding::kUntagged, context, reporter);
+    // Untagged source data should be interpreted as sRGB.
+    test_write_read(Encoding::kSRGB, Encoding::kUntagged, Encoding::kSRGB, smallError,
+                    check_no_conversion, context, reporter);
 
     ///////////////////////////////////////////////////////////////////////////////////////////////
     // Write linear data to a sRGB context. It gets converted to sRGB on write. The reads
@@ -322,8 +308,9 @@
     test_write_read(Encoding::kLinear, Encoding::kSRGB, Encoding::kLinear, error,
                     check_srgb_to_linear_conversion, context, reporter);
 
-    // Currently writing untagged data to kLinear fails because SkImageInfoValidConversion fails.
-    text_write_fails(Encoding::kSRGB, Encoding::kUntagged, context, reporter);
+    // Untagged source data should be interpreted as sRGB.
+    test_write_read(Encoding::kLinear, Encoding::kUntagged, Encoding::kSRGB, error,
+                    check_srgb_to_linear_to_srgb_conversion, context, reporter);
 
     ///////////////////////////////////////////////////////////////////////////////////////////////
     // Write linear data to a linear context. Does no conversion.