Revert "Switch SkCodec to use skcms" and follow on change

This reverts commit 81886e8f9461c7049751c6a2c194a1df632dd362 and
f8ae5ce20cf6df2dab4149fb2838d9d8dc6bd1af
("Fix CMYK handling in JPEG codec")

This fixes the Android build, which was failing a CTS test with this
change.

Bug: skia:6839
Bug: skia:8052

TBR=djsollen@google.com
As with the original, no API change

Change-Id: Ic744a610e9f431707f871de44f9f64040bc60d14
Reviewed-on: https://skia-review.googlesource.com/148810
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index 30a3d7b..9eea78c 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -504,6 +504,10 @@
         }
     }
 
+    const SkEncodedInfo& getEncodedInfo() const {
+        return fEncodedInfo;
+    }
+
     int width() const {
         return fWidth;
     }
@@ -598,6 +602,8 @@
 
     SkDngImage(SkRawStream* stream)
         : fStream(stream)
+        , fEncodedInfo(SkEncodedInfo::Make(SkEncodedInfo::kRGB_Color,
+                                           SkEncodedInfo::kOpaque_Alpha, 8))
     {}
 
     dng_memory_allocator fAllocator;
@@ -609,21 +615,11 @@
 
     int fWidth;
     int fHeight;
+    SkEncodedInfo fEncodedInfo;
     bool fIsScalable;
     bool fIsXtransImage;
 };
 
-static constexpr skcms_Matrix3x3 gAdobe_RGB_to_XYZD50 = {{
-    // ICC fixed-point (16.16) repesentation of:
-    // 0.60974, 0.20528, 0.14919,
-    // 0.31111, 0.62567, 0.06322,
-    // 0.01947, 0.06087, 0.74457,
-    { SkFixedToFloat(0x9c18), SkFixedToFloat(0x348d), SkFixedToFloat(0x2631) }, // Rx, Gx, Bx
-    { SkFixedToFloat(0x4fa5), SkFixedToFloat(0xa02c), SkFixedToFloat(0x102f) }, // Ry, Gy, By
-    { SkFixedToFloat(0x04fc), SkFixedToFloat(0x0f95), SkFixedToFloat(0xbe9c) }, // Rz, Gz, Bz
-}};
-
-
 /*
  * Tries to handle the image with PIEX. If PIEX returns kOk and finds the preview image, create a
  * SkJpegCodec. If PIEX returns kFail, then the file is invalid, return nullptr. In other cases,
@@ -648,21 +644,15 @@
             return nullptr;
         }
 
-        std::unique_ptr<SkEncodedInfo::ICCProfile> profile;
+        sk_sp<SkColorSpace> colorSpace;
         switch (imageData.color_space) {
             case ::piex::PreviewImageData::kSrgb:
-                profile = SkEncodedInfo::ICCProfile::MakeSRGB();
+                colorSpace = SkColorSpace::MakeSRGB();
                 break;
-            case ::piex::PreviewImageData::kAdobeRgb: {
-                constexpr skcms_TransferFunction twoDotTwo =
-                        { 2.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
-                skcms_ICCProfile skcmsProfile;
-                skcms_Init(&skcmsProfile);
-                skcms_SetTransferFunction(&skcmsProfile, &twoDotTwo);
-                skcms_SetXYZD50(&skcmsProfile, &gAdobe_RGB_to_XYZD50);
-                profile = SkEncodedInfo::ICCProfile::Make(skcmsProfile);
+            case ::piex::PreviewImageData::kAdobeRgb:
+                colorSpace = SkColorSpace::MakeRGB(g2Dot2_TransferFn,
+                                                   SkColorSpace::kAdobeRGB_Gamut);
                 break;
-            }
         }
 
         //  Theoretically PIEX can return JPEG compressed image or uncompressed RGB image. We only
@@ -680,7 +670,7 @@
                 return nullptr;
             }
             return SkJpegCodec::MakeFromStream(std::move(memoryStream), result,
-                                               std::move(profile));
+                                               std::move(colorSpace));
         }
     }
 
@@ -756,7 +746,7 @@
         if (this->colorXform()) {
             swizzler->swizzle(xformBuffer.get(), &srcRow[0]);
 
-            this->applyColorXform(dstRow, xformBuffer.get(), dstInfo.width());
+            this->applyColorXform(dstRow, xformBuffer.get(), dstInfo.width(), kOpaque_SkAlphaType);
         } else {
             swizzler->swizzle(dstRow, &srcRow[0]);
         }
@@ -806,8 +796,7 @@
 SkRawCodec::~SkRawCodec() {}
 
 SkRawCodec::SkRawCodec(SkDngImage* dngImage)
-    : INHERITED(SkEncodedInfo::MakeSRGB(dngImage->width(), dngImage->height(),
-                                        SkEncodedInfo::kRGB_Color,
-                                        SkEncodedInfo::kOpaque_Alpha, 8),
-                skcms_PixelFormat_RGBA_8888, nullptr)
+    : INHERITED(dngImage->width(), dngImage->height(), dngImage->getEncodedInfo(),
+                SkColorSpaceXform::kRGBA_8888_ColorFormat, nullptr,
+                SkColorSpace::MakeSRGB())
     , fDngImage(dngImage) {}