[gimp] app: remove the old rendering increments from struct GimpDisplayShell



commit 810bb1894941e07fccade0bd90d9bf3b0dd2a092
Author: Michael Natterer <mitch gimp org>
Date:   Thu Apr 18 02:10:38 2013 +0200

    app: remove the old rendering increments from struct GimpDisplayShell
    
    and don't use them for (un)transforming integer coordinates. Everything
    seems to work fine, but this sort of change has caused off-by-one errors
    before, please review.

 app/display/gimpdisplayshell-transform.c | 28 ++++++++++++----------------
 app/display/gimpdisplayshell.c           | 20 --------------------
 app/display/gimpdisplayshell.h           |  5 -----
 3 files changed, 12 insertions(+), 41 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-transform.c b/app/display/gimpdisplayshell-transform.c
index 14bb347..d245a29 100644
--- a/app/display/gimpdisplayshell-transform.c
+++ b/app/display/gimpdisplayshell-transform.c
@@ -112,11 +112,8 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell,
   g_return_if_fail (nx != NULL);
   g_return_if_fail (ny != NULL);
 
-  tx = ((gint64) x * shell->x_src_dec) / shell->x_dest_inc;
-  ty = ((gint64) y * shell->y_src_dec) / shell->y_dest_inc;
-
-  tx -= shell->offset_x;
-  ty -= shell->offset_y;
+  tx = x * shell->scale_x - shell->offset_x;
+  ty = y * shell->scale_y - shell->offset_x;
 
   /* The projected coordinates might overflow a gint in the case of big
      images at high zoom levels, so we clamp them here to avoid problems.  */
@@ -153,17 +150,16 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell,
   g_return_if_fail (nx != NULL);
   g_return_if_fail (ny != NULL);
 
-  tx = (gint64) x + shell->offset_x;
-  ty = (gint64) y + shell->offset_y;
-
-  tx *= shell->x_dest_inc;
-  ty *= shell->y_dest_inc;
-
-  tx += round ? shell->x_dest_inc : shell->x_dest_inc >> 1;
-  ty += round ? shell->y_dest_inc : shell->y_dest_inc >> 1;
-
-  tx /= shell->x_src_dec;
-  ty /= shell->y_src_dec;
+  if (round)
+    {
+      tx = SIGNED_ROUND (((gint64) x + shell->offset_x) / shell->scale_x);
+      ty = SIGNED_ROUND (((gint64) y + shell->offset_y) / shell->scale_y);
+    }
+  else
+    {
+      tx = ((gint64) x + shell->offset_x) / shell->scale_x;
+      ty = ((gint64) y + shell->offset_y) / shell->scale_y;
+    }
 
   *nx = CLAMP (tx, G_MININT, G_MAXINT);
   *ny = CLAMP (ty, G_MININT, G_MAXINT);
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 5d17c7c..c25c290 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -294,10 +294,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
   shell->dot_for_dot = TRUE;
   shell->scale_x     = 1.0;
   shell->scale_y     = 1.0;
-  shell->x_dest_inc  = 1;
-  shell->y_dest_inc  = 1;
-  shell->x_src_dec   = 1;
-  shell->y_src_dec   = 1;
 
   gimp_display_shell_items_init (shell);
 
@@ -1412,27 +1408,11 @@ gimp_display_shell_scale_changed (GimpDisplayShell *shell)
                                                   gimp_zoom_model_get_factor (shell->zoom),
                                                   &shell->scale_x,
                                                   &shell->scale_y);
-
-      shell->x_dest_inc = gimp_image_get_width  (image);
-      shell->y_dest_inc = gimp_image_get_height (image);
-      shell->x_src_dec  = shell->scale_x * shell->x_dest_inc;
-      shell->y_src_dec  = shell->scale_y * shell->y_dest_inc;
-
-      if (shell->x_src_dec < 1)
-        shell->x_src_dec = 1;
-
-      if (shell->y_src_dec < 1)
-        shell->y_src_dec = 1;
     }
   else
     {
       shell->scale_x = 1.0;
       shell->scale_y = 1.0;
-
-      shell->x_dest_inc = 1;
-      shell->y_dest_inc = 1;
-      shell->x_src_dec  = 1;
-      shell->y_src_dec  = 1;
     }
 }
 
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index d0ca7eb..2204d2d 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -74,11 +74,6 @@ struct _GimpDisplayShell
   gdouble            monitor_yres;
   gboolean           dot_for_dot;      /*  ignore monitor resolution          */
 
-  gint               x_src_dec;        /*  increments for the bresenham style */
-  gint               y_src_dec;        /*  image --> display transformation   */
-  gint               x_dest_inc;
-  gint               y_dest_inc;
-
   GimpZoomModel     *zoom;
 
   gdouble            last_scale;       /*  scale used when reverting zoom     */


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