Roll skia/third_party/skcms 5bfec77..b01dbd2 (1 commits)

https://skia.googlesource.com/skcms.git/+log/5bfec77..b01dbd2

2018-05-23 brianosman@google.com Recover the original primaries (using CHAD) when emitting gamut diagrams


The AutoRoll server is located here: https://skcms-skia-roll.skia.org

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC'd on the roll, and stop the roller if necessary.



CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel
TBR=allanmac@google.com

Change-Id: I7501f2628fa30a57f445c99ade1184eea6a8bdcc
Reviewed-on: https://skia-review.googlesource.com/129709
Commit-Queue: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Reviewed-by: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
diff --git a/third_party/skcms/skcms.gni b/third_party/skcms/skcms.gni
index 8577de3..f2004ad 100644
--- a/third_party/skcms/skcms.gni
+++ b/third_party/skcms/skcms.gni
@@ -7,6 +7,7 @@
   "src/Curve.c",
   "src/Curve.h",
   "src/ICCProfile.c",
+  "src/ICCProfile.h",
   "src/LinearAlgebra.c",
   "src/LinearAlgebra.h",
   "src/Macros.h",
diff --git a/third_party/skcms/src/ICCProfile.c b/third_party/skcms/src/ICCProfile.c
index ca28824..1f25d16 100644
--- a/third_party/skcms/src/ICCProfile.c
+++ b/third_party/skcms/src/ICCProfile.c
@@ -6,6 +6,7 @@
  */
 
 #include "../skcms.h"
+#include "ICCProfile.h"
 #include "LinearAlgebra.h"
 #include "Macros.h"
 #include "PortableMath.h"
@@ -35,11 +36,14 @@
     skcms_Signature_A2B1 = 0x41324231,
     skcms_Signature_mAB  = 0x6D414220,
 
+    skcms_Signature_CHAD = 0x63686164,
+
     // Type signatures
     skcms_Signature_curv = 0x63757276,
     skcms_Signature_mft1 = 0x6D667431,
     skcms_Signature_mft2 = 0x6D667432,
     skcms_Signature_para = 0x70617261,
+    skcms_Signature_sf32 = 0x73663332,
     // XYZ is also a PCS signature, so it's defined in skcms.h
     // skcms_Signature_XYZ = 0x58595A20,
 };
@@ -108,6 +112,33 @@
     return (const tag_Layout*)(profile->buffer + SAFE_SIZEOF(header_Layout));
 }
 
+// s15Fixed16ArrayType is technically variable sized, holding N values. However, the only valid
+// use of the type is for the CHAD tag that stores exactly nine values.
+typedef struct {
+    uint8_t type     [ 4];
+    uint8_t reserved [ 4];
+    uint8_t values   [36];
+} sf32_Layout;
+
+bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m) {
+    skcms_ICCTag tag;
+    if (!skcms_GetTagBySignature(profile, skcms_Signature_CHAD, &tag)) {
+        return false;
+    }
+
+    if (tag.type != skcms_Signature_sf32 || tag.size < SAFE_SIZEOF(sf32_Layout)) {
+        return false;
+    }
+
+    const sf32_Layout* sf32Tag = (const sf32_Layout*)tag.buf;
+    const uint8_t* values = sf32Tag->values;
+    for (int r = 0; r < 3; ++r)
+    for (int c = 0; c < 3; ++c, values += 4) {
+        m->vals[r][c] = read_big_fixed(values);
+    }
+    return true;
+}
+
 // XYZType is technically variable sized, holding N XYZ triples. However, the only valid uses of
 // the type are for tags/data that store exactly one triple.
 typedef struct {
diff --git a/third_party/skcms/src/ICCProfile.h b/third_party/skcms/src/ICCProfile.h
new file mode 100644
index 0000000..39967a1
--- /dev/null
+++ b/third_party/skcms/src/ICCProfile.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+
+bool skcms_GetCHAD(const skcms_ICCProfile* profile, skcms_Matrix3x3* m);
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index cfc5d96..b56792e 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-5bfec7723e0fefd2a257e8be4710282cd033eeb2
\ No newline at end of file
+b01dbd249b2e6cfc44e4e9831223c89b6009434f
\ No newline at end of file