changeset 1881:a0cd1875b1af

do not draw tiles outside the viewport
author Vladimir Nadvornik <nadvornik@suse.cz>
date Sat, 29 Jan 2011 17:15:39 +0100
parents b69a33a93ace
children c08048ea65f6
files src/renderer-tiles.c
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/renderer-tiles.c	Sat Jan 29 14:49:38 2011 +0100
+++ b/src/renderer-tiles.c	Sat Jan 29 17:15:39 2011 +0100
@@ -1408,7 +1408,7 @@
 				x, y,
 				x, y,
 				w, h,
-				pr->dither_quality, it->x + x + rt->stereo_off_x, it->y + y + rt->stereo_off_y);
+				pr->dither_quality, it->x + x, it->y + y);
 		}
 
 #if 0
@@ -1428,6 +1428,28 @@
 	PixbufRenderer *pr = rt->pr;
 	GtkWidget *box;
 
+	/* clamp to visible */
+	if (it->x + x < pr->x_scroll)
+		{
+		w -= pr->x_scroll - it->x - x;
+		x = pr->x_scroll - it->x;
+		}
+	if (it->x + x + w > pr->x_scroll + pr->vis_width)
+		{
+		w = pr->x_scroll + pr->vis_width - it->x - x; 
+		}
+	if (w < 1) return;
+	if (it->y + y < pr->y_scroll)
+		{
+		h -= pr->y_scroll - it->y - y;
+		y = pr->y_scroll - it->y;
+		}
+	if (it->y + y + h > pr->y_scroll + pr->vis_height)
+		{
+		h = pr->y_scroll + pr->vis_height - it->y - y; 
+		}
+	if (h < 1) return;
+
 	rt_tile_render(rt, it, x, y, w, h, new_data, fast);
 
 	box = GTK_WIDGET(pr);