[gegl] gegl: cache reused babl formats



commit 993ff49d63234a000e1de226c6c397eb436485b9
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Dec 23 20:45:19 2016 +0100

    gegl: cache reused babl formats

 gegl/buffer/gegl-buffer-access.c                |    8 ++++----
 gegl/buffer/gegl-buffer-linear.c                |    2 +-
 gegl/buffer/gegl-buffer.c                       |    6 +++---
 gegl/buffer/gegl-sampler-cubic.c                |    2 +-
 gegl/buffer/gegl-sampler-linear.c               |    2 +-
 gegl/buffer/gegl-sampler-lohalo.c               |    2 +-
 gegl/buffer/gegl-sampler-nearest.c              |    6 +++---
 gegl/buffer/gegl-sampler-nohalo.c               |    2 +-
 gegl/buffer/gegl-sampler.c                      |    2 +-
 gegl/operation/gegl-operation-area-filter.c     |    6 ++++--
 gegl/operation/gegl-operation-context.c         |    2 +-
 gegl/operation/gegl-operation-point-composer.c  |    3 ++-
 gegl/operation/gegl-operation-point-composer3.c |    3 ++-
 gegl/operation/gegl-operation-point-filter.c    |    3 ++-
 gegl/operation/gegl-operation-point-render.c    |    4 +++-
 gegl/operation/gegl-operation-temporal.c        |    5 +++--
 gegl/process/gegl-graph-traversal.c             |    2 +-
 gegl/property-types/gegl-color.c                |   10 +++++-----
 18 files changed, 39 insertions(+), 31 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 347e0d4..94f129f 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -91,7 +91,7 @@ gegl_buffer_get_pixel (GeglBuffer     *buffer,
         case GEGL_ABYSS_BLACK:
           {
             gfloat color[4] = {0.0, 0.0, 0.0, 1.0};
-            babl_process (babl_fish (babl_format ("RGBA float"), format),
+            babl_process (babl_fish (gegl_babl_rgba_linear_float (), format),
                           color,
                           buf,
                           1);
@@ -101,7 +101,7 @@ gegl_buffer_get_pixel (GeglBuffer     *buffer,
         case GEGL_ABYSS_WHITE:
           {
             gfloat color[4] = {1.0, 1.0, 1.0, 1.0};
-            babl_process (babl_fish (babl_format ("RGBA float"),
+            babl_process (babl_fish (gegl_babl_rgba_linear_float (),
                                      format),
                           color,
                           buf,
@@ -1247,7 +1247,7 @@ gegl_buffer_iterate_read_dispatch (GeglBuffer          *buffer,
       guchar color[128];
       gfloat in_color[] = {1.0f, 1.0f, 1.0f, 1.0f};
 
-      babl_process (babl_fish (babl_format ("RGBA float"), format),
+      babl_process (babl_fish (gegl_babl_rgba_linear_float (), format),
                     in_color, color, 1);
 
       gegl_buffer_iterate_read_abyss_color (buffer, &roi_factored, &abyss_factored,
@@ -1259,7 +1259,7 @@ gegl_buffer_iterate_read_dispatch (GeglBuffer          *buffer,
       guchar color[128];
       gfloat  in_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
 
-      babl_process (babl_fish (babl_format ("RGBA float"), format),
+      babl_process (babl_fish (gegl_babl_rgba_linear_float (), format),
                     in_color, color, 1);
 
       gegl_buffer_iterate_read_abyss_color (buffer, &roi_factored, &abyss_factored,
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index 91b2918..49124b5 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -24,7 +24,7 @@ gegl_buffer_linear_new (const GeglRectangle *extent,
     }
 
   if (format==NULL)
-    format = babl_format ("RGBA float");
+    format = gegl_babl_rgba_linear_float ();
 
   /* creating a linear buffer for GeglBuffer is a matter of
    * requesting the correct parameters when creating the
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 891c7b0..b233778 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -524,7 +524,7 @@ gegl_buffer_constructor (GType                  type,
           if (!buffer->format)
             {
               g_warning ("Buffer constructed without format, assuming RGBA float");
-              buffer->format = babl_format ("RGBA float");
+              buffer->format = gegl_babl_rgba_linear_float ();
             }
 
           /* make a new backend & storage */
@@ -956,7 +956,7 @@ gegl_buffer_new_ram (const GeglRectangle *extent,
     extent = &empty;
 
   if (format == NULL)
-    format = babl_format ("RGBA float");
+    format = gegl_babl_rgba_linear_float ();
 
   return g_object_new (GEGL_TYPE_BUFFER,
                        "x", extent->x,
@@ -978,7 +978,7 @@ gegl_buffer_new (const GeglRectangle *extent,
     extent = &empty;
 
   if (format == NULL)
-    format = babl_format ("RGBA float");
+    format = gegl_babl_rgba_linear_float ();
 
   return g_object_new (GEGL_TYPE_BUFFER,
                        "x", extent->x,
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index 02ea4ee..e7848a7 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -117,7 +117,7 @@ gegl_sampler_cubic_init (GeglSamplerCubic *self)
   GEGL_SAMPLER (self)->level[0].context_rect.y = -2;
   GEGL_SAMPLER (self)->level[0].context_rect.width = 5;
   GEGL_SAMPLER (self)->level[0].context_rect.height = 5;
-  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
+  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
 
   self->b=1.0;
   self->c=0.0;
diff --git a/gegl/buffer/gegl-sampler-linear.c b/gegl/buffer/gegl-sampler-linear.c
index 5377668..a7c84fc 100644
--- a/gegl/buffer/gegl-sampler-linear.c
+++ b/gegl/buffer/gegl-sampler-linear.c
@@ -70,7 +70,7 @@ gegl_sampler_linear_init (GeglSamplerLinear *self)
   GEGL_SAMPLER (self)->level[0].context_rect.y      = -1 -   LINEAR_EXTRA_ELBOW_ROOM;
   GEGL_SAMPLER (self)->level[0].context_rect.width  =  3 + 2*LINEAR_EXTRA_ELBOW_ROOM;
   GEGL_SAMPLER (self)->level[0].context_rect.height =  3 + 2*LINEAR_EXTRA_ELBOW_ROOM;
-  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
+  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
 }
 
 static inline void
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 0acf80e..01ff66f 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -425,7 +425,7 @@ gegl_sampler_lohalo_init (GeglSamplerLohalo *self)
   level->context_rect.width  = LOHALO_SIZE_7;
   level->context_rect.height = LOHALO_SIZE_7;
 
-  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
+  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
 }
 
 /*
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 4ec2cab..f610951 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -69,7 +69,7 @@ gegl_sampler_nearest_init (GeglSamplerNearest *self)
   GEGL_SAMPLER (self)->level[0].context_rect.y = 0;
   GEGL_SAMPLER (self)->level[0].context_rect.width = 1;
   GEGL_SAMPLER (self)->level[0].context_rect.height = 1;
-  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
+  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
 }
 
 static void inline
@@ -105,7 +105,7 @@ gegl_sampler_get_pixel (GeglSampler    *sampler,
         case GEGL_ABYSS_BLACK:
           {
             gfloat color[4] = {0.0, 0.0, 0.0, 1.0};
-            babl_process (babl_fish (babl_format ("RGBA float"), sampler->format),
+            babl_process (babl_fish (gegl_babl_rgba_linear_float (), sampler->format),
                           color,
                           buf,
                           1);
@@ -115,7 +115,7 @@ gegl_sampler_get_pixel (GeglSampler    *sampler,
         case GEGL_ABYSS_WHITE:
           {
             gfloat color[4] = {1.0, 1.0, 1.0, 1.0};
-            babl_process (babl_fish (babl_format ("RGBA float"),
+            babl_process (babl_fish (gegl_babl_rgba_linear_float (),
                                      sampler->format),
                           color,
                           buf,
diff --git a/gegl/buffer/gegl-sampler-nohalo.c b/gegl/buffer/gegl-sampler-nohalo.c
index eeef4af..68cb552 100644
--- a/gegl/buffer/gegl-sampler-nohalo.c
+++ b/gegl/buffer/gegl-sampler-nohalo.c
@@ -508,7 +508,7 @@ gegl_sampler_nohalo_init (GeglSamplerNohalo *self)
   level->context_rect.width  = NOHALO_SIZE_7;
   level->context_rect.height = NOHALO_SIZE_7;
 
-  GEGL_SAMPLER (self)->interpolate_format = babl_format ("RaGaBaA float");
+  GEGL_SAMPLER (self)->interpolate_format = gegl_babl_rgbA_linear_float ();
 }
 
 static void inline
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 9f556fd..2364380 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -609,7 +609,7 @@ gegl_buffer_sampler_new_at_level (GeglBuffer      *buffer,
   GType        desired_type;
 
   if (format == NULL)
-    format = babl_format ("RaGaBaA float");
+    format = gegl_babl_rgbA_linear_float ();
 
   desired_type = gegl_sampler_gtype_from_enum (sampler_type);
 
diff --git a/gegl/operation/gegl-operation-area-filter.c b/gegl/operation/gegl-operation-area-filter.c
index 78a6e70..062fbce 100644
--- a/gegl/operation/gegl-operation-area-filter.c
+++ b/gegl/operation/gegl-operation-area-filter.c
@@ -24,6 +24,7 @@
 #include "gegl.h"
 #include "gegl-operation-area-filter.h"
 #include "gegl-operation-context.h"
+#include "gegl-types-internal.h"
 
 
 static void          prepare                  (GeglOperation       *operation);
@@ -60,8 +61,9 @@ gegl_operation_area_filter_init (GeglOperationAreaFilter *self)
 
 static void prepare (GeglOperation *operation)
 {
-  gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
-  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+  const Babl *format = gegl_babl_rgba_linear_float ();
+  gegl_operation_set_format (operation, "input", format);
+  gegl_operation_set_format (operation, "output", format);
 }
 
 static GeglRectangle
diff --git a/gegl/operation/gegl-operation-context.c b/gegl/operation/gegl-operation-context.c
index 032a55f..430b1ff 100644
--- a/gegl/operation/gegl-operation-context.c
+++ b/gegl/operation/gegl-operation-context.c
@@ -311,7 +311,7 @@ gegl_operation_context_get_target (GeglOperationContext *context,
     {
       g_warning ("no format for %s presuming RGBA float\n",
                  gegl_node_get_debug_name (node));
-      format = babl_format ("RGBA float");
+      format = gegl_babl_rgba_linear_float ();
     }
   g_assert (format != NULL);
   g_assert (!strcmp (padname, "output"));
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index 5cca499..ba5afc1 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -25,6 +25,7 @@
 #include "gegl-operation-point-composer.h"
 #include "gegl-operation-context.h"
 #include "gegl-config.h"
+#include "gegl-types-internal.h"
 #include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
@@ -162,7 +163,7 @@ G_DEFINE_TYPE (GeglOperationPointComposer, gegl_operation_point_composer, GEGL_T
 
 static void prepare (GeglOperation *operation)
 {
-  const Babl *format = babl_format ("RGBA float");
+  const Babl *format = gegl_babl_rgba_linear_float ();
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
   gegl_operation_set_format (operation, "output", format);
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index c7f95ed..9b2499c 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -24,6 +24,7 @@
 #include "gegl.h"
 #include "gegl-operation-point-composer3.h"
 #include "gegl-operation-context.h"
+#include "gegl-types-internal.h"
 #include "gegl-config.h"
 #include <sys/types.h>
 #include <unistd.h>
@@ -177,7 +178,7 @@ G_DEFINE_TYPE (GeglOperationPointComposer3, gegl_operation_point_composer3, GEGL
 
 static void prepare (GeglOperation *operation)
 {
-  const Babl *format = babl_format ("RGBA float");
+  const Babl *format = gegl_babl_rgba_linear_float ();
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
   gegl_operation_set_format (operation, "aux2", format);
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index d3b8241..03a38d2 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -26,6 +26,7 @@
 #include "gegl-operation-point-filter.h"
 #include "gegl-operation-context.h"
 #include "gegl-config.h"
+#include "gegl-types-internal.h"
 #include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
@@ -147,7 +148,7 @@ G_DEFINE_TYPE (GeglOperationPointFilter, gegl_operation_point_filter, GEGL_TYPE_
 
 static void prepare (GeglOperation *operation)
 {
-  const Babl *format = babl_format ("RGBA float");
+  const Babl *format = gegl_babl_rgba_linear_float ();
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "output", format);
 }
diff --git a/gegl/operation/gegl-operation-point-render.c b/gegl/operation/gegl-operation-point-render.c
index 5225893..ca94b1f 100644
--- a/gegl/operation/gegl-operation-point-render.c
+++ b/gegl/operation/gegl-operation-point-render.c
@@ -24,6 +24,7 @@
 #include "gegl.h"
 #include "gegl-operation-point-render.h"
 #include "gegl-operation-context.h"
+#include "gegl-types-internal.h"
 
 static gboolean gegl_operation_point_render_process
                               (GeglOperation       *operation,
@@ -35,7 +36,8 @@ G_DEFINE_TYPE (GeglOperationPointRender, gegl_operation_point_render, GEGL_TYPE_
 
 static void prepare (GeglOperation *operation)
 {
-  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+  const Babl *format = gegl_babl_rgba_linear_float ();
+  gegl_operation_set_format (operation, "output", format);
 }
 
 static GeglNode *
diff --git a/gegl/operation/gegl-operation-temporal.c b/gegl/operation/gegl-operation-temporal.c
index 8b278f4..b6cc990 100644
--- a/gegl/operation/gegl-operation-temporal.c
+++ b/gegl/operation/gegl-operation-temporal.c
@@ -113,8 +113,9 @@ static gboolean gegl_operation_temporal_process (GeglOperation       *self,
 
 static void gegl_operation_temporal_prepare (GeglOperation *operation)
 {
-  gegl_operation_set_format (operation, "output", babl_format ("RGB u8"));
-  gegl_operation_set_format (operation, "input", babl_format ("RGB u8"));
+  const Babl *format = babl_format ("RGB u8");
+  gegl_operation_set_format (operation, "output", format);
+  gegl_operation_set_format (operation, "input", format);
 }
 
 static void
diff --git a/gegl/process/gegl-graph-traversal.c b/gegl/process/gegl-graph-traversal.c
index 7af3071..c2188e5 100644
--- a/gegl/process/gegl-graph-traversal.c
+++ b/gegl/process/gegl-graph-traversal.c
@@ -366,7 +366,7 @@ gegl_graph_get_shared_empty (GeglGraphTraversal *path)
   if (!path->shared_empty)
     {
       path->shared_empty = gegl_buffer_new_ram (GEGL_RECTANGLE (0, 0, 0, 0),
-                                                babl_format ("RGBA float"));
+                                                gegl_babl_rgba_linear_float ());
       gegl_object_set_has_forked (G_OBJECT (path->shared_empty));
     }
   return path->shared_empty;
diff --git a/gegl/property-types/gegl-color.c b/gegl/property-types/gegl-color.c
index be375f9..0b65822 100644
--- a/gegl/property-types/gegl-color.c
+++ b/gegl/property-types/gegl-color.c
@@ -270,7 +270,7 @@ gegl_color_set_pixel (GeglColor   *color,
   g_return_if_fail (format);
   g_return_if_fail (pixel);
 
-  babl_process (babl_fish (format, babl_format ("RGBA float")),
+  babl_process (babl_fish (format, gegl_babl_rgba_linear_float ()),
                 pixel, color->priv->rgba_color, 1);
 }
 
@@ -283,7 +283,7 @@ gegl_color_get_pixel (GeglColor   *color,
   g_return_if_fail (format);
   g_return_if_fail (pixel);
 
-  babl_process (babl_fish (babl_format ("RGBA float"), format),
+  babl_process (babl_fish (gegl_babl_rgba_linear_float (), format),
                 color->priv->rgba_color, pixel, 1);
 }
 
@@ -326,7 +326,7 @@ gegl_color_set_from_string (GeglColor   *self,
   GTokenValue       token_value;
   gboolean          color_parsing_successfull;
   float rgba[4] = {0.0, 0.0, 0.0, 1.0};
-  const Babl *format = babl_format ("R'G'B'A float");
+  const Babl *format = gegl_babl_rgba_float ();
 
   scanner                               = g_scanner_new (NULL);
   scanner->config->cpair_comment_single = "";
@@ -339,14 +339,14 @@ gegl_color_set_from_string (GeglColor   *self,
       g_ascii_strcasecmp (token_value.v_identifier, "rgb") == 0)
     {
       color_parsing_successfull = parse_float_argument_list (rgba, scanner, 3);
-      format = babl_format ("RGBA float");
+      format = gegl_babl_rgba_linear_float ();
     }
   else if (token_type == G_TOKEN_IDENTIFIER &&
            g_ascii_strcasecmp (token_value.v_identifier, "rgba") == 0)
     {
       rgba[3] = 1.0;
       color_parsing_successfull = parse_float_argument_list (rgba, scanner, 4);
-      format = babl_format ("RGBA float");
+      format = gegl_babl_rgba_linear_float ();
     }
   else if (token_type == '#')
     {


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