gimp r26146 - in trunk: . app/display
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26146 - in trunk: . app/display
- Date: Sat, 12 Jul 2008 07:00:46 +0000 (UTC)
Author: martinn
Date: Sat Jul 12 07:00:46 2008
New Revision: 26146
URL: http://svn.gnome.org/viewvc/gimp?rev=26146&view=rev
Log:
2008-07-12 Martin Nordholts <martinn svn gnome org>
* app/display/gimpdisplayshell.c: Kill disp_[xy]offset! We now
keep store that information by using negative values in
offset_[xy].
* app/display/gimpdisplayshell-scroll.[ch]
(gimp_display_shell_scroll_clamp_offsets)
(gimp_display_shell_get_scaled_image_viewport_offset): Adjust
accordingly to preserve current behaviour.
(gimp_display_shell_get_disp_offset): New function to get the old
disp_[xy]offset based on the new offset_[xy].
(gimp_display_shell_get_render_start_offset): New function to get
th old offset_[xy] based on the new offset_[xy].
* app/display/gimpdisplayshell-draw.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-render.c: Get rid of
disp_[xy]offset and use
gimp_display_shell_get_render_start_offset() and
gimp_display_shell_get_disp_offset() instead.
Modified:
trunk/ChangeLog
trunk/app/display/gimpdisplayshell-draw.c
trunk/app/display/gimpdisplayshell-render.c
trunk/app/display/gimpdisplayshell-scale.c
trunk/app/display/gimpdisplayshell-scroll.c
trunk/app/display/gimpdisplayshell-scroll.h
trunk/app/display/gimpdisplayshell.c
trunk/app/display/gimpdisplayshell.h
Modified: trunk/app/display/gimpdisplayshell-draw.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-draw.c (original)
+++ trunk/app/display/gimpdisplayshell-draw.c Sat Jul 12 07:00:46 2008
@@ -572,14 +572,19 @@
{
for (j = x; j < x2; j += GIMP_DISPLAY_RENDER_BUF_WIDTH)
{
+ gint disp_xoffset, disp_yoffset;
gint dx, dy;
dx = MIN (x2 - j, GIMP_DISPLAY_RENDER_BUF_WIDTH);
dy = MIN (y2 - i, GIMP_DISPLAY_RENDER_BUF_HEIGHT);
+ gimp_display_shell_get_disp_offset (shell,
+ &disp_xoffset,
+ &disp_yoffset);
+
gimp_display_shell_render (shell,
- j - shell->disp_xoffset,
- i - shell->disp_yoffset,
+ j - disp_xoffset,
+ i - disp_yoffset,
dx, dy,
shell->highlight ? &rect : NULL);
}
Modified: trunk/app/display/gimpdisplayshell-render.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-render.c (original)
+++ trunk/app/display/gimpdisplayshell-render.c Sat Jul 12 07:00:46 2008
@@ -44,6 +44,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-filter.h"
#include "gimpdisplayshell-render.h"
+#include "gimpdisplayshell-scroll.h"
#define GIMP_DISPLAY_ZOOM_FAST (1 << 0) /* use the fastest possible code
path trading quality for speed
@@ -223,6 +224,8 @@
GimpImage *image;
RenderInfo info;
GimpImageType type;
+ gint offset_x;
+ gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (w > 0 && h > 0);
@@ -230,13 +233,15 @@
image = shell->display->image;
projection = image->projection;
+ gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
+
/* Initialize RenderInfo with values that don't change during the
* call of this function.
*/
info.shell = shell;
- info.x = x + shell->offset_x;
- info.y = y + shell->offset_y;
+ info.x = x + offset_x;
+ info.y = y + offset_y;
info.w = w;
info.h = h;
@@ -310,12 +315,20 @@
}
/* put it to the screen */
- gimp_canvas_draw_rgb (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_RENDER,
- x + shell->disp_xoffset, y + shell->disp_yoffset,
+ {
+ gint disp_xoffset, disp_yoffset;
+ gint offset_x, offset_y;
+
+ gimp_display_shell_get_disp_offset (shell, &disp_xoffset, &disp_yoffset);
+ gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
+
+ gimp_canvas_draw_rgb (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_RENDER,
+ x + disp_xoffset, y + disp_yoffset,
w, h,
shell->render_buf,
3 * GIMP_DISPLAY_RENDER_BUF_WIDTH,
- shell->offset_x, shell->offset_y);
+ offset_x, offset_y);
+ }
}
@@ -338,16 +351,20 @@
{
guchar *buf = shell->render_buf;
GdkRectangle rect;
+ gint offset_x;
+ gint offset_y;
+
+ gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
- rect.x = shell->offset_x + x;
- rect.y = shell->offset_y + y;
+ rect.x = x + offset_x;
+ rect.y = y + offset_y;
rect.width = w;
rect.height = h;
if (gdk_rectangle_intersect (highlight, &rect, &rect))
{
- rect.x -= shell->offset_x + x;
- rect.y -= shell->offset_y + y;
+ rect.x -= x + offset_x;
+ rect.y -= y + offset_y;
for (y = 0; y < rect.y; y++)
{
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Sat Jul 12 07:00:46 2008
@@ -92,6 +92,8 @@
gfloat sx, sy;
gint image_width;
gint image_height;
+ gint offset_x;
+ gint offset_y;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -117,13 +119,15 @@
sy = image_height;
}
- shell->hsbdata->value = shell->offset_x;
+ gimp_display_shell_get_render_start_offset (shell, &offset_x, &offset_y);
+
+ shell->hsbdata->value = offset_x;
shell->hsbdata->upper = sx;
shell->hsbdata->page_size = MIN (sx, shell->disp_width);
shell->hsbdata->page_increment = shell->disp_width / 2;
shell->hsbdata->step_increment = shell->scale_x;
- shell->vsbdata->value = shell->offset_y;
+ shell->vsbdata->value = offset_y;
shell->vsbdata->upper = sy;
shell->vsbdata->page_size = MIN (sy, shell->disp_height);
shell->vsbdata->page_increment = shell->disp_height / 2;
@@ -167,29 +171,6 @@
}
- /* Center the image if its scaled width/height fits within the
- * viewport
- */
-
- if (image && sx < shell->disp_width)
- {
- shell->disp_xoffset = (shell->disp_width - sx) / 2;
- }
- else
- {
- shell->disp_xoffset = 0;
- }
-
- if (image && sy < shell->disp_height)
- {
- shell->disp_yoffset = (shell->disp_height - sy) / 2;
- }
- else
- {
- shell->disp_yoffset = 0;
- }
-
-
/* Adjust due to scrolling */
gimp_display_shell_get_scaled_image_viewport_offset (shell,
Modified: trunk/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.c (original)
+++ trunk/app/display/gimpdisplayshell-scroll.c Sat Jul 12 07:00:46 2008
@@ -121,11 +121,29 @@
sw = SCALEX (shell, gimp_image_get_width (shell->display->image));
sh = SCALEY (shell, gimp_image_get_height (shell->display->image));
- shell->offset_x = CLAMP (shell->offset_x, 0,
- MAX (sw - shell->disp_width, 0));
+ if (shell->disp_width > sw)
+ {
+ shell->offset_x = -(shell->disp_width - sw) / 2;
+ }
+ else
+ {
+ gint min_offset_x = 0;
+ gint max_offset_x = sw - shell->disp_width;
+
+ shell->offset_x = CLAMP (shell->offset_x, min_offset_x, max_offset_x);
+ }
+
+ if (shell->disp_height > sh)
+ {
+ shell->offset_y = -(shell->disp_height - sh) / 2;
+ }
+ else
+ {
+ gint min_offset_y = 0;
+ gint max_offset_y = sh - shell->disp_height;
- shell->offset_y = CLAMP (shell->offset_y, 0,
- MAX (sh - shell->disp_height, 0));
+ shell->offset_y = CLAMP (shell->offset_y, min_offset_y, max_offset_y);
+ }
}
else
{
@@ -211,6 +229,69 @@
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- if (x) *x = shell->disp_xoffset - shell->offset_x;
- if (y) *y = shell->disp_yoffset - shell->offset_y;
+ if (x) *x = -shell->offset_x;
+ if (y) *y = -shell->offset_y;
+}
+
+/**
+ * gimp_display_shell_get_disp_offset:
+ * @shell:
+ * @disp_xoffset:
+ * @disp_yoffset:
+ *
+ * In viewport coordinates, get the offset of where to start rendering
+ * the scaled image.
+ *
+ **/
+void
+gimp_display_shell_get_disp_offset (const GimpDisplayShell *shell,
+ gint *disp_xoffset,
+ gint *disp_yoffset)
+{
+ g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+ if (disp_xoffset)
+ {
+ if (shell->offset_x < 0)
+ {
+ *disp_xoffset = -shell->offset_x;
+ }
+ else
+ {
+ *disp_xoffset = 0;
+ }
+ }
+
+ if (disp_yoffset)
+ {
+ if (shell->offset_y < 0)
+ {
+ *disp_yoffset = -shell->offset_y;
+ }
+ else
+ {
+ *disp_yoffset = 0;
+ }
+ }
+}
+
+/**
+ * gimp_display_shell_get_render_start_offset:
+ * @shell:
+ * @offset_x:
+ * @offset_y:
+ *
+ * Get the offset into the scaled image that we should start render
+ * from
+ *
+ **/
+void
+gimp_display_shell_get_render_start_offset (const GimpDisplayShell *shell,
+ gint *offset_x,
+ gint *offset_y)
+{
+ 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);
}
Modified: trunk/app/display/gimpdisplayshell-scroll.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.h (original)
+++ trunk/app/display/gimpdisplayshell-scroll.h Sat Jul 12 07:00:46 2008
@@ -42,5 +42,13 @@
gint *x,
gint *y);
+void gimp_display_shell_get_disp_offset (const GimpDisplayShell *shell,
+ gint *disp_xoffset,
+ gint *disp_yoffset);
+
+void gimp_display_shell_get_render_start_offset (const GimpDisplayShell *shell,
+ gint *offset_x,
+ gint *offset_y);
+
#endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */
Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c (original)
+++ trunk/app/display/gimpdisplayshell.c Sat Jul 12 07:00:46 2008
@@ -257,8 +257,6 @@
shell->disp_width = 0;
shell->disp_height = 0;
- shell->disp_xoffset = 0;
- shell->disp_yoffset = 0;
shell->proximity = FALSE;
shell->snap_to_guides = TRUE;
Modified: trunk/app/display/gimpdisplayshell.h
==============================================================================
--- trunk/app/display/gimpdisplayshell.h (original)
+++ trunk/app/display/gimpdisplayshell.h Sat Jul 12 07:00:46 2008
@@ -99,8 +99,6 @@
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */
- gint disp_xoffset;
- gint disp_yoffset;
gboolean proximity; /* is a device in proximity */
gboolean snap_to_guides; /* should the guides be snapped to? */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]