[gimp] app: in GimpCanvasBufferPreview, add support for offset buffers
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in GimpCanvasBufferPreview, add support for offset buffers
- Date: Mon, 3 Feb 2020 19:24:32 +0000 (UTC)
commit 43f8a5199fa97d68c0733ef6f63da6b2c380a252
Author: Ell <ell_se yahoo com>
Date: Mon Feb 3 20:03:57 2020 +0200
app: in GimpCanvasBufferPreview, add support for offset buffers
Ditto.
app/display/gimpcanvasbufferpreview.c | 74 +++++++++++++++++------------------
1 file changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/app/display/gimpcanvasbufferpreview.c b/app/display/gimpcanvasbufferpreview.c
index 6aad7f2ed1..26b1171787 100644
--- a/app/display/gimpcanvasbufferpreview.c
+++ b/app/display/gimpcanvasbufferpreview.c
@@ -25,9 +25,12 @@
#include <cairo/cairo.h>
#include "libgimpbase/gimpbase.h"
+#include "libgimpmath/gimpmath.h"
#include "display/display-types.h"
+#include "core/gimpimage.h"
+
#include "gimpcanvas.h"
#include "gimpcanvasbufferpreview.h"
#include "gimpdisplayshell.h"
@@ -150,17 +153,9 @@ gimp_canvas_buffer_preview_draw (GimpCanvasItem *item,
cairo_surface_t *area;
guchar *data;
cairo_rectangle_int_t rectangle;
- gint viewport_offset_x, viewport_offset_y;
- gint viewport_width, viewport_height;
g_return_if_fail (GEGL_IS_BUFFER (buffer));
- gimp_display_shell_scroll_get_scaled_viewport (shell,
- &viewport_offset_x,
- &viewport_offset_y,
- &viewport_width,
- &viewport_height);
-
gimp_canvas_buffer_preview_compute_bounds (item, &rectangle);
area = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
@@ -169,8 +164,8 @@ gimp_canvas_buffer_preview_draw (GimpCanvasItem *item,
data = cairo_image_surface_get_data (area);
gegl_buffer_get (buffer,
- GEGL_RECTANGLE ((viewport_offset_x < 0 ? 0 : viewport_offset_x),
- (viewport_offset_y < 0 ? 0 : viewport_offset_y),
+ GEGL_RECTANGLE (rectangle.x + shell->offset_x,
+ rectangle.y + shell->offset_y,
rectangle.width,
rectangle.height),
shell->scale_x,
@@ -197,38 +192,39 @@ gimp_canvas_buffer_preview_compute_bounds (GimpCanvasItem *item,
{
GimpDisplayShell *shell = gimp_canvas_item_get_shell (item);
GeglBuffer *buffer = GET_PRIVATE (item)->buffer;
- gint x_from, x_to;
- gint y_from, y_to;
- gint viewport_offset_x, viewport_offset_y;
- gint viewport_width, viewport_height;
- gint width, height;
+ GeglRectangle extent;
+ gdouble x1, y1;
+ gdouble x2, y2;
g_return_if_fail (GEGL_IS_BUFFER (buffer));
- width = gegl_buffer_get_width (buffer);
- height = gegl_buffer_get_height (buffer);
-
- gimp_display_shell_scroll_get_scaled_viewport (shell,
- &viewport_offset_x,
- &viewport_offset_y,
- &viewport_width,
- &viewport_height);
-
- x_from = (viewport_offset_x < 0 ? -viewport_offset_x : 0);
- y_from = (viewport_offset_y < 0 ? -viewport_offset_y : 0);
-
- x_to = width * shell->scale_x - viewport_offset_x;
- if (x_to > viewport_width)
- x_to = viewport_width;
-
- y_to = height * shell->scale_y - viewport_offset_y;
- if (y_to > viewport_height)
- y_to = viewport_height;
-
- bounds->x = x_from;
- bounds->y = y_from;
- bounds->width = x_to - x_from;
- bounds->height = y_to - y_from;
+ extent = *gegl_buffer_get_extent (buffer);
+
+ gimp_canvas_item_transform_xy_f (item,
+ extent.x,
+ extent.y,
+ &x1, &y1);
+ gimp_canvas_item_transform_xy_f (item,
+ extent.x + extent.width,
+ extent.y + extent.height,
+ &x2, &y2);
+
+ extent.x = floor (x1);
+ extent.y = floor (y1);
+ extent.width = ceil (x2) - extent.x;
+ extent.height = ceil (y2) - extent.y;
+
+ gegl_rectangle_intersect (&extent,
+ &extent,
+ GEGL_RECTANGLE (0,
+ 0,
+ shell->disp_width,
+ shell->disp_height));
+
+ bounds->x = extent.x;
+ bounds->y = extent.y;
+ bounds->width = extent.width;
+ bounds->height = extent.height;
}
static cairo_region_t *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]