changeset 1827:b33c3624405f

swap stereo images
author Vladimir Nadvornik <nadvornik@suse.cz>
date Sat, 05 Feb 2011 18:20:16 +0100
parents 6bf256959cda
children e1855b7d835c
files src/pixbuf-renderer.c src/pixbuf-renderer.h src/renderer-tiles.c
diffstat 3 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/pixbuf-renderer.c	Fri Feb 04 23:49:13 2011 +0100
+++ b/src/pixbuf-renderer.c	Sat Feb 05 18:20:16 2011 +0100
@@ -2293,7 +2293,7 @@
  */
 static void pr_pixbuf_size_sync(PixbufRenderer *pr)
 {
-	pr->stereo_pixbuf_off = 0;
+	pr->stereo_pixbuf_offset = 0;
 	if (!pr->pixbuf) return;
 	switch (pr->orientation)
 		{
@@ -2306,7 +2306,7 @@
 			if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))) 
 				{
 				pr->image_height /= 2;
-				pr->stereo_pixbuf_off = pr->image_height;
+				pr->stereo_pixbuf_offset = pr->image_height;
 				}
 			
 			break;
@@ -2316,7 +2316,7 @@
 			if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_sbs"))) 
 				{
 				pr->image_width /= 2;
-				pr->stereo_pixbuf_off = pr->image_width;
+				pr->stereo_pixbuf_offset = pr->image_width;
 				}
 		}
 }
--- a/src/pixbuf-renderer.h	Fri Feb 04 23:49:13 2011 +0100
+++ b/src/pixbuf-renderer.h	Sat Feb 05 18:20:16 2011 +0100
@@ -80,10 +80,11 @@
 	PR_STEREO_HORIZ    = 1 << 2, /* side by side */
 	PR_STEREO_VERT     = 1 << 3, /* above below */
 	/* flags for renderer: */
-	PR_STEREO_RIGHT    = 1 << 4, /* above below */
+	PR_STEREO_RIGHT    = 1 << 4, /* render right buffer */
 	PR_STEREO_ANAGLYPH = 1 << 5, /* anaglyph */
-	PR_STEREO_MIRROR   = 1 << 6, /* anaglyph */
-	PR_STEREO_FLIP     = 1 << 7  /* anaglyph */
+	PR_STEREO_MIRROR   = 1 << 6, /* mirror */
+	PR_STEREO_FLIP     = 1 << 7, /* flip */
+	PR_STEREO_SWAP     = 1 << 8  /* swap left and right buffers */
 	
 } PixbufRendererStereoMode;
 
@@ -112,7 +113,7 @@
 
 	gint image_width;	/* image actual dimensions (pixels) */
 	gint image_height;
-	gint stereo_pixbuf_off; /* offset of the right part of the stereo image in pixbuf */
+	gint stereo_pixbuf_offset; /* offset of the right part of the stereo image in pixbuf */
 
 	GdkPixbuf *pixbuf;
 
--- a/src/renderer-tiles.c	Fri Feb 04 23:49:13 2011 +0100
+++ b/src/renderer-tiles.c	Sat Feb 05 18:20:16 2011 +0100
@@ -141,6 +141,7 @@
 };
 
 
+
 static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h);
 static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, ImageTile *it);
 
@@ -162,6 +163,16 @@
 static void pixbuf_renderer_paint(RendererTiles *rt, GdkRectangle *area);
 static gint rt_queue_draw_idle_cb(gpointer data);
 
+#define GET_RIGHT_PIXBUF_OFFSET(rt) \
+        (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
+         (!(rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
+          rt->pr->stereo_pixbuf_offset : 0 )
+
+#define GET_LEFT_PIXBUF_OFFSET(rt) \
+        ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
+         ( (rt->stereo_mode & PR_STEREO_RIGHT) &&  (rt->stereo_mode & PR_STEREO_SWAP)) ?  \
+          rt->pr->stereo_pixbuf_offset : 0 )
+
 
 static void rt_sync_scroll(RendererTiles *rt)
 {
@@ -1279,7 +1290,6 @@
 	GtkWidget *box;
 	gboolean has_alpha;
 	gboolean draw = FALSE;
-	gint stereo_right_pixbuf_off;
 	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};
@@ -1307,7 +1317,6 @@
 	rt_tile_prepare(rt, it);
 	has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
 
-	stereo_right_pixbuf_off = (rt->stereo_mode & PR_STEREO_RIGHT) ? pr->stereo_pixbuf_off : 0;
 	if (rt->stereo_mode & PR_STEREO_MIRROR) orientation = mirror[orientation];
 	if (rt->stereo_mode & PR_STEREO_FLIP) orientation = flip[orientation];
 	box = GTK_WIDGET(pr);
@@ -1341,7 +1350,7 @@
 				box->style->fg_gc[GTK_WIDGET_STATE(box)],
 #endif
 				pr->pixbuf,
-				it->x + x + stereo_right_pixbuf_off, it->y + y,
+				it->x + x + GET_RIGHT_PIXBUF_OFFSET(rt), it->y + y,
 				x, y,
 				w, h,
 				pr->dither_quality, it->x + x, it->y + y);
@@ -1367,7 +1376,7 @@
 					    w, h,
 					    &pb_x, &pb_y,
 					    &pb_w, &pb_h);
-//printf("%d  %d\n", GET_X_SCROLL(rt), src_x);
+
 		switch (orientation)
 			{
 			gdouble tmp;
@@ -1391,17 +1400,17 @@
 
 		rt_tile_get_region(has_alpha,
 				   pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
-				   (gdouble) 0.0 - src_x - stereo_right_pixbuf_off * scale_x,
+				   (gdouble) 0.0 - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
 				   (gdouble) 0.0 - src_y,
 				   scale_x, scale_y,
 				   (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
 				   it->x + pb_x, it->y + pb_y);
-		if (rt->stereo_mode & PR_STEREO_ANAGLYPH && pr->stereo_pixbuf_off > 0)
+		if (rt->stereo_mode & PR_STEREO_ANAGLYPH && pr->stereo_pixbuf_offset > 0)
 			{
 			GdkPixbuf *right_pb = rt_get_spare_tile(rt);
 			rt_tile_get_region(has_alpha,
 					   pr->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h,
-					   (gdouble) 0.0 - src_x - pr->stereo_pixbuf_off * scale_x,
+					   (gdouble) 0.0 - src_x - GET_LEFT_PIXBUF_OFFSET(rt) * scale_x,
 					   (gdouble) 0.0 - src_y,
 					   scale_x, scale_y,
 					   (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,