[gimp] app: undo some of the previous refactorings and keep using GdkSegment



commit cd192adf09a8423aa0d2a2d10db764331cef11f5
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 25 21:21:16 2010 +0200

    app: undo some of the previous refactorings and keep using GdkSegment
    
    It's not going to be deprecated, so there is no harm in using it; get
    rid of all the added _old() functions too.

 app/display/gimpdisplayshell-draw.c      |    2 +-
 app/display/gimpdisplayshell-draw.h      |    2 +-
 app/display/gimpdisplayshell-selection.c |   65 ++++-------------------------
 app/display/gimpdisplayshell-transform.c |   60 +---------------------------
 app/display/gimpdisplayshell-transform.h |    7 +---
 app/tools/gimpregionselecttool.c         |    4 +-
 6 files changed, 15 insertions(+), 125 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 5d4a516..cfd9f88 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -536,7 +536,7 @@ void
 gimp_display_shell_draw_layer_boundary (GimpDisplayShell *shell,
                                         cairo_t          *cr,
                                         GimpDrawable     *drawable,
-                                        BoundSeg         *segs,
+                                        GdkSegment       *segs,
                                         gint              n_segs)
 {
   gint i;
diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h
index 6bb8bd6..d9d8199 100644
--- a/app/display/gimpdisplayshell-draw.h
+++ b/app/display/gimpdisplayshell-draw.h
@@ -51,7 +51,7 @@ void   gimp_display_shell_draw_sample_points         (GimpDisplayShell   *shell,
 void   gimp_display_shell_draw_layer_boundary        (GimpDisplayShell   *shell,
                                                       cairo_t            *cr,
                                                       GimpDrawable       *drawable,
-                                                      BoundSeg           *segs,
+                                                      GdkSegment         *segs,
                                                       gint                n_segs);
 void   gimp_display_shell_draw_vector                (GimpDisplayShell   *shell,
                                                       GimpVectors        *vectors);
diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c
index 193f9e5..4741040 100644
--- a/app/display/gimpdisplayshell-selection.c
+++ b/app/display/gimpdisplayshell-selection.c
@@ -57,7 +57,7 @@ struct _Selection
   GdkSegment       *segs_out;         /*  gdk segments of area boundary     */
   gint              n_segs_out;       /*  number of segments in segs_out    */
 
-  BoundSeg         *segs_layer;       /*  segments of layer boundary        */
+  GdkSegment       *segs_layer;       /*  segments of layer boundary        */
   gint              n_segs_layer;     /*  number of segments in segs_layer  */
 
   guint             index;            /*  index of current stipple pattern  */
@@ -91,13 +91,9 @@ static void      selection_add_point      (GdkPoint       *points[8],
                                            gint            y);
 static void      selection_render_points  (Selection      *selection);
 
-static void  selection_transform_segs_old (Selection      *selection,
-                                           const BoundSeg *src_segs,
-                                           GdkSegment     *dest_segs,
-                                           gint            n_segs);
 static void      selection_transform_segs (Selection      *selection,
                                            const BoundSeg *src_segs,
-                                           BoundSeg       *dest_segs,
+                                           GdkSegment     *dest_segs,
                                            gint            n_segs);
 static void      selection_generate_segs  (Selection      *selection);
 static void      selection_free_segs      (Selection      *selection);
@@ -574,52 +570,9 @@ selection_render_points (Selection *selection)
 }
 
 static void
-selection_transform_segs_old (Selection      *selection,
-                              const BoundSeg *src_segs,
-                              GdkSegment     *dest_segs,
-                              gint            n_segs)
-{
-  gint xclamp = selection->shell->disp_width + 1;
-  gint yclamp = selection->shell->disp_height + 1;
-  gint i;
-
-  gimp_display_shell_transform_segments_old (selection->shell,
-                                             src_segs, dest_segs, n_segs, FALSE);
-
-  for (i = 0; i < n_segs; i++)
-    {
-      dest_segs[i].x1 = CLAMP (dest_segs[i].x1, -1, xclamp);
-      dest_segs[i].y1 = CLAMP (dest_segs[i].y1, -1, yclamp);
-
-      dest_segs[i].x2 = CLAMP (dest_segs[i].x2, -1, xclamp);
-      dest_segs[i].y2 = CLAMP (dest_segs[i].y2, -1, yclamp);
-
-      /*  If this segment is a closing segment && the segments lie inside
-       *  the region, OR if this is an opening segment and the segments
-       *  lie outside the region...
-       *  we need to transform it by one display pixel
-       */
-      if (!src_segs[i].open)
-        {
-          /*  If it is vertical  */
-          if (dest_segs[i].x1 == dest_segs[i].x2)
-            {
-              dest_segs[i].x1 -= 1;
-              dest_segs[i].x2 -= 1;
-            }
-          else
-            {
-              dest_segs[i].y1 -= 1;
-              dest_segs[i].y2 -= 1;
-            }
-        }
-    }
-}
-
-static void
 selection_transform_segs (Selection      *selection,
                           const BoundSeg *src_segs,
-                          BoundSeg       *dest_segs,
+                          GdkSegment     *dest_segs,
                           gint            n_segs)
 {
   gint xclamp = selection->shell->disp_width + 1;
@@ -642,7 +595,7 @@ selection_transform_segs (Selection      *selection,
        *  lie outside the region...
        *  we need to transform it by one display pixel
        */
-      if (! dest_segs[i].open)
+      if (!src_segs[i].open)
         {
           /*  If it is vertical  */
           if (dest_segs[i].x1 == dest_segs[i].x2)
@@ -678,8 +631,8 @@ selection_generate_segs (Selection *selection)
   if (selection->n_segs_in)
     {
       selection->segs_in = g_new (GdkSegment, selection->n_segs_in);
-      selection_transform_segs_old (selection, segs_in,
-                                    selection->segs_in, selection->n_segs_in);
+      selection_transform_segs (selection, segs_in,
+                                selection->segs_in, selection->n_segs_in);
 
 #ifdef USE_DRAWPOINTS
       selection_render_points (selection);
@@ -694,8 +647,8 @@ selection_generate_segs (Selection *selection)
   if (selection->n_segs_out)
     {
       selection->segs_out = g_new (GdkSegment, selection->n_segs_out);
-      selection_transform_segs_old (selection, segs_out,
-                                    selection->segs_out, selection->n_segs_out);
+      selection_transform_segs (selection, segs_out,
+                                selection->segs_out, selection->n_segs_out);
     }
   else
     {
@@ -712,7 +665,7 @@ selection_generate_segs (Selection *selection)
 
       if (selection->n_segs_layer)
         {
-          selection->segs_layer = g_new (BoundSeg, selection->n_segs_layer);
+          selection->segs_layer = g_new (GdkSegment, selection->n_segs_layer);
 
           selection_transform_segs (selection,
                                     segs,
diff --git a/app/display/gimpdisplayshell-transform.c b/app/display/gimpdisplayshell-transform.c
index f78be28..88befda 100644
--- a/app/display/gimpdisplayshell-transform.c
+++ b/app/display/gimpdisplayshell-transform.c
@@ -376,61 +376,6 @@ gimp_display_shell_transform_coords (const GimpDisplayShell *shell,
 }
 
 /**
- * gimp_display_shell_transform_segments_old:
- * @shell:       a #GimpDisplayShell
- * @src_segs:    array of segments in image coordinates
- * @dest_segs:   returns the corresponding segments in display coordinates
- * @n_segs:      number of segments
- * @use_offsets: if %TRUE, the source coordinates are in the coordinate
- *               system of the active drawable instead of the image
- *
- * Transforms from image coordinates to display coordinates, so that
- * objects can be rendered at the correct points on the display.
- **/
-void
-gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
-                                           const BoundSeg         *src_segs,
-                                           GdkSegment             *dest_segs,
-                                           gint                    n_segs,
-                                           gboolean                use_offsets)
-{
-  gint offset_x = 0;
-  gint offset_y = 0;
-  gint i;
-
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  if (use_offsets)
-    {
-      GimpImage *image = gimp_display_get_image (shell->display);
-      GimpItem  *item  = GIMP_ITEM (gimp_image_get_active_drawable (image));
-
-      gimp_item_get_offset (item, &offset_x, &offset_y);
-    }
-
-  for (i = 0; i < n_segs ; i++)
-    {
-      gint64 x1, x2;
-      gint64 y1, y2;
-
-      x1 = src_segs[i].x1 + offset_x;
-      x2 = src_segs[i].x2 + offset_x;
-      y1 = src_segs[i].y1 + offset_y;
-      y2 = src_segs[i].y2 + offset_y;
-
-      x1 = (x1 * shell->x_src_dec) / shell->x_dest_inc;
-      x2 = (x2 * shell->x_src_dec) / shell->x_dest_inc;
-      y1 = (y1 * shell->y_src_dec) / shell->y_dest_inc;
-      y2 = (y2 * shell->y_src_dec) / shell->y_dest_inc;
-
-      dest_segs[i].x1 = CLAMP (x1 - shell->offset_x, G_MININT, G_MAXINT);
-      dest_segs[i].x2 = CLAMP (x2 - shell->offset_x, G_MININT, G_MAXINT);
-      dest_segs[i].y1 = CLAMP (y1 - shell->offset_y, G_MININT, G_MAXINT);
-      dest_segs[i].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
-    }
-}
-
-/**
  * gimp_display_shell_transform_segments:
  * @shell:       a #GimpDisplayShell
  * @src_segs:    array of segments in image coordinates
@@ -445,7 +390,7 @@ gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
 void
 gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
                                        const BoundSeg         *src_segs,
-                                       BoundSeg               *dest_segs,
+                                       GdkSegment             *dest_segs,
                                        gint                    n_segs,
                                        gboolean                use_offsets)
 {
@@ -482,9 +427,6 @@ gimp_display_shell_transform_segments (const GimpDisplayShell *shell,
       dest_segs[i].x2 = CLAMP (x2 - shell->offset_x, G_MININT, G_MAXINT);
       dest_segs[i].y1 = CLAMP (y1 - shell->offset_y, G_MININT, G_MAXINT);
       dest_segs[i].y2 = CLAMP (y2 - shell->offset_y, G_MININT, G_MAXINT);
-
-      dest_segs[i].open    = src_segs[i].open;
-      dest_segs[i].visited = FALSE;
     }
 }
 
diff --git a/app/display/gimpdisplayshell-transform.h b/app/display/gimpdisplayshell-transform.h
index 5a4b3e0..a7c9f45 100644
--- a/app/display/gimpdisplayshell-transform.h
+++ b/app/display/gimpdisplayshell-transform.h
@@ -63,14 +63,9 @@ void  gimp_display_shell_transform_coords       (const GimpDisplayShell *shell,
                                                  GdkPoint               *disp_coords,
                                                  gint                    n_coords,
                                                  gboolean                use_offsets);
-void  gimp_display_shell_transform_segments_old (const GimpDisplayShell *shell,
-                                                 const BoundSeg         *src_segs,
-                                                 GdkSegment             *dest_segs,
-                                                 gint                    n_segs,
-                                                 gboolean                use_offsets);
 void  gimp_display_shell_transform_segments     (const GimpDisplayShell *shell,
                                                  const BoundSeg         *src_segs,
-                                                 BoundSeg               *dest_segs,
+                                                 GdkSegment             *dest_segs,
                                                  gint                    n_segs,
                                                  gboolean                use_offsets);
 
diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c
index c96ed56..44b141b 100644
--- a/app/tools/gimpregionselecttool.c
+++ b/app/tools/gimpregionselecttool.c
@@ -383,8 +383,8 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
 
   segs = g_new (GdkSegment, *num_segs);
 
-  gimp_display_shell_transform_segments_old (shell, bsegs, segs, *num_segs,
-                                             ! options->sample_merged);
+  gimp_display_shell_transform_segments (shell, bsegs, segs, *num_segs,
+                                         ! options->sample_merged);
   g_free (bsegs);
 
   gimp_display_shell_unset_override_cursor (shell);



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