Enable legacy premuls in SkColorSpaceXform

***Will allow for simplified Android framework code, they typically
   want a color correct transform followed by a gamma encoded premul.
***Chrome does the same, so this will make it easier to replace their
   codecs.
***Will decrease code size.  Both types of premuls are moved off the
   fast path here - one is essentially unused in production and the
   other is not "encouraged".
***Will actually make the common case faster: sRGB->sRGB means no
   color xform, just premul in SkSwizzler.

BUG=skia:

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD

Change-Id: Ia4ec1d273b6f137151f951d37c0ebf975f6b9a3e
Reviewed-on: https://skia-review.googlesource.com/8848
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 110cbdc..026120f 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -302,16 +302,23 @@
 
 static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
                                      bool needsPremul) {
+    // We never perform a color xform in legacy mode.
+    if (!dstInfo.colorSpace()) {
+        return false;
+    }
+
     // F16 is by definition a linear space, so we always must perform a color xform.
     bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType();
 
     // Need a color xform when dst space does not match the src.
-    bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.colorSpace());
+    bool srcDstNotEqual =
+            !SkColorSpace_Base::EqualsIgnoreFlags(srcInfo.colorSpace(), dstInfo.colorSpace());
 
-    // We never perform a color xform in legacy mode.
-    bool isLegacy = nullptr == dstInfo.colorSpace();
+    // We provide the option for both legacy premuls and color correct premuls.
+    bool needsColorCorrectPremul =
+            needsPremul && !as_CSB(dstInfo.colorSpace())->nonLinearBlending();
 
-    return !isLegacy && (needsPremul || isF16 || srcDstNotEqual);
+    return needsColorCorrectPremul || isF16 || srcDstNotEqual;
 }
 
 static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) {