aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/skcms
diff options
context:
space:
mode:
authorGravatar skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>2018-05-02 18:59:47 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-02 19:27:48 +0000
commit2af0904bf411f3050d6db87141bfc206897827fb (patch)
treee76b616b5fd8bf3f52d6bb05b3b5723579e5bb8c /third_party/skcms
parent38a08436886e82de4eb9ebdbcb2bbd5ea7b05c6d (diff)
Roll skia/third_party/skcms 513d372..baef14c (1 commits)
https://skia.googlesource.com/skcms.git/+log/513d372..baef14c 2018-05-02 brianosman@google.com Add MakeUsableAsDestination to replace EnsureUsableAsDestination 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=brianosman@google.com Change-Id: I809f6e42977bea720c7dc7208c3fb9545cd66317 Reviewed-on: https://skia-review.googlesource.com/125382 Reviewed-by: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com> Commit-Queue: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Diffstat (limited to 'third_party/skcms')
-rw-r--r--third_party/skcms/skcms.h11
-rw-r--r--third_party/skcms/src/Transform.c64
-rwxr-xr-xthird_party/skcms/version.sha12
3 files changed, 76 insertions, 1 deletions
diff --git a/third_party/skcms/skcms.h b/third_party/skcms/skcms.h
index 2053fe6828..36ac4a0fbc 100644
--- a/third_party/skcms/skcms.h
+++ b/third_party/skcms/skcms.h
@@ -221,6 +221,17 @@ SKCMS_API void skcms_EnsureUsableAsDestination(skcms_ICCProfile* profile,
SKCMS_API void skcms_EnsureUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile,
const skcms_ICCProfile* fallback);
+// If profile can be used as a destination in skcms_Transform, return true. Otherwise, attempt to
+// rewrite it with approximations where reasonable. If successful, return true. If no reasonable
+// approximation exists, leave the profile unchanged and return false.
+SKCMS_API bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile);
+
+// If profile can be used as a destination with a single parametric transfer function (ie for
+// rasterization), return true. Otherwise, attempt to rewrite it with approximations where
+// reasonable. If successful, return true. If not reasonable approximation exists, leave the
+// profile unchanged and return false.
+SKCMS_API bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile);
+
#ifdef __cplusplus
}
#endif
diff --git a/third_party/skcms/src/Transform.c b/third_party/skcms/src/Transform.c
index 7aaed63cf6..ae26e71804 100644
--- a/third_party/skcms/src/Transform.c
+++ b/third_party/skcms/src/Transform.c
@@ -697,3 +697,67 @@ void skcms_EnsureUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile,
*profile = result;
assert_usable_as_destination(profile);
}
+
+bool skcms_MakeUsableAsDestination(skcms_ICCProfile* profile) {
+ skcms_Matrix3x3 fromXYZD50;
+ if (!profile->has_trc || !profile->has_toXYZD50
+ || !skcms_Matrix3x3_invert(&profile->toXYZD50, &fromXYZD50)) {
+ return false;
+ }
+
+ skcms_TransferFunction tf[3];
+ for (int i = 0; i < 3; i++) {
+ skcms_TransferFunction inv;
+ if (profile->trc[i].table_entries == 0
+ && skcms_TransferFunction_invert(&profile->trc[i].parametric, &inv)) {
+ tf[i] = profile->trc[i].parametric;
+ continue;
+ }
+
+ float max_error;
+ // Parametric curves from skcms_ApproximateCurve() are guaranteed to be invertible.
+ if (!skcms_ApproximateCurve(&profile->trc[i], &tf[i], &max_error)) {
+ return false;
+ }
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ profile->trc[i].table_entries = 0;
+ profile->trc[i].parametric = tf[i];
+ }
+
+ assert_usable_as_destination(profile);
+ return true;
+}
+
+bool skcms_MakeUsableAsDestinationWithSingleCurve(skcms_ICCProfile* profile) {
+ // Operate on a copy of profile, so we can choose the best TF for the original curves
+ skcms_ICCProfile result = *profile;
+ if (!skcms_MakeUsableAsDestination(&result)) {
+ return false;
+ }
+
+ int best_tf = 0;
+ float min_max_error = INFINITY_;
+ for (int i = 0; i < 3; i++) {
+ skcms_TransferFunction inv;
+ skcms_TransferFunction_invert(&result.trc[i].parametric, &inv);
+
+ float err = 0;
+ for (int j = 0; j < 3; ++j) {
+ err = fmaxf_(err, max_roundtrip_error(&inv, &profile->trc[j]));
+ }
+ if (min_max_error > err) {
+ min_max_error = err;
+ best_tf = i;
+ }
+ }
+
+ for (int i = 0; i < 3; i++) {
+ result.trc[i].parametric = result.trc[best_tf].parametric;
+ }
+
+ *profile = result;
+ assert_usable_as_destination(profile);
+ return true;
+}
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index 1284041000..d75996c241 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-513d372c015ed44b5649308d45728708cdf956ee \ No newline at end of file
+baef14ce357a67a20251276475241f574cc5e2ee \ No newline at end of file