[gimp] app: change gimp_gegl_color_set_rgba() to gimp_gegl_color_new()



commit 69c52173fb48afd70f316349c7cfac55e51159d0
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 20 10:27:28 2012 +0100

    app: change gimp_gegl_color_set_rgba() to gimp_gegl_color_new()
    
    which saves one line of code in every single use case.

 app/core/gimp-edit.c                |    5 +----
 app/core/gimpdrawable-bucket-fill.c |    5 +----
 app/core/gimpdrawable-offset.c      |    9 +++------
 app/core/gimpdrawable-stroke.c      |   12 ++++++------
 app/core/gimpdrawable-transform.c   |    8 ++------
 app/core/gimpdrawable.c             |   10 ++--------
 app/core/gimpimage-merge.c          |    5 +----
 app/gegl/gimp-gegl-nodes.c          |    4 +---
 app/gegl/gimp-gegl-utils.c          |   13 ++++++++-----
 app/gegl/gimp-gegl-utils.h          |    3 +--
 app/paint/gimpsmudge.c              |    4 +---
 11 files changed, 27 insertions(+), 51 deletions(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index b716ad6..8ee7a68 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -495,16 +495,13 @@ gimp_edit_fill_full (GimpImage            *image,
       GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
 
       gegl_buffer_set_pattern (dest_buffer, NULL, src_buffer, 0, 0);
-
       g_object_unref (src_buffer);
     }
   else
     {
-      GeglColor *gegl_color = gegl_color_new (NULL);
+      GeglColor *gegl_color = gimp_gegl_color_new (color);
 
-      gimp_gegl_color_set_rgba (gegl_color, color);
       gegl_buffer_set_color (dest_buffer, NULL, gegl_color);
-
       g_object_unref (gegl_color);
     }
 
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 42a7e5a..a541e59 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -236,11 +236,9 @@ gimp_drawable_bucket_fill_internal (GimpDrawable        *drawable,
     case GIMP_FG_BUCKET_FILL:
     case GIMP_BG_BUCKET_FILL:
       {
-        GeglColor *gegl_color = gegl_color_new (NULL);
+        GeglColor *gegl_color = gimp_gegl_color_new (color);
 
-        gimp_gegl_color_set_rgba (gegl_color, color);
         gegl_buffer_set_color (buffer, NULL, gegl_color);
-
         g_object_unref (gegl_color);
       }
       break;
@@ -250,7 +248,6 @@ gimp_drawable_bucket_fill_internal (GimpDrawable        *drawable,
         GeglBuffer *pattern_buffer = gimp_pattern_create_buffer (pattern);
 
         gegl_buffer_set_pattern (buffer, NULL, pattern_buffer, -x1, -y1);
-
         g_object_unref (pattern_buffer);
       }
       break;
diff --git a/app/core/gimpdrawable-offset.c b/app/core/gimpdrawable-offset.c
index 38da424..d948986 100644
--- a/app/core/gimpdrawable-offset.c
+++ b/app/core/gimpdrawable-offset.c
@@ -97,16 +97,13 @@ gimp_drawable_offset (GimpDrawable   *drawable,
     {
       if (fill_type == GIMP_OFFSET_BACKGROUND)
         {
-          GimpRGB    background;
+          GimpRGB    bg;
           GeglColor *color;
 
-          gimp_context_get_background (context, &background);
-
-          color = gegl_color_new (NULL);
-          gimp_gegl_color_set_rgba (color, &background);
+          gimp_context_get_background (context, &bg);
 
+          color = gimp_gegl_color_new (&bg);
           gegl_buffer_set_color (dest_buffer, NULL, color);
-
           g_object_unref (color);
         }
       else
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index 7ee618b..d6ed131 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -368,24 +368,24 @@ gimp_drawable_stroke_scan_convert (GimpDrawable    *drawable,
     {
     case GIMP_FILL_STYLE_SOLID:
       {
-        GeglColor *color = gegl_color_new (NULL);
         GimpRGB    fg;
+        GeglColor *color;
 
         gimp_context_get_foreground (context, &fg);
-        gimp_gegl_color_set_rgba (color, &fg);
-        gegl_buffer_set_color (base_buffer, NULL, color);
 
+        color = gimp_gegl_color_new (&fg);
+        gegl_buffer_set_color (base_buffer, NULL, color);
         g_object_unref (color);
       }
       break;
 
     case GIMP_FILL_STYLE_PATTERN:
       {
-        GimpPattern *pattern        = gimp_context_get_pattern (context);
-        GeglBuffer  *pattern_buffer = gimp_pattern_create_buffer (pattern);
+        GimpPattern *pattern = gimp_context_get_pattern (context);
+        GeglBuffer  *pattern_buffer;
 
+        pattern_buffer = gimp_pattern_create_buffer (pattern);
         gegl_buffer_set_pattern (base_buffer, NULL, pattern_buffer, 0, 0);
-
         g_object_unref (pattern_buffer);
       }
       break;
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index f8d3d08..9969d45 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -272,9 +272,7 @@ gimp_drawable_transform_tiles_flip (GimpDrawable        *drawable,
       else
         gimp_context_get_background (context, &bg);
 
-      color = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (color, &bg);
-
+      color = gimp_gegl_color_new (&bg);
       gegl_buffer_set_color (dest_buffer, NULL, color);
       g_object_unref (color);
 
@@ -488,9 +486,7 @@ gimp_drawable_transform_tiles_rotate (GimpDrawable     *drawable,
       else
         gimp_context_get_background (context, &bg);
 
-      color = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (color, &bg);
-
+      color = gimp_gegl_color_new (&bg);
       gegl_buffer_set_color (dest_buffer, NULL, color);
       g_object_unref (color);
 
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 640554d..507a818 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -599,11 +599,9 @@ gimp_drawable_resize (GimpItem    *item,
       else
         gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
 
-      col = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (col, &bg);
+      col = gimp_gegl_color_new (&bg);
 
       gegl_buffer_set_color (dest_buffer, NULL, col);
-
       g_object_unref (col);
     }
 
@@ -1768,12 +1766,9 @@ gimp_drawable_fill (GimpDrawable      *drawable,
       if (! gimp_drawable_has_alpha (drawable))
         gimp_rgb_set_alpha (&c, 1.0);
 
-      col = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (col, &c);
-
+      col = gimp_gegl_color_new (&c);
       gegl_buffer_set_color (gimp_drawable_get_write_buffer (drawable),
                              NULL, col);
-
       g_object_unref (col);
     }
   else
@@ -1782,7 +1777,6 @@ gimp_drawable_fill (GimpDrawable      *drawable,
 
       gegl_buffer_set_pattern (gimp_drawable_get_write_buffer (drawable),
                                NULL, src_buffer, 0, 0);
-
       g_object_unref (src_buffer);
     }
 
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 9bfb175..3f02f01 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -545,12 +545,9 @@ gimp_image_merge_layers (GimpImage     *image,
       rect.width  = x2 - x1;
       rect.height = y2 - y1;
 
-      color = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (color, &bg);
-
+      color = gimp_gegl_color_new (&bg);
       gegl_buffer_set_color (gimp_drawable_get_write_buffer (GIMP_DRAWABLE (merge_layer)),
                              &rect, color);
-
       g_object_unref (color);
 
       position = 0;
diff --git a/app/gegl/gimp-gegl-nodes.c b/app/gegl/gimp-gegl-nodes.c
index c99986a..5110dd6 100644
--- a/app/gegl/gimp-gegl-nodes.c
+++ b/app/gegl/gimp-gegl-nodes.c
@@ -45,9 +45,7 @@ gimp_gegl_create_flatten_node (const GimpRGB *background)
   input  = gegl_node_get_input_proxy  (node, "input");
   output = gegl_node_get_output_proxy (node, "output");
 
-  c = gegl_color_new (NULL);
-  gimp_gegl_color_set_rgba (c, background);
-
+  c = gimp_gegl_color_new (background);
   color = gegl_node_new_child (node,
                                "operation", "gegl:color",
                                "value",     c,
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 446639c..b2f8cc4 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -226,12 +226,15 @@ gimp_gegl_buffer_refetch_tiles (GeglBuffer *buffer)
   gegl_tile_source_reinit (GEGL_TILE_SOURCE (buffer));
 }
 
-void
-gimp_gegl_color_set_rgba (GeglColor     *color,
-                          const GimpRGB *rgb)
+GeglColor *
+gimp_gegl_color_new (const GimpRGB *rgb)
 {
-  g_return_if_fail (GEGL_IS_COLOR (color));
-  g_return_if_fail (rgb != NULL);
+  GeglColor *color;
+
+  g_return_val_if_fail (rgb != NULL, NULL);
 
+  color = gegl_color_new (NULL);
   gegl_color_set_rgba (color, rgb->r, rgb->g, rgb->b, rgb->a);
+
+  return color;
 }
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 4956fbe..595100e 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -40,8 +40,7 @@ GeglBuffer  * gimp_pixbuf_create_buffer          (GdkPixbuf             *pixbuf)
 
 void          gimp_gegl_buffer_refetch_tiles     (GeglBuffer            *buffer);
 
-void          gimp_gegl_color_set_rgba           (GeglColor             *color,
-                                                  const GimpRGB         *rgb);
+GeglColor   * gimp_gegl_color_new                (const GimpRGB         *rgb);
 
 
 #endif /* __GIMP_GEGL_UTILS_H__ */
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index 3d3d947..77e187f 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -222,9 +222,7 @@ gimp_smudge_start (GimpPaintCore    *paint_core,
                                          gimp_item_get_height (GIMP_ITEM (drawable)) - 1),
                                   &pixel);
 
-      color = gegl_color_new (NULL);
-      gimp_gegl_color_set_rgba (color, &pixel);
-
+      color = gimp_gegl_color_new (&pixel);
       gegl_buffer_set_color (buffer, &rect, color);
       g_object_unref (color);
 



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