diff options
author | Matt Sarett <msarett@google.com> | 2017-03-06 09:11:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-06 14:58:52 +0000 |
commit | 06b302585c35000642898752a6d4e7cf5b67ceac (patch) | |
tree | fe3e434b565e2cf3efa26222644f475cd3060e7f | |
parent | e632003ca7d861b9e4325e836575410e59ad337c (diff) |
Fix transfer function epsilon
This has never worked.
1.0f == 1.0f + FLT_MIN
BUG=skia:
Change-Id: I73c8f321ea0d13497cb74f7bd5965d5910e664d1
Reviewed-on: https://skia-review.googlesource.com/9280
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
-rw-r--r-- | src/core/SkColorSpacePriv.h | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/core/SkColorSpacePriv.h b/src/core/SkColorSpacePriv.h index e1b01b707f..0f5af2781e 100644 --- a/src/core/SkColorSpacePriv.h +++ b/src/core/SkColorSpacePriv.h @@ -58,14 +58,10 @@ static inline bool color_space_almost_equal(float a, float b) { return SkTAbs(a - b) < 0.01f; } -static inline float add_epsilon(float v) { - return v + FLT_MIN; -} - static inline bool is_zero_to_one(float v) { // Because we allow a value just barely larger than 1, the client can use an // entirely linear transfer function. - return (0.0f <= v) && (v <= add_epsilon(1.0f)); + return (0.0f <= v) && (v <= nextafterf(1.0f, 2.0f)); } static inline bool is_valid_transfer_fn(const SkColorSpaceTransferFn& coeffs) { @@ -185,7 +181,7 @@ static inline bool named_to_parametric(SkColorSpaceTransferFn* coeffs, coeffs->fC = 1.0f; // Make sure that we use the linear segment of the transfer function even // when the x-value is 1.0f. - coeffs->fD = add_epsilon(1.0f); + coeffs->fD = nextafterf(1.0f, 2.0f); coeffs->fE = 0.0f; coeffs->fF = 0.0f; coeffs->fG = 0.0f; |