add a test that sRGB stages round trip

Change-Id: Ide8303f6fc162f3703f7db298fe210d47225a580
Reviewed-on: https://skia-review.googlesource.com/16988
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/tests/SRGBTest.cpp b/tests/SRGBTest.cpp
index 77c1fb7..4d0084a 100644
--- a/tests/SRGBTest.cpp
+++ b/tests/SRGBTest.cpp
@@ -5,6 +5,7 @@
  * found in the LICENSE file.
  */
 
+#include "SkRasterPipeline.h"
 #include "SkSRGB.h"
 #include "SkTypes.h"
 #include "Test.h"
@@ -37,3 +38,26 @@
         f = pun.flt;
     }
 }
+
+DEF_TEST(sk_pipeline_srgb_roundtrip, r) {
+    uint32_t reds[256];
+    for (int i = 0; i < 256; i++) {
+        reds[i] = i;
+    }
+
+    auto ptr = (void*)reds;
+
+    SkRasterPipeline p;
+    p.append(SkRasterPipeline::load_8888,  &ptr);
+    p.append_from_srgb(kUnpremul_SkAlphaType);
+    p.append(SkRasterPipeline::to_srgb);
+    p.append(SkRasterPipeline::store_8888, &ptr);
+
+    p.run(0,256);
+
+    for (int i = 0; i < 256; i++) {
+        if (reds[i] != (uint32_t)i) {
+            ERRORF(r, "%d doesn't round trip, %d", i, reds[i]);
+        }
+    }
+}