gimp r27644 - in trunk: . app/display



Author: neo
Date: Thu Nov 13 23:16:11 2008
New Revision: 27644
URL: http://svn.gnome.org/viewvc/gimp?rev=27644&view=rev

Log:
2008-11-14  Sven Neumann  <sven gimp org>

	* app/display/gimpdisplayshell-scroll.[ch]: removed function
	gimp_display_shell_scroll_get_scaled_viewport_offset() as it was
	only returning -shell->offset_x and -shell->offset_y and it
	started to show up in profiles.

	* app/display/gimpdisplayshell-draw.c
	* app/display/gimpdisplayshell-transform.c
	* app/display/gimpdisplayshell-scale.c: use the shell offsets
	directly.



Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplayshell-draw.c
   trunk/app/display/gimpdisplayshell-scale.c
   trunk/app/display/gimpdisplayshell-scroll.c
   trunk/app/display/gimpdisplayshell-scroll.h
   trunk/app/display/gimpdisplayshell-transform.c

Modified: trunk/app/display/gimpdisplayshell-draw.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-draw.c	(original)
+++ trunk/app/display/gimpdisplayshell-draw.c	Thu Nov 13 23:16:11 2008
@@ -574,7 +574,9 @@
   if (! shell->display->image)
     return;
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell, &sx, &sy);
+  sx = - shell->offset_x;
+  sy = - shell->offset_y;
+
   gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
 
   /*  check if the passed in area intersects with

Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c	(original)
+++ trunk/app/display/gimpdisplayshell-scale.c	Thu Nov 13 23:16:11 2008
@@ -164,8 +164,6 @@
   gdouble    vertical_lower;
   gdouble    vertical_upper;
   gdouble    vertical_max_size;
-  gint       scaled_viewport_offset_x;
-  gint       scaled_viewport_offset_y;
 
   if (! shell->display)
     return;
@@ -213,28 +211,23 @@
 
   /* Adjust due to scrolling */
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-
   if (image)
     {
-      horizontal_lower -= img2real (shell, TRUE,
+      horizontal_lower += img2real (shell, TRUE,
                                     FUNSCALEX (shell,
-                                               (gdouble) scaled_viewport_offset_x));
-      horizontal_upper -= img2real (shell, TRUE,
+                                               (gdouble) shell->offset_x));
+      horizontal_upper += img2real (shell, TRUE,
                                     FUNSCALEX (shell,
-                                               (gdouble) scaled_viewport_offset_x));
+                                               (gdouble) shell->offset_x));
 
-      vertical_lower   -= img2real (shell, FALSE,
+      vertical_lower   += img2real (shell, FALSE,
                                     FUNSCALEY (shell,
-                                               (gdouble) scaled_viewport_offset_y));
-      vertical_upper   -= img2real (shell, FALSE,
+                                               (gdouble) shell->offset_y));
+      vertical_upper   += img2real (shell, FALSE,
                                     FUNSCALEY (shell,
-                                               (gdouble) scaled_viewport_offset_y));
+                                               (gdouble) shell->offset_y));
     }
 
-
   /* Finally setup the actual rulers */
 
   gimp_ruler_set_range (GIMP_RULER (shell->hrule),
@@ -455,7 +448,7 @@
                             GIMP_ZOOM_TO,
                             zoom_factor,
                             GIMP_ZOOM_FOCUS_BEST_GUESS);
-  
+
   gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
 }
 

Modified: trunk/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.c	(original)
+++ trunk/app/display/gimpdisplayshell-scroll.c	Thu Nov 13 23:16:11 2008
@@ -433,18 +433,12 @@
                                                gint                   *w,
                                                gint                   *h)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
-
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-  if (x) *x = -scaled_viewport_offset_x;
-  if (y) *y = -scaled_viewport_offset_y;
-  if (w) *w =  shell->disp_width;
-  if (h) *h =  shell->disp_height;
+  *x = shell->offset_x;
+  *y = shell->offset_y;
+  *w = shell->disp_width;
+  *h = shell->disp_height;
 }
 
 /**
@@ -467,30 +461,10 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (x) *x = shell->offset_x    / shell->scale_x;
-  if (y) *y = shell->offset_y    / shell->scale_y;
-  if (w) *w = shell->disp_width  / shell->scale_x;
-  if (h) *h = shell->disp_height / shell->scale_y;
-}
-
-/**
- * gimp_display_shell_scroll_get_scaled_viewport_offset:
- * @shell:
- * @x:
- * @y:
- *
- * Gets the scaled image offset in viewport coordinates
- *
- **/
-void
-gimp_display_shell_scroll_get_scaled_viewport_offset (const GimpDisplayShell *shell,
-                                                      gint                   *x,
-                                                      gint                   *y)
-{
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  if (x) *x = -shell->offset_x;
-  if (y) *y = -shell->offset_y;
+  *x = shell->offset_x    / shell->scale_x;
+  *y = shell->offset_y    / shell->scale_y;
+  *w = shell->disp_width  / shell->scale_x;
+  *h = shell->disp_height / shell->scale_y;
 }
 
 /**
@@ -552,8 +526,8 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (offset_x) *offset_x = MAX (0, shell->offset_x);
-  if (offset_y) *offset_y = MAX (0, shell->offset_y);
+  *offset_x = MAX (0, shell->offset_x);
+  *offset_y = MAX (0, shell->offset_y);
 }
 
 /**

Modified: trunk/app/display/gimpdisplayshell-scroll.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.h	(original)
+++ trunk/app/display/gimpdisplayshell-scroll.h	Thu Nov 13 23:16:11 2008
@@ -53,9 +53,6 @@
                                                              gdouble                *y,
                                                              gdouble                *w,
                                                              gdouble                *h);
-void   gimp_display_shell_scroll_get_scaled_viewport_offset (const GimpDisplayShell *shell,
-                                                             gint                   *x,
-                                                             gint                   *y);
 void   gimp_display_shell_scroll_get_disp_offset            (const GimpDisplayShell *shell,
                                                              gint                   *disp_xoffset,
                                                              gint                   *disp_yoffset);

Modified: trunk/app/display/gimpdisplayshell-transform.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-transform.c	(original)
+++ trunk/app/display/gimpdisplayshell-transform.c	Thu Nov 13 23:16:11 2008
@@ -50,9 +50,6 @@
                                          GimpCoords             *image_coords,
                                          GimpCoords             *display_coords)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
-
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (image_coords != NULL);
   g_return_if_fail (display_coords != NULL);
@@ -62,12 +59,8 @@
   display_coords->x = SCALEX (shell, image_coords->x);
   display_coords->y = SCALEY (shell, image_coords->y);
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-
-  display_coords->x += scaled_viewport_offset_x;
-  display_coords->y += scaled_viewport_offset_y;
+  display_coords->x -= shell->offset_x;
+  display_coords->y -= shell->offset_y;
 }
 
 /**
@@ -84,21 +77,14 @@
                                            GimpCoords             *display_coords,
                                            GimpCoords             *image_coords)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
-
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (display_coords != NULL);
   g_return_if_fail (image_coords != NULL);
 
   *image_coords = *display_coords;
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-
-  image_coords->x = display_coords->x - scaled_viewport_offset_x;
-  image_coords->y = display_coords->y - scaled_viewport_offset_y;
+  image_coords->x = display_coords->x + shell->offset_x;
+  image_coords->y = display_coords->y + shell->offset_y;
 
   image_coords->x /= shell->scale_x;
   image_coords->y /= shell->scale_y;
@@ -112,8 +98,6 @@
                                  gint                   *ny,
                                  gboolean                use_offsets)
 {
-  gint   scaled_viewport_offset_x;
-  gint   scaled_viewport_offset_y;
   gint   offset_x = 0;
   gint   offset_y = 0;
   gint64 tx;
@@ -137,11 +121,8 @@
   tx = ((gint64) x * shell->x_src_dec) / shell->x_dest_inc;
   ty = ((gint64) y * shell->y_src_dec) / shell->y_dest_inc;
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-  tx += scaled_viewport_offset_x;
-  ty += scaled_viewport_offset_y;
+  tx -= shell->offset_x;
+  ty -= shell->offset_y;
 
   /* 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.  */
@@ -174,8 +155,6 @@
                                    gboolean                round,
                                    gboolean                use_offsets)
 {
-  gint   scaled_viewport_offset_x;
-  gint   scaled_viewport_offset_y;
   gint   offset_x = 0;
   gint   offset_y = 0;
   gint64 tx;
@@ -193,11 +172,8 @@
       gimp_item_get_offset (item, &offset_x, &offset_y);
     }
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-  tx = (gint64) x - scaled_viewport_offset_x;
-  ty = (gint64) y - scaled_viewport_offset_y;
+  tx = (gint64) x + shell->offset_x;
+  ty = (gint64) y + shell->offset_y;
 
   tx *= shell->x_dest_inc;
   ty *= shell->y_dest_inc;
@@ -233,8 +209,6 @@
                                     gdouble                *ny,
                                     gboolean                use_offsets)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
   gint offset_x = 0;
   gint offset_y = 0;
 
@@ -250,12 +224,8 @@
       gimp_item_get_offset (item, &offset_x, &offset_y);
     }
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-
-  *nx = SCALEX (shell, x + offset_x) + scaled_viewport_offset_x;
-  *ny = SCALEY (shell, y + offset_y) + scaled_viewport_offset_y;
+  *nx = SCALEX (shell, x + offset_x) - shell->offset_x;
+  *ny = SCALEY (shell, y + offset_y) - shell->offset_y;
 }
 
 /**
@@ -280,8 +250,6 @@
                                      gdouble                *ny,
                                      gboolean                use_offsets)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
   gint offset_x = 0;
   gint offset_y = 0;
 
@@ -297,12 +265,8 @@
       gimp_item_get_offset (item, &offset_x, &offset_y);
     }
 
-  gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                        &scaled_viewport_offset_x,
-                                                        &scaled_viewport_offset_y);
-
-  *nx = (x - scaled_viewport_offset_x) / shell->scale_x - offset_x;
-  *ny = (y - scaled_viewport_offset_y) / shell->scale_y - offset_y;
+  *nx = (x + shell->offset_x) / shell->scale_x - offset_x;
+  *ny = (y + shell->offset_y) / shell->scale_y - offset_y;
 }
 
 /**
@@ -340,21 +304,15 @@
 
   for (i = 0; i < n_points ; i++)
     {
-      gint    scaled_viewport_offset_x;
-      gint    scaled_viewport_offset_y;
       gdouble x = points[i].x + offset_x;
       gdouble y = points[i].y + offset_y;
 
       x = x * shell->x_src_dec / shell->x_dest_inc;
       y = y * shell->y_src_dec / shell->y_dest_inc;
 
-      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                            &scaled_viewport_offset_x,
-                                                            &scaled_viewport_offset_y);
-
-      coords[i].x = CLAMP (PROJ_ROUND64 (x) + scaled_viewport_offset_x,
+      coords[i].x = CLAMP (PROJ_ROUND64 (x) - shell->offset_x,
                            G_MININT, G_MAXINT);
-      coords[i].y = CLAMP (PROJ_ROUND64 (y) + scaled_viewport_offset_y,
+      coords[i].y = CLAMP (PROJ_ROUND64 (y) - shell->offset_y,
                            G_MININT, G_MAXINT);
     }
 }
@@ -394,21 +352,15 @@
 
   for (i = 0; i < n_coords ; i++)
     {
-      gint    scaled_viewport_offset_x;
-      gint    scaled_viewport_offset_y;
       gdouble x = image_coords[i].x + offset_x;
       gdouble y = image_coords[i].y + offset_y;
 
       x = x * shell->x_src_dec / shell->x_dest_inc;
       y = y * shell->y_src_dec / shell->y_dest_inc;
 
-      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                            &scaled_viewport_offset_x,
-                                                            &scaled_viewport_offset_y);
-
-      disp_coords[i].x = CLAMP (PROJ_ROUND64 (x) + scaled_viewport_offset_x,
+      disp_coords[i].x = CLAMP (PROJ_ROUND64 (x) - shell->offset_x,
                                 G_MININT, G_MAXINT);
-      disp_coords[i].y = CLAMP (PROJ_ROUND64 (y) + scaled_viewport_offset_y,
+      disp_coords[i].y = CLAMP (PROJ_ROUND64 (y) - shell->offset_y,
                                 G_MININT, G_MAXINT);
     }
 }
@@ -448,8 +400,6 @@
 
   for (i = 0; i < n_segs ; i++)
     {
-      gint   scaled_viewport_offset_x;
-      gint   scaled_viewport_offset_y;
       gint64 x1, x2;
       gint64 y1, y2;
 
@@ -463,18 +413,10 @@
       y1 = (y1 * shell->y_src_dec) / shell->y_dest_inc;
       y2 = (y2 * shell->y_src_dec) / shell->y_dest_inc;
 
-      gimp_display_shell_scroll_get_scaled_viewport_offset (shell,
-                                                            &scaled_viewport_offset_x,
-                                                            &scaled_viewport_offset_y);
-
-      dest_segs[i].x1 = CLAMP (x1 + scaled_viewport_offset_x,
-                               G_MININT, G_MAXINT);
-      dest_segs[i].x2 = CLAMP (x2 + scaled_viewport_offset_x,
-                               G_MININT, G_MAXINT);
-      dest_segs[i].y1 = CLAMP (y1 + scaled_viewport_offset_y,
-                               G_MININT, G_MAXINT);
-      dest_segs[i].y2 = CLAMP (y2 + scaled_viewport_offset_y,
-                               G_MININT, G_MAXINT);
+      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);
     }
 }
 



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