gimp r27664 - in branches/gimp-2-6: . app/display



Author: neo
Date: Sat Nov 15 18:41:58 2008
New Revision: 27664
URL: http://svn.gnome.org/viewvc/gimp?rev=27664&view=rev

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

 	Merged from trunk:

	* 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:
   branches/gimp-2-6/ChangeLog
   branches/gimp-2-6/app/display/gimpdisplayshell-draw.c
   branches/gimp-2-6/app/display/gimpdisplayshell-scale.c
   branches/gimp-2-6/app/display/gimpdisplayshell-scroll.c
   branches/gimp-2-6/app/display/gimpdisplayshell-scroll.h
   branches/gimp-2-6/app/display/gimpdisplayshell-transform.c

Modified: branches/gimp-2-6/app/display/gimpdisplayshell-draw.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-draw.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-draw.c	Sat Nov 15 18:41:58 2008
@@ -573,7 +573,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: branches/gimp-2-6/app/display/gimpdisplayshell-scale.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-scale.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-scale.c	Sat Nov 15 18:41:58 2008
@@ -168,8 +168,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;
@@ -217,28 +215,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),
@@ -475,7 +468,7 @@
                             GIMP_ZOOM_TO,
                             zoom_factor,
                             GIMP_ZOOM_FOCUS_BEST_GUESS);
-  
+
   gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
 }
 

Modified: branches/gimp-2-6/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-scroll.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-scroll.c	Sat Nov 15 18:41:58 2008
@@ -432,18 +432,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;
 }
 
 /**
@@ -466,30 +460,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;
 }
 
 /**
@@ -551,8 +525,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: branches/gimp-2-6/app/display/gimpdisplayshell-scroll.h
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-scroll.h	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-scroll.h	Sat Nov 15 18:41:58 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: branches/gimp-2-6/app/display/gimpdisplayshell-transform.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-transform.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-transform.c	Sat Nov 15 18:41:58 2008
@@ -49,9 +49,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);
@@ -61,12 +58,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;
 }
 
 /**
@@ -83,21 +76,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;
@@ -111,8 +97,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;
@@ -136,11 +120,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.  */
@@ -173,8 +154,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;
@@ -192,11 +171,8 @@
       gimp_item_offsets (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;
@@ -232,8 +208,6 @@
                                     gdouble                *ny,
                                     gboolean                use_offsets)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
   gint offset_x = 0;
   gint offset_y = 0;
 
@@ -249,12 +223,8 @@
       gimp_item_offsets (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;
 }
 
 /**
@@ -279,8 +249,6 @@
                                      gdouble                *ny,
                                      gboolean                use_offsets)
 {
-  gint scaled_viewport_offset_x;
-  gint scaled_viewport_offset_y;
   gint offset_x = 0;
   gint offset_y = 0;
 
@@ -296,12 +264,8 @@
       gimp_item_offsets (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;
 }
 
 /**
@@ -339,21 +303,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);
     }
 }
@@ -393,21 +351,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);
     }
 }
@@ -447,8 +399,6 @@
 
   for (i = 0; i < n_segs ; i++)
     {
-      gint   scaled_viewport_offset_x;
-      gint   scaled_viewport_offset_y;
       gint64 x1, x2;
       gint64 y1, y2;
 
@@ -462,18 +412,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]