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-16 19:14:40 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-17 01:09:52 +0000
commited4921b9d4734dab53f514a7df7172b62b9d7824 (patch)
tree95296123f647f96a44fd026043e9e51f831c32e6 /third_party/skcms
parent05da1c16dfb4a8117451124fe7474fdffcac46d8 (diff)
Roll skia/third_party/skcms 5cc905d..e4c0e54 (1 commits)
https://skia.googlesource.com/skcms.git/+log/5cc905d..e4c0e54 2018-05-16 brianosman@google.com Add lerping to skcms_eval_curve 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=herb@google.com Change-Id: Ie44a66826197489e499a2ce7dcbba8592a43973f Reviewed-on: https://skia-review.googlesource.com/128650 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/src/Curve.c35
-rwxr-xr-xthird_party/skcms/version.sha12
2 files changed, 24 insertions, 13 deletions
diff --git a/third_party/skcms/src/Curve.c b/third_party/skcms/src/Curve.c
index f52eb983fe..2b5a042500 100644
--- a/third_party/skcms/src/Curve.c
+++ b/third_party/skcms/src/Curve.c
@@ -10,25 +10,36 @@
#include "TransferFunction.h"
#include <assert.h>
+static float minus_1_ulp(float x) {
+ int32_t bits;
+ memcpy(&bits, &x, sizeof(bits));
+ bits = bits - 1;
+ memcpy(&x, &bits, sizeof(bits));
+ return x;
+}
+
float skcms_eval_curve(const skcms_Curve* curve, float x) {
if (curve->table_entries == 0) {
return skcms_TransferFunction_eval(&curve->parametric, x);
}
- // TODO: today we should always hit an entry exactly, but if that changes, lerp?
- // (We add half to account for slight int -> float -> int round tripping issues.)
- float fx = x*(curve->table_entries - 1);
- int ix = (int)( fx + 0.5f );
-
- assert ( fabsf_(fx - (float)ix) < 0.0005 );
+ float ix = fmaxf_(0, fminf_(x, 1)) * (curve->table_entries - 1);
+ int lo = (int) ix,
+ hi = (int)minus_1_ulp(ix + 1.0f);
+ float t = ix - (float)lo;
+ float l, h;
if (curve->table_8) {
- return curve->table_8[ix] * (1/255.0f);
+ l = curve->table_8[lo] * (1/255.0f);
+ h = curve->table_8[hi] * (1/255.0f);
} else {
- uint16_t be;
- memcpy(&be, curve->table_16 + 2*ix, 2);
-
- uint16_t le = ((be << 8) | (be >> 8)) & 0xffff;
- return le * (1/65535.0f);
+ uint16_t be_l, be_h;
+ memcpy(&be_l, curve->table_16 + 2*lo, 2);
+ memcpy(&be_h, curve->table_16 + 2*hi, 2);
+ uint16_t le_l = ((be_l << 8) | (be_l >> 8)) & 0xffff;
+ uint16_t le_h = ((be_h << 8) | (be_h >> 8)) & 0xffff;
+ l = le_l * (1/65535.0f);
+ h = le_h * (1/65535.0f);
}
+ return l + (h-l)*t;
}
diff --git a/third_party/skcms/version.sha1 b/third_party/skcms/version.sha1
index 14bc5efe03..a2c36d6635 100755
--- a/third_party/skcms/version.sha1
+++ b/third_party/skcms/version.sha1
@@ -1 +1 @@
-5cc905db968da1cad33f473f2d7700972bb959a1 \ No newline at end of file
+e4c0e54a9c1998286f0d4760a71f42ae23679541 \ No newline at end of file