[gegl] gegl-algorithms: cache babl_types



commit 67636cac2bbcd1d3be2ba0a81ca8a5b38838d793
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Dec 23 17:59:05 2016 +0100

    gegl-algorithms: cache babl_types

 gegl/gegl-algorithms.c |   36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/gegl/gegl-algorithms.c b/gegl/gegl-algorithms.c
index 13bff45..cbd11d5 100644
--- a/gegl/gegl-algorithms.c
+++ b/gegl/gegl-algorithms.c
@@ -30,6 +30,12 @@
 
 #include <math.h>
 
+static const Babl *babl_type_float (void) { static const Babl *type = NULL; if (!type) type = babl_type 
("float"); return type; }
+static const Babl *babl_type_u8 (void) { static const Babl *type = NULL; if (!type) type = babl_type ("u8"); 
return type; }
+static const Babl *babl_type_u16 (void) { static const Babl *type = NULL; if (!type) type = babl_type 
("u16"); return type; }
+static const Babl *babl_type_u32 (void) { static const Babl *type = NULL; if (!type) type = babl_type 
("u32"); return type; }
+static const Babl *babl_type_double (void) { static const Babl *type = NULL; if (!type) type = babl_type 
("double"); return type; }
+
 void gegl_downscale_2x2 (const Babl *format,
                          gint    src_width,
                          gint    src_height,
@@ -41,15 +47,15 @@ void gegl_downscale_2x2 (const Babl *format,
   const gint  bpp = babl_format_get_bytes_per_pixel (format);
   const Babl *comp_type = babl_format_get_type (format, 0);
 
-  if (comp_type == babl_type ("float"))
+  if (comp_type == babl_type_float())
     gegl_downscale_2x2_float (bpp, src_width, src_height, src_data, src_rowstride, dst_data, dst_rowstride);
-  else if (comp_type == babl_type ("u8"))
+  else if (comp_type == babl_type_u8())
     gegl_downscale_2x2_u8 (bpp, src_width, src_height, src_data, src_rowstride, dst_data, dst_rowstride);
-  else if (comp_type == babl_type ("u16"))
+  else if (comp_type == babl_type_u16())
     gegl_downscale_2x2_u16 (bpp, src_width, src_height, src_data, src_rowstride, dst_data, dst_rowstride);
-  else if (comp_type == babl_type ("u32"))
+  else if (comp_type == babl_type_u32())
     gegl_downscale_2x2_u32 (bpp, src_width, src_height, src_data, src_rowstride, dst_data, dst_rowstride);
-  else if (comp_type == babl_type ("double"))
+  else if (comp_type == babl_type_double())
     gegl_downscale_2x2_double (bpp, src_width, src_height, src_data, src_rowstride, dst_data, dst_rowstride);
   else
     gegl_downscale_2x2_nearest (bpp, src_width, src_height, src_data, src_rowstride, dst_data, 
dst_rowstride);
@@ -96,19 +102,19 @@ void gegl_resample_boxfilter (guchar              *dest_buf,
   const Babl *comp_type  = babl_format_get_type (format, 0);
   const gint bpp = babl_format_get_bytes_per_pixel (format);
 
-  if (comp_type == babl_type ("u8"))
+  if (comp_type == babl_type_u8())
     gegl_resample_boxfilter_u8 (dest_buf, source_buf, dst_rect, src_rect,
                                 s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("u16"))
+  else if (comp_type == babl_type_u16())
     gegl_resample_boxfilter_u16 (dest_buf, source_buf, dst_rect, src_rect,
                                  s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("u32"))
+  else if (comp_type == babl_type_u32())
     gegl_resample_boxfilter_u32 (dest_buf, source_buf, dst_rect, src_rect,
                                  s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("float"))
+  else if (comp_type == babl_type_float())
     gegl_resample_boxfilter_float (dest_buf, source_buf, dst_rect, src_rect,
                                    s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("double"))
+  else if (comp_type == babl_type_double())
     gegl_resample_boxfilter_double (dest_buf, source_buf, dst_rect, src_rect,
                                     s_rowstride, scale, bpp, d_rowstride);
   else
@@ -128,19 +134,19 @@ void gegl_resample_bilinear (guchar              *dest_buf,
   const Babl *comp_type  = babl_format_get_type (format, 0);
   const gint bpp = babl_format_get_bytes_per_pixel (format);
 
-  if (comp_type == babl_type ("u8"))
+  if (comp_type == babl_type_u8 ())
     gegl_resample_bilinear_u8 (dest_buf, source_buf, dst_rect, src_rect,
                                s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("u16"))
+  else if (comp_type == babl_type_u16 ())
     gegl_resample_bilinear_u16 (dest_buf, source_buf, dst_rect, src_rect,
                                 s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("u32"))
+  else if (comp_type == babl_type_u32 ())
     gegl_resample_bilinear_u32 (dest_buf, source_buf, dst_rect, src_rect,
                                 s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("float"))
+  else if (comp_type == babl_type_float ())
     gegl_resample_bilinear_float (dest_buf, source_buf, dst_rect, src_rect,
                                   s_rowstride, scale, bpp, d_rowstride);
-  else if (comp_type == babl_type ("double"))
+  else if (comp_type == babl_type_double ())
     gegl_resample_bilinear_double (dest_buf, source_buf, dst_rect, src_rect,
                                    s_rowstride, scale, bpp, d_rowstride);
   else


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