Skip to content

Commit

Permalink
do not mix autodetected and user-defined stereo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Sep 27, 2011
1 parent c447b43 commit e9780e0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
13 changes: 9 additions & 4 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ GdkPixbuf *image_get_pixbuf(ImageWindow *imd)

void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy)
{

StereoPixbufData stereo_data = STEREO_PIXBUF_DEFAULT;
/* read_exif and similar functions can actually notice that the file has changed and trigger
a notification that removes the pixbuf from cache and unrefs it. Therefore we must ref it
here before it is taken over by the renderer. */
Expand All @@ -1124,9 +1124,13 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboo
}
}

if (pixbuf && imd->user_stereo)
if (pixbuf)
{
g_object_set_data(G_OBJECT(pixbuf), "stereo_data", GINT_TO_POINTER(imd->user_stereo));
stereo_data = imd->user_stereo;
if (stereo_data == STEREO_PIXBUF_DEFAULT)
{
stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pixbuf), "stereo_data"));
}
}

pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE);
Expand All @@ -1138,12 +1142,13 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboo

if (lazy)
{
pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation);
pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation, stereo_data);
}
else
{
pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom);
pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
pixbuf_renderer_set_stereo_data((PixbufRenderer *)imd->pr, stereo_data);
}

if (pixbuf) g_object_unref(pixbuf);
Expand Down
25 changes: 18 additions & 7 deletions src/pixbuf-renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,6 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr)
pr->stereo_pixbuf_offset_left = 0;
pr->stereo_pixbuf_offset_right = 0;
if (!pr->pixbuf) return;
gint stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_data"));
switch (pr->orientation)
{
case EXIF_ORIENTATION_LEFT_TOP:
Expand All @@ -2397,12 +2396,12 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr)
case EXIF_ORIENTATION_LEFT_BOTTOM:
pr->image_width = gdk_pixbuf_get_height(pr->pixbuf);
pr->image_height = gdk_pixbuf_get_width(pr->pixbuf);
if (stereo_data == STEREO_PIXBUF_SBS)
if (pr->stereo_data == STEREO_PIXBUF_SBS)
{
pr->image_height /= 2;
pr->stereo_pixbuf_offset_right = pr->image_height;
}
else if (stereo_data == STEREO_PIXBUF_CROSS)
else if (pr->stereo_data == STEREO_PIXBUF_CROSS)
{
pr->image_height /= 2;
pr->stereo_pixbuf_offset_left = pr->image_height;
Expand All @@ -2412,12 +2411,12 @@ static void pr_pixbuf_size_sync(PixbufRenderer *pr)
default:
pr->image_width = gdk_pixbuf_get_width(pr->pixbuf);
pr->image_height = gdk_pixbuf_get_height(pr->pixbuf);
if (stereo_data == STEREO_PIXBUF_SBS)
if (pr->stereo_data == STEREO_PIXBUF_SBS)
{
pr->image_width /= 2;
pr->stereo_pixbuf_offset_right = pr->image_width;
}
else if (stereo_data == STEREO_PIXBUF_CROSS)
else if (pr->stereo_data == STEREO_PIXBUF_CROSS)
{
pr->image_width /= 2;
pr->stereo_pixbuf_offset_left = pr->image_width;
Expand Down Expand Up @@ -2462,7 +2461,7 @@ static void pr_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, P

if (pr->stereo_mode & PR_STEREO_TEMP_DISABLE)
{
gint disable = !pr->pixbuf || ! GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pr->pixbuf), "stereo_data"));
gint disable = !pr->pixbuf || ! pr->stereo_data;
pr_stereo_temp_disable(pr, disable);
}

Expand All @@ -2481,13 +2480,14 @@ void pixbuf_renderer_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble z
pr_update_signal(pr);
}

void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation)
void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation, StereoPixbufData stereo_data)
{
g_return_if_fail(IS_PIXBUF_RENDERER(pr));

pr_source_tile_unset(pr);

pr->orientation = orientation;
pr->stereo_data = stereo_data;
pr_set_pixbuf(pr, pixbuf, zoom, PR_ZOOM_LAZY);

pr_update_signal(pr);
Expand Down Expand Up @@ -2516,6 +2516,16 @@ gint pixbuf_renderer_get_orientation(PixbufRenderer *pr)
return pr->orientation;
}

void pixbuf_renderer_set_stereo_data(PixbufRenderer *pr, StereoPixbufData stereo_data)
{
g_return_if_fail(IS_PIXBUF_RENDERER(pr));

pr->stereo_data = stereo_data;

pr_pixbuf_size_sync(pr);
pr_zoom_sync(pr, pr->zoom, PR_ZOOM_FORCE, 0, 0);
}

void pixbuf_renderer_set_post_process_func(PixbufRenderer *pr, PixbufRendererPostProcessFunc func, gpointer user_data, gboolean slow)
{
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
Expand Down Expand Up @@ -2557,6 +2567,7 @@ void pixbuf_renderer_move(PixbufRenderer *pr, PixbufRenderer *source)
pr->post_process_user_data = source->post_process_user_data;
pr->post_process_slow = source->post_process_slow;
pr->orientation = source->orientation;
pr->stereo_data = source->stereo_data;

if (source->source_tiles_enabled)
{
Expand Down
7 changes: 6 additions & 1 deletion src/pixbuf-renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ struct _PixbufRenderer
gint orientation;

gint stereo_mode;

StereoPixbufData stereo_data;
gboolean stereo_temp_disable;
gint stereo_fixed_width;
gint stereo_fixed_height;
Expand Down Expand Up @@ -241,14 +243,17 @@ GtkWindow *pixbuf_renderer_get_parent(PixbufRenderer *pr);
void pixbuf_renderer_set_pixbuf(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom);

/* same as pixbuf_renderer_set_pixbuf but waits with redrawing for pixbuf_renderer_area_changed */
void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation);
void pixbuf_renderer_set_pixbuf_lazy(PixbufRenderer *pr, GdkPixbuf *pixbuf, gdouble zoom, gint orientation, StereoPixbufData stereo_data);


GdkPixbuf *pixbuf_renderer_get_pixbuf(PixbufRenderer *pr);

void pixbuf_renderer_set_orientation(PixbufRenderer *pr, gint orientation);
gint pixbuf_renderer_get_orientation(PixbufRenderer *pr);

/* sets the format of stereo data in the input pixbuf */
void pixbuf_renderer_set_stereo_data(PixbufRenderer *pr, StereoPixbufData stereo_data);

void pixbuf_renderer_set_post_process_func(PixbufRenderer *pr, PixbufRendererPostProcessFunc func, gpointer user_data, gboolean slow);

/* display an on-request array of pixbuf tiles */
Expand Down

0 comments on commit e9780e0

Please sign in to comment.