changeset 1880:b69a33a93ace

display pixel aspect ratio support
author Vladimir Nadvornik <nadvornik@suse.cz>
date Sat, 29 Jan 2011 14:49:38 +0100
parents 880d06578486
children a0cd1875b1af
files src/pixbuf-renderer.c src/pixbuf-renderer.h src/renderer-tiles.c
diffstat 3 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/pixbuf-renderer.c	Fri Jan 28 14:34:57 2011 +0100
+++ b/src/pixbuf-renderer.c	Sat Jan 29 14:49:38 2011 +0100
@@ -409,6 +409,7 @@
 
 	pr->zoom = 1.0;
 	pr->scale = 1.0;
+	pr->aspect_ratio = 2.0;
 
 	pr->dither_quality = GDK_RGB_DITHER_NORMAL;
 
@@ -428,7 +429,7 @@
 	pr->norm_center_x = 0.5;
 	pr->norm_center_y = 0.5;
 	
-	pr->stereo_mode = PR_STEREO_ANAGLYPH;
+	pr->stereo_mode = PR_STEREO_HORIZ;
 	
 	pr->renderer = (void *)renderer_tiles_new(pr, pr->stereo_mode);
 	
@@ -1698,9 +1699,9 @@
 
 		if ((pr->zoom_expand && !sizeable) || w > max_w || h > max_h)
 			{
-			if ((gdouble)max_w / w > (gdouble)max_h / h)
+			if ((gdouble)max_w / w > (gdouble)max_h / h / pr->aspect_ratio)
 				{
-				scale = (gdouble)max_h / h;
+				scale = (gdouble)max_h / h / pr->aspect_ratio;
 				h = max_h;
 				w = w * scale + 0.5;
 				if (w > max_w) w = max_w;
@@ -1709,7 +1710,7 @@
 				{
 				scale = (gdouble)max_w / w;
 				w = max_w;
-				h = h * scale + 0.5;
+				h = h * scale * pr->aspect_ratio + 0.5;
 				if (h > max_h) h = max_h;
 				}
 
@@ -1733,13 +1734,13 @@
 		{
 		scale = zoom;
 		w = w * scale;
-		h = h * scale;
+		h = h * scale * pr->aspect_ratio;
 		}
 	else /* zoom out */
 		{
 		scale = 1.0 / (0.0 - zoom);
 		w = w * scale;
-		h = h * scale;
+		h = h * scale * pr->aspect_ratio;
 		}
 
 	invalid = (pr->width != w || pr->height != h);
@@ -1807,12 +1808,12 @@
 			case PR_SCROLL_RESET_NOCHANGE:
 				/* maintain old scroll position */
 				pr->x_scroll = ((gdouble)pr->image_width * old_center_x * pr->scale) - pr->vis_width / 2;
-				pr->y_scroll = ((gdouble)pr->image_height * old_center_y * pr->scale) - pr->vis_height / 2;
+				pr->y_scroll = ((gdouble)pr->image_height * old_center_y * pr->scale * pr->aspect_ratio) - pr->vis_height / 2;
 				break;
 			case PR_SCROLL_RESET_CENTER:
 				/* center new image */
 				pr->x_scroll = ((gdouble)pr->image_width / 2.0 * pr->scale) - pr->vis_width / 2;
-				pr->y_scroll = ((gdouble)pr->image_height / 2.0 * pr->scale) - pr->vis_height / 2;
+				pr->y_scroll = ((gdouble)pr->image_height / 2.0 * pr->scale * pr->aspect_ratio) - pr->vis_height / 2;
 				break;
 			case PR_SCROLL_RESET_TOPLEFT:
 			default:
@@ -1828,12 +1829,12 @@
 		if (center_point)
 			{
 			pr->x_scroll = old_cx / old_scale * pr->scale - (px - pr->x_offset);
-			pr->y_scroll = old_cy / old_scale * pr->scale - (py - pr->y_offset);
+			pr->y_scroll = old_cy / old_scale * pr->scale * pr->aspect_ratio - (py - pr->y_offset);
 			}
 		else
 			{
 			pr->x_scroll = old_cx / old_scale * pr->scale - (pr->vis_width / 2);
-			pr->y_scroll = old_cy / old_scale * pr->scale - (pr->vis_height / 2);
+			pr->y_scroll = old_cy / old_scale * pr->scale * pr->aspect_ratio - (pr->vis_height / 2);
 			}
 		}
 
@@ -2010,7 +2011,7 @@
 	ay = (gdouble)pr->vis_height * y_align;
 
 	px = (gdouble)x * pr->scale - (pr->x_scroll + ax);
-	py = (gdouble)y * pr->scale - (pr->y_scroll + ay);
+	py = (gdouble)y * pr->scale * pr->aspect_ratio - (pr->y_scroll + ay);
 
 	pixbuf_renderer_scroll(pr, px, py);
 }
@@ -2506,9 +2507,9 @@
 		}
 
 	x1 = (gint)floor((gdouble)x * pr->scale);
-	y1 = (gint)floor((gdouble)y * 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);
+	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);
@@ -2629,7 +2630,7 @@
 		}
 	
 	x_pixel = floor((gdouble)(pr->x_mouse - pr->x_offset + pr->x_scroll) / pr->scale);
-	y_pixel = floor((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale);
+	y_pixel = floor((gdouble)(pr->y_mouse - pr->y_offset + pr->y_scroll) / pr->scale / pr->aspect_ratio);
 	x_pixel_clamped = CLAMP(x_pixel, 0, pr->image_width - 1);
 	y_pixel_clamped = CLAMP(y_pixel, 0, pr->image_height - 1);
 	
@@ -2695,9 +2696,9 @@
 		}
 
 	rect->x = (gint)((gdouble)pr->x_scroll / pr->scale);
-	rect->y = (gint)((gdouble)pr->y_scroll / pr->scale);
+	rect->y = (gint)((gdouble)pr->y_scroll / pr->scale / pr->aspect_ratio);
 	rect->width = (gint)((gdouble)pr->vis_width / pr->scale);
-	rect->height = (gint)((gdouble)pr->vis_height / pr->scale);
+	rect->height = (gint)((gdouble)pr->vis_height / pr->scale / pr->aspect_ratio);
 	return TRUE;
 }
 
--- a/src/pixbuf-renderer.h	Fri Jan 28 14:34:57 2011 +0100
+++ b/src/pixbuf-renderer.h	Sat Jan 29 14:49:38 2011 +0100
@@ -146,6 +146,8 @@
 	gdouble zoom;		/* zoom we want (0 is auto) */
 	gdouble scale;		/* zoom we got (should never be 0) */
 
+	gdouble aspect_ratio;   /* screen pixel aspect ratio (2.0 for 3DTV SBS mode) */
+
 	GdkInterpType zoom_quality;
 	gboolean zoom_2pass;
 	gboolean zoom_expand;
--- a/src/renderer-tiles.c	Fri Jan 28 14:34:57 2011 +0100
+++ b/src/renderer-tiles.c	Sat Jan 29 14:49:38 2011 +0100
@@ -1306,6 +1306,7 @@
 		draw = rt_source_tile_render(rt, it, x, y, w, h, new_data, fast);
 		}
 	else if ((pr->zoom == 1.0 || pr->scale == 1.0) &&
+		 pr->aspect_ratio == 1.0 &&
 		 !has_alpha &&
 		 pr->orientation == EXIF_ORIENTATION_TOP_LEFT && 
 		 !(pr->func_post_process && !(pr->post_process_slow && fast)) &&