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>
This commit is contained in:
parent
05da1c16df
commit
ed4921b9d4
35
third_party/skcms/src/Curve.c
vendored
35
third_party/skcms/src/Curve.c
vendored
@ -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;
|
||||
}
|
||||
|
2
third_party/skcms/version.sha1
vendored
2
third_party/skcms/version.sha1
vendored
@ -1 +1 @@
|
||||
5cc905db968da1cad33f473f2d7700972bb959a1
|
||||
e4c0e54a9c1998286f0d4760a71f42ae23679541
|
Loading…
Reference in New Issue
Block a user