Roll skia/third_party/skcms aee343c..cc1799c (1 commits)

https://skia.googlesource.com/skcms.git/+log/aee343c..cc1799c

2018-05-03 brianosman@google.com Enforce constraints at the start of nonlinear fitting


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: Ic85d08764124fd57fc44950001d2f67348984fa2
Reviewed-on: https://skia-review.googlesource.com/125779
Reviewed-by: skcms-skia-autoroll <skcms-skia-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/third_party/skcms/src/TransferFunction.c b/third_party/skcms/src/TransferFunction.c
index df728e1..c1fce37 100644
--- a/third_party/skcms/src/TransferFunction.c
+++ b/third_party/skcms/src/TransferFunction.c
@@ -238,6 +238,14 @@
 
     for (int j = 0; j < 3/*TODO: tune*/; j++) {
         // These extra constraints a >= 0 and ad+b >= 0 are not modeled in the optimization.
+        // We don't really know how to fix up a if it goes negative.
+        if (P[1] < 0) {
+            return false;
+        }
+        // If ad+b goes negative, we feel just barely not uneasy enough to tweak b so ad+b is zero.
+        if (P[1] * tf->d + P[2] < 0) {
+            P[2] = -P[1] * tf->d;
+        }
         assert (P[1] >= 0 &&
                 P[1] * tf->d + P[2] >= 0);
 
@@ -247,15 +255,14 @@
                                      start*x_scale, 1, N-start)) {
             return false;
         }
+    }
 
-        // We don't really know how to fix up a if it goes negative.
-        if (P[1] < 0) {
-            return false;
-        }
-        // If ad+b goes negative, we feel just barely not uneasy enough to tweak b so ad+b is zero.
-        if (P[1] * tf->d + P[2] < 0) {
-            P[2] = -P[1] * tf->d;
-        }
+    // We need to apply our fixups one last time
+    if (P[1] < 0) {
+        return false;
+    }
+    if (P[1] * tf->d + P[2] < 0) {
+        P[2] = -P[1] * tf->d;
     }
 
     tf->g = P[0];
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index e8af40a..9cabfc9 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-aee343ca3bc90ac49f2c410ed3578efad8012710
\ No newline at end of file
+cc1799c6b4fce905ad3810924d1a1a73b10ec230
\ No newline at end of file