From: Vladimir Nadvornik Date: Sat, 5 Feb 2011 17:20:16 +0000 (+0100) Subject: swap stereo images X-Git-Tag: 1.1~77 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=68dc88956d7b42a3ced0e0256d075307e866494f swap stereo images --- diff --git a/src/pixbuf-renderer.c b/src/pixbuf-renderer.c index c6d93014..3ab3c270 100644 --- a/src/pixbuf-renderer.c +++ b/src/pixbuf-renderer.c @@ -2293,7 +2293,7 @@ void pr_create_anaglyph(GdkPixbuf *pixbuf, GdkPixbuf *right, gint x, gint y, gin */ 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 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr) 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 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr) 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; } } } diff --git a/src/pixbuf-renderer.h b/src/pixbuf-renderer.h index 35fa5154..20e96a07 100644 --- a/src/pixbuf-renderer.h +++ b/src/pixbuf-renderer.h @@ -80,10 +80,11 @@ typedef enum { 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 @@ struct _PixbufRenderer 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; diff --git a/src/renderer-tiles.c b/src/renderer-tiles.c index 550bb2b8..fe418c0a 100644 --- a/src/renderer-tiles.c +++ b/src/renderer-tiles.c @@ -141,6 +141,7 @@ struct _RendererTiles }; + 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 rt_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_tople 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 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, 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 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, 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 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, 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 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, 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 @@ static void rt_tile_render(RendererTiles *rt, ImageTile *it, 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,