[gimp] app: rename gimpimage-contiguous-region.[ch] to gimppickable-....[ch]



commit 0349b8972ab6bb3979832aaa77f2323cdf4af981
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 31 09:52:44 2014 +0200

    app: rename gimpimage-contiguous-region.[ch] to gimppickable-....[ch]
    
    The functions don't need to know about sample_merged, in fact they
    used the boolean only to either use the passed image or drawable and
    otherwise ran the same code. The sample_merged logic belongs into
    their callers (and sometimes not even there).

 app/core/Makefile.am                               |    4 +-
 app/core/gimpchannel-select.c                      |   59 +++++++++--------
 app/core/gimpdrawable-bucket-fill.c                |   38 ++++++-----
 app/core/gimpimage-contiguous-region.h             |   42 ------------
 ...s-region.c => gimppickable-contiguous-region.c} |   70 +++++++-------------
 app/core/gimppickable-contiguous-region.h          |   38 +++++++++++
 app/tools/gimpbycolorselecttool.c                  |   15 ++--
 app/tools/gimpfuzzyselecttool.c                    |   23 ++++--
 8 files changed, 140 insertions(+), 149 deletions(-)
---
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index 374b3a7..3fbf897 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -203,8 +203,6 @@ libappcore_a_sources = \
        gimpimage-arrange.h                     \
        gimpimage-colormap.c                    \
        gimpimage-colormap.h                    \
-       gimpimage-contiguous-region.c           \
-       gimpimage-contiguous-region.h           \
        gimpimage-convert-fsdither.h            \
        gimpimage-convert-data.h                \
        gimpimage-convert-precision.c           \
@@ -327,6 +325,8 @@ libappcore_a_sources = \
        gimppickable.h                          \
        gimppickable-auto-shrink.c              \
        gimppickable-auto-shrink.h              \
+       gimppickable-contiguous-region.c        \
+       gimppickable-contiguous-region.h        \
        gimpprogress.c                          \
        gimpprogress.h                          \
        gimpprojectable.c                       \
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index b804bc1..de9c513 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -34,7 +34,8 @@
 #include "gimpchannel.h"
 #include "gimpchannel-select.h"
 #include "gimpchannel-combine.h"
-#include "gimpimage-contiguous-region.h"
+#include "gimppickable.h"
+#include "gimppickable-contiguous-region.h"
 #include "gimpscanconvert.h"
 
 #include "vectors/gimpstroke.h"
@@ -498,25 +499,26 @@ gimp_channel_select_fuzzy (GimpChannel         *channel,
                            gdouble              feather_radius_x,
                            gdouble              feather_radius_y)
 {
-  GimpItem   *item;
-  GeglBuffer *add_on;
-  gint        add_on_x = 0;
-  gint        add_on_y = 0;
+  GimpPickable *pickable;
+  GeglBuffer   *add_on;
+  gint          add_on_x = 0;
+  gint          add_on_y = 0;
 
   g_return_if_fail (GIMP_IS_CHANNEL (channel));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
 
-  item = GIMP_ITEM (channel);
+  if (sample_merged)
+    pickable = GIMP_PICKABLE (gimp_item_get_image (GIMP_ITEM (drawable)));
+  else
+    pickable = GIMP_PICKABLE (drawable);
 
-  add_on = gimp_image_contiguous_region_by_seed (gimp_item_get_image (item),
-                                                 drawable,
-                                                 sample_merged,
-                                                 antialias,
-                                                 threshold,
-                                                 select_transparent,
-                                                 select_criterion,
-                                                 x, y);
+  add_on = gimp_pickable_contiguous_region_by_seed (pickable,
+                                                    antialias,
+                                                    threshold,
+                                                    select_transparent,
+                                                    select_criterion,
+                                                    x, y);
 
   if (! sample_merged)
     gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
@@ -544,26 +546,27 @@ gimp_channel_select_by_color (GimpChannel         *channel,
                               gdouble              feather_radius_x,
                               gdouble              feather_radius_y)
 {
-  GimpItem   *item;
-  GeglBuffer *add_on;
-  gint        add_on_x = 0;
-  gint        add_on_y = 0;
+  GimpPickable *pickable;
+  GeglBuffer   *add_on;
+  gint          add_on_x = 0;
+  gint          add_on_y = 0;
 
   g_return_if_fail (GIMP_IS_CHANNEL (channel));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (color != NULL);
 
-  item = GIMP_ITEM (channel);
-
-  add_on = gimp_image_contiguous_region_by_color (gimp_item_get_image (item),
-                                                  drawable,
-                                                  sample_merged,
-                                                  antialias,
-                                                  threshold,
-                                                  select_transparent,
-                                                  select_criterion,
-                                                  color);
+  if (sample_merged)
+    pickable = GIMP_PICKABLE (gimp_item_get_image (GIMP_ITEM (drawable)));
+  else
+    pickable = GIMP_PICKABLE (drawable);
+
+  add_on = gimp_pickable_contiguous_region_by_color (pickable,
+                                                     antialias,
+                                                     threshold,
+                                                     select_transparent,
+                                                     select_criterion,
+                                                     color);
 
   if (! sample_merged)
     gimp_item_get_offset (GIMP_ITEM (drawable), &add_on_x, &add_on_y);
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index 13c7ba9..80105a6 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -39,8 +39,9 @@
 #include "gimpdrawable-bucket-fill.h"
 #include "gimperror.h"
 #include "gimpimage.h"
-#include "gimpimage-contiguous-region.h"
 #include "gimppattern.h"
+#include "gimppickable.h"
+#include "gimppickable-contiguous-region.h"
 
 #include "gimp-intl.h"
 
@@ -136,13 +137,14 @@ gimp_drawable_bucket_fill_internal (GimpDrawable        *drawable,
                                     const GimpRGB       *color,
                                     GimpPattern         *pattern)
 {
-  GimpImage   *image;
-  GeglBuffer  *buffer;
-  GeglBuffer  *mask_buffer;
-  gint         x1, y1, x2, y2;
-  gint         mask_offset_x = 0;
-  gint         mask_offset_y = 0;
-  gboolean     selection;
+  GimpImage    *image;
+  GimpPickable *pickable;
+  GeglBuffer   *buffer;
+  GeglBuffer   *mask_buffer;
+  gint          x1, y1, x2, y2;
+  gint          mask_offset_x = 0;
+  gint          mask_offset_y = 0;
+  gboolean      selection;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
@@ -160,18 +162,22 @@ gimp_drawable_bucket_fill_internal (GimpDrawable        *drawable,
 
   gimp_set_busy (image->gimp);
 
+  if (sample_merged)
+    pickable = GIMP_PICKABLE (image);
+  else
+    pickable = GIMP_PICKABLE (drawable);
+
   /*  Do a seed bucket fill...To do this, calculate a new
    *  contiguous region. If there is a selection, calculate the
    *  intersection of this region with the existing selection.
    */
-  mask_buffer = gimp_image_contiguous_region_by_seed (image, drawable,
-                                                      sample_merged,
-                                                      TRUE,
-                                                      threshold,
-                                                      fill_transparent,
-                                                      fill_criterion,
-                                                      (gint) x,
-                                                      (gint) y);
+  mask_buffer = gimp_pickable_contiguous_region_by_seed (pickable,
+                                                         TRUE,
+                                                         threshold,
+                                                         fill_transparent,
+                                                         fill_criterion,
+                                                         (gint) x,
+                                                         (gint) y);
 
   if (selection)
     {
diff --git a/app/core/gimpimage-contiguous-region.c b/app/core/gimppickable-contiguous-region.c
similarity index 88%
rename from app/core/gimpimage-contiguous-region.c
rename to app/core/gimppickable-contiguous-region.c
index 7c19796..05d2c6b 100644
--- a/app/core/gimpimage-contiguous-region.c
+++ b/app/core/gimppickable-contiguous-region.c
@@ -30,10 +30,8 @@
 
 #include "gegl/gimp-babl.h"
 
-#include "gimpdrawable.h"
-#include "gimpimage.h"
-#include "gimpimage-contiguous-region.h"
 #include "gimppickable.h"
+#include "gimppickable-contiguous-region.h"
 
 
 /*  local function prototypes  */
@@ -82,31 +80,22 @@ static void find_contiguous_region_helper (GeglBuffer          *src_buffer,
 /*  public functions  */
 
 GeglBuffer *
-gimp_image_contiguous_region_by_seed (GimpImage           *image,
-                                      GimpDrawable        *drawable,
-                                      gboolean             sample_merged,
-                                      gboolean             antialias,
-                                      gfloat               threshold,
-                                      gboolean             select_transparent,
-                                      GimpSelectCriterion  select_criterion,
-                                      gint                 x,
-                                      gint                 y)
+gimp_pickable_contiguous_region_by_seed (GimpPickable        *pickable,
+                                         gboolean             antialias,
+                                         gfloat               threshold,
+                                         gboolean             select_transparent,
+                                         GimpSelectCriterion  select_criterion,
+                                         gint                 x,
+                                         gint                 y)
 {
-  GimpPickable *pickable;
-  GeglBuffer   *src_buffer;
-  GeglBuffer   *mask_buffer;
-  const Babl   *format;
-  gint          n_components;
-  gboolean      has_alpha;
-  gfloat        start_col[MAX_CHANNELS];
-
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
-  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
-
-  if (sample_merged)
-    pickable = GIMP_PICKABLE (image);
-  else
-    pickable = GIMP_PICKABLE (drawable);
+  GeglBuffer *src_buffer;
+  GeglBuffer *mask_buffer;
+  const Babl *format;
+  gint        n_components;
+  gboolean    has_alpha;
+  gfloat      start_col[MAX_CHANNELS];
+
+  g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
 
   gimp_pickable_flush (pickable);
 
@@ -147,23 +136,20 @@ gimp_image_contiguous_region_by_seed (GimpImage           *image,
 }
 
 GeglBuffer *
-gimp_image_contiguous_region_by_color (GimpImage            *image,
-                                       GimpDrawable         *drawable,
-                                       gboolean              sample_merged,
-                                       gboolean              antialias,
-                                       gfloat                threshold,
-                                       gboolean              select_transparent,
-                                       GimpSelectCriterion   select_criterion,
-                                       const GimpRGB        *color)
+gimp_pickable_contiguous_region_by_color (GimpPickable        *pickable,
+                                          gboolean             antialias,
+                                          gfloat               threshold,
+                                          gboolean             select_transparent,
+                                          GimpSelectCriterion  select_criterion,
+                                          const GimpRGB       *color)
 {
-  /*  Scan over the image's active layer, finding pixels within the
+  /*  Scan over the pickable's active layer, finding pixels within the
    *  specified threshold from the given R, G, & B values.  If
    *  antialiasing is on, use the same antialiasing scheme as in
-   *  fuzzy_select.  Modify the image's mask to reflect the
+   *  fuzzy_select.  Modify the pickable's mask to reflect the
    *  additional selection
    */
   GeglBufferIterator *iter;
-  GimpPickable       *pickable;
   GeglBuffer         *src_buffer;
   GeglBuffer         *mask_buffer;
   const Babl         *format;
@@ -171,15 +157,9 @@ gimp_image_contiguous_region_by_color (GimpImage            *image,
   gboolean            has_alpha;
   gfloat              start_col[MAX_CHANNELS];
 
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
-  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
+  g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
   g_return_val_if_fail (color != NULL, NULL);
 
-  if (sample_merged)
-    pickable = GIMP_PICKABLE (image);
-  else
-    pickable = GIMP_PICKABLE (drawable);
-
   gimp_pickable_flush (pickable);
 
   src_buffer = gimp_pickable_get_buffer (pickable);
diff --git a/app/core/gimppickable-contiguous-region.h b/app/core/gimppickable-contiguous-region.h
new file mode 100644
index 0000000..f5e5a1e
--- /dev/null
+++ b/app/core/gimppickable-contiguous-region.h
@@ -0,0 +1,38 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_PICKABLE_CONTIGUOUS_REGION_H__
+#define __GIMP_PICKABLE_CONTIGUOUS_REGION_H__
+
+
+GeglBuffer * gimp_pickable_contiguous_region_by_seed  (GimpPickable           *pickable,
+                                                       gboolean             antialias,
+                                                       gfloat               threshold,
+                                                       gboolean             select_transparent,
+                                                       GimpSelectCriterion  select_criterion,
+                                                       gint                 x,
+                                                       gint                 y);
+
+GeglBuffer * gimp_pickable_contiguous_region_by_color (GimpPickable           *pickable,
+                                                       gboolean             antialias,
+                                                       gfloat               threshold,
+                                                       gboolean             select_transparent,
+                                                       GimpSelectCriterion  select_criterion,
+                                                       const GimpRGB       *color);
+
+
+#endif  /*  __GIMP_PICKABLE_CONTIGUOUS_REGION_H__ */
diff --git a/app/tools/gimpbycolorselecttool.c b/app/tools/gimpbycolorselecttool.c
index 7ccd586..61a0df3 100644
--- a/app/tools/gimpbycolorselecttool.c
+++ b/app/tools/gimpbycolorselecttool.c
@@ -30,9 +30,9 @@
 #include "tools-types.h"
 
 #include "core/gimpimage.h"
-#include "core/gimpimage-contiguous-region.h"
 #include "core/gimpitem.h"
 #include "core/gimppickable.h"
+#include "core/gimppickable-contiguous-region.h"
 
 #include "widgets/gimphelp-ids.h"
 
@@ -126,13 +126,12 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
   gimp_pickable_flush (pickable);
 
   if (gimp_pickable_get_color_at (pickable, x, y, &color))
-    return gimp_image_contiguous_region_by_color (image, drawable,
-                                                  options->sample_merged,
-                                                  sel_options->antialias,
-                                                  options->threshold / 255.0,
-                                                  options->select_transparent,
-                                                  options->select_criterion,
-                                                  &color);
+    return gimp_pickable_contiguous_region_by_color (pickable,
+                                                     sel_options->antialias,
+                                                     options->threshold / 255.0,
+                                                     options->select_transparent,
+                                                     options->select_criterion,
+                                                     &color);
 
   return NULL;
 }
diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c
index 89f555b..3af6f2c 100644
--- a/app/tools/gimpfuzzyselecttool.c
+++ b/app/tools/gimpfuzzyselecttool.c
@@ -29,8 +29,9 @@
 #include "tools-types.h"
 
 #include "core/gimpimage.h"
-#include "core/gimpimage-contiguous-region.h"
 #include "core/gimpitem.h"
+#include "core/gimppickable.h"
+#include "core/gimppickable-contiguous-region.h"
 
 #include "widgets/gimphelp-ids.h"
 
@@ -99,6 +100,7 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
   GimpRegionSelectOptions *options     = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
   GimpImage               *image       = gimp_display_get_image (display);
   GimpDrawable            *drawable    = gimp_image_get_active_drawable (image);
+  GimpPickable            *pickable;
   gint                     x, y;
 
   x = region_select->x;
@@ -112,13 +114,18 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
 
       x -= off_x;
       y -= off_y;
+
+      pickable = GIMP_PICKABLE (drawable);
+    }
+  else
+    {
+      pickable = GIMP_PICKABLE (image);
     }
 
-  return gimp_image_contiguous_region_by_seed (image, drawable,
-                                               options->sample_merged,
-                                               sel_options->antialias,
-                                               options->threshold / 255.0,
-                                               options->select_transparent,
-                                               options->select_criterion,
-                                               x, y);
+  return gimp_pickable_contiguous_region_by_seed (pickable,
+                                                  sel_options->antialias,
+                                                  options->threshold / 255.0,
+                                                  options->select_transparent,
+                                                  options->select_criterion,
+                                                  x, y);
 }


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