changeset 1897:b1fe543de73a

fixed area_changed handling
author Vladimir Nadvornik <nadvornik@suse.cz>
date Fri, 25 Mar 2011 22:09:59 +0100
parents 9604c72ac670
children c72ca737fdcc
files src/pixbuf-renderer.c src/pixbuf-renderer.h src/renderer-tiles.c
diffstat 3 files changed, 48 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/pixbuf-renderer.c	Sun Mar 20 19:16:07 2011 +0100
+++ b/src/pixbuf-renderer.c	Fri Mar 25 22:09:59 2011 +0100
@@ -2603,38 +2603,17 @@
 //	pr_tile_free_all(source);
 }
 
-void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint src_x, gint src_y, gint src_w, gint src_h)
+void pixbuf_renderer_area_changed(PixbufRenderer *pr, gint x, gint y, gint w, gint h)
 {
-	gint x, y, width, height,  x1, y1, x2, y2;
-
 	g_return_if_fail(IS_PIXBUF_RENDERER(pr));
 
-	pr_coords_map_orientation_reverse(pr->orientation,
-				     src_x, src_y,
-				     pr->image_width, pr->image_height,
-				     src_w, src_h,
-				     &x, &y,
-				     &width, &height);
-
 	if (pr->source_tiles_enabled)
 		{
-		pr_source_tile_changed(pr, x, y, width, height);
-		}
-
-	if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
-		{
-		/* increase region when using a zoom quality that may access surrounding pixels */
-		y -= 1;
-		height += 2;
+		pr_source_tile_changed(pr, x, y, w, h);
 		}
 
-	x1 = (gint)floor((gdouble)x * pr->scale);
-	y1 = (gint)floor((gdouble)y * pr->scale * pr->aspect_ratio);
-	x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
-	y2 = (gint)ceil((gdouble)(y + height) * pr->scale * pr->aspect_ratio);
-
-	pr->renderer->queue(pr->renderer, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
-	if (pr->renderer2) pr->renderer2->queue(pr->renderer2, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+	pr->renderer->area_changed(pr->renderer, x, y, w, h);
+	if (pr->renderer2) pr->renderer2->area_changed(pr->renderer2, x, y, w, h);
 }
 
 void pixbuf_renderer_zoom_adjust(PixbufRenderer *pr, gdouble increment)
--- a/src/pixbuf-renderer.h	Sun Mar 20 19:16:07 2011 +0100
+++ b/src/pixbuf-renderer.h	Fri Mar 25 22:09:59 2011 +0100
@@ -78,6 +78,7 @@
 {
 	void (*queue)(void *renderer, gint x, gint y, gint w, gint h,
                      gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
+        void (*area_changed)(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h);
 	void (*queue_clear)(void *renderer);
 	void (*border_draw)(void *renderer, gint x, gint y, gint w, gint h);
 	void (*invalidate_all)(void *renderer);
--- a/src/renderer-tiles.c	Sun Mar 20 19:16:07 2011 +0100
+++ b/src/renderer-tiles.c	Fri Mar 25 22:09:59 2011 +0100
@@ -1280,6 +1280,18 @@
 }
 
 
+static gint rt_get_orientation(RendererTiles *rt)
+{
+	PixbufRenderer *pr = rt->pr;
+
+	gint orientation = pr->orientation;
+	static const gint mirror[]       = {1,   2, 1, 4, 3, 6, 5, 8, 7};
+	static const gint flip[]         = {1,   4, 3, 2, 1, 8, 7, 6, 5};
+
+	if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
+	if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
+        return orientation;
+}
 
 
 static void rt_tile_render(RendererTiles *rt, ImageTile *it,
@@ -1290,9 +1302,7 @@
 	GtkWidget *box;
 	gboolean has_alpha;
 	gboolean draw = FALSE;
-	gint orientation = pr->orientation;
-	static const gint mirror[]       = {1,   2, 1, 4, 3, 6, 5, 8, 7};
-	static const gint flip[]         = {1,   4, 3, 2, 1, 8, 7, 6, 5};
+	gint orientation = rt_get_orientation(rt);
 
 	if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return;
 
@@ -1317,8 +1327,6 @@
 	rt_tile_prepare(rt, it);
 	has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
 
-	if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
-	if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
 	box = GTK_WIDGET(pr);
 
 	/* FIXME checker colors for alpha should be configurable,
@@ -1981,6 +1989,35 @@
 		}
 }
 
+static void renderer_area_changed(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h)
+{
+	RendererTiles *rt = (RendererTiles *)renderer;
+	PixbufRenderer *pr = rt->pr;
+	gint x, y, width, height,  x1, y1, x2, y2;
+
+	gint orientation = rt_get_orientation(rt);
+	pr_coords_map_orientation_reverse(orientation,
+				     src_x - GET_RIGHT_PIXBUF_OFFSET(rt), src_y,
+				     pr->image_width, pr->image_height,
+				     src_w, src_h,
+				     &x, &y,
+				     &width, &height);
+
+	if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
+		{
+		/* increase region when using a zoom quality that may access surrounding pixels */
+		y -= 1;
+		height += 2;
+		}
+
+	x1 = (gint)floor((gdouble)x * pr->scale);
+	y1 = (gint)floor((gdouble)y * pr->scale * pr->aspect_ratio);
+	x2 = (gint)ceil((gdouble)(x + width) * pr->scale);
+	y2 = (gint)ceil((gdouble)(y + height) * pr->scale * pr->aspect_ratio);
+
+	rt_queue(rt, x1, y1, x2 - x1, y2 - y1, FALSE, TILE_RENDER_AREA, TRUE, TRUE);
+}
+
 static void renderer_queue(void *renderer, gint x, gint y, gint w, gint h,
                      gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing)
 {
@@ -2083,6 +2120,7 @@
 	rt->pr = pr;
 	
 	rt->f.queue = renderer_queue;
+	rt->f.area_changed = renderer_area_changed;
 	rt->f.queue_clear = renderer_queue_clear;
 	rt->f.border_draw = renderer_border_draw;
 	rt->f.free = renderer_free;