Fix transfer function epsilon
authorMatt Sarett <msarett@google.com>
Mon, 6 Mar 2017 14:11:54 +0000 (09:11 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Mon, 6 Mar 2017 14:58:52 +0000 (14:58 +0000)
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>
src/core/SkColorSpacePriv.h

index e1b01b7..0f5af27 100644 (file)
@@ -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;