fix two 1-bit mismatches in sRGB transfer functions

The Skia and skcms 'a' and 'b' terms disagree in the low bit.
'd' was exactly the same, but I've rewritten Skia's to match anyway.

Guarded by SK_LEGACY_SRGB_TRANSFER_FUNCTION.  *grumble*

Bug: skia:8278

Change-Id: Ie799f155cbe9c6a1fbe9043c827b8f79d04e1d96
Reviewed-on: https://skia-review.googlesource.com/150130
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkColorSpacePriv.h b/src/core/SkColorSpacePriv.h
index 898a61e..02bc9fe 100644
--- a/src/core/SkColorSpacePriv.h
+++ b/src/core/SkColorSpacePriv.h
@@ -57,8 +57,13 @@
     0.032925f,  0.153615f,  0.638669f,
 };
 
+// Like gSRGB_toXYZD50, keeping this bitwise exactly the same as skcms makes things fastest.
 static constexpr SkColorSpaceTransferFn gSRGB_TransferFn =
+#ifdef SK_LEGACY_SRGB_TRANSFER_FUNCTION
         { 2.4f, 1.0f / 1.055f, 0.055f / 1.055f, 1.0f / 12.92f, 0.04045f, 0.0f, 0.0f };
+#else
+        { 2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0.0f, 0.0f };
+#endif
 
 static constexpr SkColorSpaceTransferFn g2Dot2_TransferFn =
         { 2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp
index 2e2687c..a376fc8 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -424,3 +424,10 @@
     sk_sp<SkColorSpace> srgb = SkColorSpace::Make(*skcms_sRGB_profile());
     REPORTER_ASSERT(r, srgb->isSRGB());
 }
+
+DEF_TEST(ColorSpace_skcms_sRGB_exact, r) {
+    skcms_ICCProfile profile;
+    sk_srgb_singleton()->toProfile(&profile);
+
+    REPORTER_ASSERT(r, 0 == memcmp(&profile, skcms_sRGB_profile(), sizeof(skcms_ICCProfile)));
+}