From 47c39d6c97c6327fa651f956bc0f698d6605e7c2 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 13 Nov 2008 23:16:11 +0000 Subject: [PATCH] removed function gimp_display_shell_scroll_get_scaled_viewport_offset() as 2008-11-14 Sven Neumann * 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. svn path=/trunk/; revision=27644 --- ChangeLog | 12 +++ app/display/gimpdisplayshell-draw.c | 4 +- app/display/gimpdisplayshell-scale.c | 25 +++--- app/display/gimpdisplayshell-scroll.c | 46 +++-------- app/display/gimpdisplayshell-scroll.h | 3 - app/display/gimpdisplayshell-transform.c | 98 +++++------------------- 6 files changed, 54 insertions(+), 134 deletions(-) diff --git a/ChangeLog b/ChangeLog index a03495d5c8..75532d1ac0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-11-14 Sven Neumann + + * 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. + 2008-11-14 Sven Neumann * app/display/gimpdisplayshell-preview.c diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 2fc71c7bdb..f011f5ddbb 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -574,7 +574,9 @@ gimp_display_shell_draw_area (const GimpDisplayShell *shell, 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 diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index e7c42ec357..b28199178d 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -164,8 +164,6 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) 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 @@ gimp_display_shell_scale_update_rulers (GimpDisplayShell *shell) /* 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_display_shell_scale_fit_in (GimpDisplayShell *shell) GIMP_ZOOM_TO, zoom_factor, GIMP_ZOOM_FOCUS_BEST_GUESS); - + gimp_display_shell_scroll_center_image (shell, TRUE, TRUE); } diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c index 391f651063..5033f4ae85 100644 --- a/app/display/gimpdisplayshell-scroll.c +++ b/app/display/gimpdisplayshell-scroll.c @@ -433,18 +433,12 @@ gimp_display_shell_scroll_get_scaled_viewport (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_scroll_get_viewport (const GimpDisplayShell *shell, { 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 @@ gimp_display_shell_scroll_get_render_start_offset (const GimpDisplayShell *shell { 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); } /** diff --git a/app/display/gimpdisplayshell-scroll.h b/app/display/gimpdisplayshell-scroll.h index 4e172dbb05..28af91bce6 100644 --- a/app/display/gimpdisplayshell-scroll.h +++ b/app/display/gimpdisplayshell-scroll.h @@ -53,9 +53,6 @@ void gimp_display_shell_scroll_get_viewport (const GimpDisplaySh 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); diff --git a/app/display/gimpdisplayshell-transform.c b/app/display/gimpdisplayshell-transform.c index 53808b8b17..8edd3b81e1 100644 --- a/app/display/gimpdisplayshell-transform.c +++ b/app/display/gimpdisplayshell-transform.c @@ -50,9 +50,6 @@ gimp_display_shell_transform_coordinate (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_coordinate (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_untransform_coordinate (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_xy (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_untransform_xy (const GimpDisplayShell *shell, 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_display_shell_untransform_xy (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_xy_f (const GimpDisplayShell *shell, 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_display_shell_transform_xy_f (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_untransform_xy_f (const GimpDisplayShell *shell, 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_display_shell_untransform_xy_f (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_points (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_coords (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_segments (const GimpDisplayShell *shell, 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 @@ gimp_display_shell_transform_segments (const GimpDisplayShell *shell, 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); } }