Revert "Revert "New read pixels implementation that is simpler but does all conversions on CPU.""

This reverts commit be5947c2f38a79b7c709accfb1047d8fd06a0227.

Bug: skia:
Change-Id: I06dc15b31042d7827511d0ac2a7f4262c3f09622
Reviewed-on: https://skia-review.googlesource.com/115079
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index 18ed738..569490c 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -139,8 +139,8 @@
             uint32_t read = readData[j * w + i];
 
             if (!checker(orig, read, error)) {
-                ERRORF(reporter, "Expected 0x%08x, read back as 0x%08x in %s at %d, %d).",
-                       orig, read, subtestName, i, j);
+                ERRORF(reporter, "Original 0x%08x, read back as 0x%08x in %s at %d, %d).", orig,
+                       read, subtestName, i, j);
                 return;
             }
         }
@@ -272,13 +272,20 @@
     ///////////////////////////////////////////////////////////////////////////////////////////////
     // Write sRGB data to a sRGB context - no conversion on the write.
 
-    // back to sRGB no conversion
+    // back to sRGB - no conversion.
     test_write_read(Encoding::kSRGB, Encoding::kSRGB, Encoding::kSRGB, smallError,
                     check_no_conversion, context, reporter);
+#ifdef SK_LEGACY_GPU_PIXEL_OPS
     // Untagged read from sRGB is treated as a conversion back to linear. TODO: Fail or don't
     // convert?
     test_write_read(Encoding::kSRGB, Encoding::kSRGB, Encoding::kUntagged, error,
                     check_srgb_to_linear_conversion, context, reporter);
+#else
+    // Reading back to untagged should be a pass through with no conversion.
+    test_write_read(Encoding::kSRGB, Encoding::kSRGB, Encoding::kUntagged, error,
+                    check_no_conversion, context, reporter);
+#endif
+
     // Converts back to linear
     test_write_read(Encoding::kSRGB, Encoding::kSRGB, Encoding::kLinear, error,
                     check_srgb_to_linear_conversion, context, reporter);
@@ -307,9 +314,15 @@
     // are all the same as the above cases where the original data was untagged.
     test_write_read(Encoding::kSRGB, Encoding::kLinear, Encoding::kSRGB, error,
                     check_linear_to_srgb_conversion, context, reporter);
+#ifdef SK_LEGACY_GPU_PIXEL_OPS
     // TODO: Fail or don't convert?
     test_write_read(Encoding::kSRGB, Encoding::kLinear, Encoding::kUntagged, error,
                     check_linear_to_srgb_to_linear_conversion, context, reporter);
+#else
+    // When the dst buffer is untagged there should be no conversion on the read.
+    test_write_read(Encoding::kSRGB, Encoding::kLinear, Encoding::kUntagged, error,
+                    check_linear_to_srgb_conversion, context, reporter);
+#endif
     test_write_read(Encoding::kSRGB, Encoding::kLinear, Encoding::kLinear, error,
                     check_linear_to_srgb_to_linear_conversion, context, reporter);
 
@@ -317,13 +330,13 @@
     // Write data to an untagged context. The write does no conversion no matter what encoding the
     // src data has.
     for (auto writeEncoding : {Encoding::kSRGB, Encoding::kUntagged, Encoding::kLinear}) {
-        // The read from untagged to sRGB also does no conversion. TODO: Should it just fail?
+        // The read from untagged to sRGB also does no conversion.
         test_write_read(Encoding::kUntagged, writeEncoding, Encoding::kSRGB, error,
                         check_no_conversion, context, reporter);
         // Reading untagged back as untagged should do no conversion.
         test_write_read(Encoding::kUntagged, writeEncoding, Encoding::kUntagged, error,
                         check_no_conversion, context, reporter);
-        // Reading untagged back as linear does no conversion. TODO: Should it just fail?
+        // Reading untagged back as linear does no conversion.
         test_write_read(Encoding::kUntagged, writeEncoding, Encoding::kLinear, error,
                         check_no_conversion, context, reporter);
     }
@@ -334,18 +347,18 @@
     // converts back to sRGB on read.
     test_write_read(Encoding::kLinear, Encoding::kSRGB, Encoding::kSRGB, error,
                     check_srgb_to_linear_to_srgb_conversion, context, reporter);
-    // Reading untagged data from linear currently does no conversion. TODO: Should it fail?
+    // Reading untagged data from linear currently does no conversion.
     test_write_read(Encoding::kLinear, Encoding::kSRGB, Encoding::kUntagged, error,
                     check_srgb_to_linear_conversion, context, reporter);
     // Stays linear when read.
     test_write_read(Encoding::kLinear, Encoding::kSRGB, Encoding::kLinear, error,
                     check_srgb_to_linear_conversion, context, reporter);
 
+#ifdef SK_LEGACY_GPU_PIXEL_OPS
     ///////////////////////////////////////////////////////////////////////////////////////////////
     // Write untagged data to a linear context. Currently does no conversion. TODO: Should this
     // fail?
 
-#ifdef SK_LEGACY_GPU_PIXEL_OPS
     // Reading to sRGB does a conversion.
     test_write_read(Encoding::kLinear, Encoding::kUntagged, Encoding::kSRGB, error,
                     check_linear_to_srgb_conversion, context, reporter);
@@ -366,7 +379,7 @@
     // Reading to sRGB does a conversion.
     test_write_read(Encoding::kLinear, Encoding::kLinear, Encoding::kSRGB, error,
                     check_linear_to_srgb_conversion, context, reporter);
-    // Reading to untagged does no conversion. TODO: Should it fail?
+    // Reading to untagged does no conversion.
     test_write_read(Encoding::kLinear, Encoding::kLinear, Encoding::kUntagged, error,
                     check_no_conversion, context, reporter);
     // Stays linear when read.