[gegl] opacity: use inlinable fabsf



commit 2a734c1750199742a3dac02d7593e74e4bd995f8
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed May 13 03:12:48 2020 +0200

    opacity: use inlinable fabsf

 operations/common/opacity.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/operations/common/opacity.c b/operations/common/opacity.c
index c89e6c491..d8a5c6acf 100644
--- a/operations/common/opacity.c
+++ b/operations/common/opacity.c
@@ -55,6 +55,13 @@ prepare (GeglOperation *self)
   return;
 }
 
+static inline gfloat int_fabsf (const gfloat x)
+{
+  union {gfloat f; guint32 i;} u = {x};
+  u.i &= 0x7fffffff;
+  return u.f;
+}
+
 static void
 process_premultiplied_float (GeglOperation       *op,
                       void                *in_buf,
@@ -81,7 +88,7 @@ process_premultiplied_float (GeglOperation       *op,
           out += components;
         }
     }
-  else if (fabsf (value - 1.0f) <= EPSILON)
+  else if (int_fabsf (value - 1.0f) <= EPSILON)
     while (samples--)
       {
         gint j;
@@ -132,7 +139,7 @@ process_with_alpha_float (GeglOperation       *op,
           out += components;
         }
     }
-  else if (fabsf (value - 1.0f) <= EPSILON)
+  else if (int_fabsf (value - 1.0f) <= EPSILON)
     while (samples--)
       {
         gint j;
@@ -247,7 +254,7 @@ static gboolean operation_process (GeglOperation        *operation,
   in = gegl_operation_context_get_object (context, "input");
   aux = gegl_operation_context_get_object (context, "aux");
 
-  if (in && !aux && fabsf (value - 1.0f) <= EPSILON)
+  if (in && !aux && int_fabsf (value - 1.0f) <= EPSILON)
     {
       gegl_operation_context_take_object (context, "output",
                                           g_object_ref (G_OBJECT (in)));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]