[gimp] app: factor out gimp_channel_select_buffer() from select_channel()



commit 75c9a0dc276f25db7b3c5a03fe13a353f787ec6e
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 8 23:31:26 2013 +0200

    app: factor out gimp_channel_select_buffer() from select_channel()

 app/core/gimpchannel-select.c |   50 ++++++++++++++++++++++++++++------------
 app/core/gimpchannel-select.h |    9 +++++++
 2 files changed, 44 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index 252674b..e28af8e 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -326,20 +326,20 @@ gimp_channel_select_vectors (GimpChannel    *channel,
 /*  select by GimpChannel functions  */
 
 void
-gimp_channel_select_channel (GimpChannel    *channel,
-                             const gchar    *undo_desc,
-                             GimpChannel    *add_on,
-                             gint            offset_x,
-                             gint            offset_y,
-                             GimpChannelOps  op,
-                             gboolean        feather,
-                             gdouble         feather_radius_x,
-                             gdouble         feather_radius_y)
+gimp_channel_select_buffer (GimpChannel    *channel,
+                            const gchar    *undo_desc,
+                            GeglBuffer     *add_on,
+                            gint            offset_x,
+                            gint            offset_y,
+                            GimpChannelOps  op,
+                            gboolean        feather,
+                            gdouble         feather_radius_x,
+                            gdouble         feather_radius_y)
 {
   g_return_if_fail (GIMP_IS_CHANNEL (channel));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
   g_return_if_fail (undo_desc != NULL);
-  g_return_if_fail (GIMP_IS_CHANNEL (add_on));
+  g_return_if_fail (GEGL_IS_BUFFER (add_on));
 
   gimp_channel_push_undo (channel, undo_desc);
 
@@ -350,7 +350,6 @@ gimp_channel_select_channel (GimpChannel    *channel,
   if (feather || op == GIMP_CHANNEL_OP_INTERSECT)
     {
       GimpItem   *item = GIMP_ITEM (channel);
-      GeglBuffer *add_on_buffer;
       GeglBuffer *add_on2;
 
       add_on2 = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
@@ -358,9 +357,7 @@ gimp_channel_select_channel (GimpChannel    *channel,
                                                  gimp_item_get_height (item)),
                                  babl_format ("Y float"));
 
-      add_on_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (add_on));
-
-      gimp_gegl_mask_combine_buffer (add_on2, add_on_buffer,
+      gimp_gegl_mask_combine_buffer (add_on2, add_on,
                                      GIMP_CHANNEL_OP_ADD,
                                      offset_x, offset_y);
 
@@ -374,11 +371,34 @@ gimp_channel_select_channel (GimpChannel    *channel,
     }
   else
     {
-      gimp_channel_combine_mask (channel, add_on, op, offset_x, offset_y);
+      gimp_channel_combine_buffer (channel, add_on, op, offset_x, offset_y);
     }
 }
 
 void
+gimp_channel_select_channel (GimpChannel    *channel,
+                             const gchar    *undo_desc,
+                             GimpChannel    *add_on,
+                             gint            offset_x,
+                             gint            offset_y,
+                             GimpChannelOps  op,
+                             gboolean        feather,
+                             gdouble         feather_radius_x,
+                             gdouble         feather_radius_y)
+{
+  g_return_if_fail (GIMP_IS_CHANNEL (channel));
+  g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
+  g_return_if_fail (undo_desc != NULL);
+  g_return_if_fail (GIMP_IS_CHANNEL (add_on));
+
+  gimp_channel_select_buffer (channel, undo_desc,
+                              gimp_drawable_get_buffer (GIMP_DRAWABLE (add_on)),
+                              offset_x, offset_y, op,
+                              feather,
+                              feather_radius_x, feather_radius_y);
+}
+
+void
 gimp_channel_select_alpha (GimpChannel    *channel,
                            GimpDrawable   *drawable,
                            GimpChannelOps  op,
diff --git a/app/core/gimpchannel-select.h b/app/core/gimpchannel-select.h
index 4d4e297..c81f0de 100644
--- a/app/core/gimpchannel-select.h
+++ b/app/core/gimpchannel-select.h
@@ -88,6 +88,15 @@ void   gimp_channel_select_vectors      (GimpChannel         *channel,
                                          gdouble              feather_radius_x,
                                          gdouble              feather_radius_y,
                                          gboolean             push_undo);
+void   gimp_channel_select_buffer       (GimpChannel         *channel,
+                                         const gchar         *undo_desc,
+                                         GeglBuffer          *add_on,
+                                         gint                 offset_x,
+                                         gint                 offset_y,
+                                         GimpChannelOps       op,
+                                         gboolean             feather,
+                                         gdouble              feather_radius_x,
+                                         gdouble              feather_radius_y);
 
 
 /*  select by GimpChannel functions  */


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