remove linear-blended sRGB dst support in software

This is the mechanism we'd want to add back if we add an sRGBA
SkColorType.  This will break the DM "srgb" config hard.

Landing this first should help flush out GMs that are incidentally using
sRGB offscreens.

Updated tests/AnimatedImageTest.cpp to avoid linear sRGB 8888 surfaces.

CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Change-Id: Idb5035cf4d60fcd1dc24c303d43a406fc4a603fa
Reviewed-on: https://skia-review.googlesource.com/132261
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 40921f1..1dd346f 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -41,7 +41,7 @@
     M(unpremul) M(premul) M(premul_dst)                            \
     M(force_opaque) M(force_opaque_dst)                            \
     M(set_rgb) M(swap_rb)                                          \
-    M(from_srgb) M(from_srgb_dst) M(to_srgb)                       \
+    M(from_srgb) M(to_srgb)                                        \
     M(black_color) M(white_color) M(uniform_color)                 \
     M(seed_shader) M(dither)                                       \
     M(load_a8)   M(load_a8_dst)   M(store_a8)   M(gather_a8)       \
diff --git a/src/core/SkRasterPipelineBlitter.cpp b/src/core/SkRasterPipelineBlitter.cpp
index ae76617..aa6b6e9 100644
--- a/src/core/SkRasterPipelineBlitter.cpp
+++ b/src/core/SkRasterPipelineBlitter.cpp
@@ -248,9 +248,6 @@
         case kRGB_101010x_SkColorType:  p->append(SkRasterPipeline::load_1010102_dst, ctx);
                                         p->append(SkRasterPipeline::force_opaque_dst     ); break;
     }
-    if (fDst.info().gammaCloseToSRGB()) {
-        p->append(SkRasterPipeline::from_srgb_dst);
-    }
     if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
         p->append(SkRasterPipeline::premul_dst);
     }
@@ -260,12 +257,7 @@
     if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
         p->append(SkRasterPipeline::unpremul);
     }
-    if (fDst.info().gammaCloseToSRGB()) {
-        p->append(SkRasterPipeline::to_srgb);
-    }
     if (fDitherRate > 0.0f) {
-        // We dither after any sRGB transfer function to make sure our 1/255.0f is sensible
-        // over the whole range.  If we did it before, 1/255.0f is too big a rate near zero.
         p->append(SkRasterPipeline::dither, &fDitherRate);
     }
 
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index d6e0d4b..f7c757d 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -1314,24 +1314,18 @@
 STAGE(force_opaque    , Ctx::None) {  a = 1; }
 STAGE(force_opaque_dst, Ctx::None) { da = 1; }
 
-SI F from_srgb_(F s) {
-    auto lo = s * (1/12.92f);
-    auto hi = mad(s*s, mad(s, 0.3000f, 0.6975f), 0.0025f);
-    return if_then_else(s < 0.055f, lo, hi);
-}
-
 STAGE(from_srgb, Ctx::None) {
-    r = from_srgb_(r);
-    g = from_srgb_(g);
-    b = from_srgb_(b);
-}
-STAGE(from_srgb_dst, Ctx::None) {
-    dr = from_srgb_(dr);
-    dg = from_srgb_(dg);
-    db = from_srgb_(db);
+    auto fn = [](F s) {
+        auto lo = s * (1/12.92f);
+        auto hi = mad(s*s, mad(s, 0.3000f, 0.6975f), 0.0025f);
+        return if_then_else(s < 0.055f, lo, hi);
+    };
+    r = fn(r);
+    g = fn(g);
+    b = fn(b);
 }
 STAGE(to_srgb, Ctx::None) {
-    auto fn = [&](F l) {
+    auto fn = [](F l) {
         // We tweak c and d for each instruction set to make sure fn(1) is exactly 1.
     #if defined(JUMPER_IS_AVX512)
         const float c = 1.130026340485f,
diff --git a/tests/AnimatedImageTest.cpp b/tests/AnimatedImageTest.cpp
index 13ea808..6532b58 100644
--- a/tests/AnimatedImageTest.cpp
+++ b/tests/AnimatedImageTest.cpp
@@ -97,6 +97,17 @@
     return true;
 }
 
+// Temporary hack to avoid linear sRGB 8888 surfaces.
+static SkImageInfo temporarily_sanitize(SkImageInfo info) {
+    if (info.colorType() == kRGBA_8888_SkColorType ||
+        info.colorType() == kBGRA_8888_SkColorType) {
+        if (info.colorSpace() && info.colorSpace()->isSRGB()) {
+            info = info.makeColorSpace(nullptr);
+        }
+    }
+    return info;
+}
+
 DEF_TEST(AnimatedImage_copyOnWrite, r) {
     if (GetResourcePath().isEmpty()) {
         return;
@@ -137,7 +148,7 @@
         std::vector<sk_sp<SkPicture>> pictures(frameCount);
         for (int i = 0; i < frameCount; i++) {
             SkBitmap& bm = expected[i];
-            bm.allocPixels(imageInfo);
+            bm.allocPixels(temporarily_sanitize(imageInfo));
             bm.eraseColor(SK_ColorTRANSPARENT);
             SkCanvas canvas(bm);
 
@@ -157,7 +168,7 @@
 
         for (int i = 0; i < frameCount; i++) {
             SkBitmap test;
-            test.allocPixels(imageInfo);
+            test.allocPixels(temporarily_sanitize(imageInfo));
             test.eraseColor(SK_ColorTRANSPARENT);
             SkCanvas canvas(test);
 
@@ -237,7 +248,7 @@
         auto testDraw = [r, &frames, &imageInfo, file](const sk_sp<SkAnimatedImage>& animatedImage,
                                                        int expectedFrame) {
             SkBitmap test;
-            test.allocPixels(imageInfo);
+            test.allocPixels(temporarily_sanitize(imageInfo));
             test.eraseColor(0);
             SkCanvas c(test);
             animatedImage->draw(&c);