wayland: early aspect calculation in vo_config

Calculate the aspect ratio in vo_config, when we get the window size and in the
inside the resize function we calculate the aspect ratio of the output in order
to determine if we have to change the height or the width of the video.

If the ratio of the output is bigger than the ratio of the video then we have
to set the width accordingly and if the ratio is smaller we change the size.
But only if no resize edges are passed, because this indicates that we want to
change the windows state instead of just a simple resize and the video should
not grow bigger than the requested size.
This commit is contained in:
Alexander Preisinger
2013-07-16 19:13:29 +02:00
parent dc142991f1
commit 6230e0b896
3 changed files with 27 additions and 7 deletions
+24 -7
View File
@@ -48,11 +48,12 @@ static void egl_resize_func(struct vo_wayland_state *wl,
struct egl_context *ctx = user_data;
int32_t minimum_size = 150;
int32_t x, y;
float temp_aspect = width / (float) MPMAX(height, 1);
/* get the real window size of the window */
wl_egl_window_get_attached_size(ctx->egl_window,
&wl->window->width,
&wl->window->height);
&w->width,
&w->height);
if (width < minimum_size)
width = minimum_size;
@@ -61,11 +62,27 @@ static void egl_resize_func(struct vo_wayland_state *wl,
/* if only the height is changed we have to calculate the width
* in any other case we calculate the height */
if (edges == WL_SHELL_SURFACE_RESIZE_BOTTOM ||
edges == WL_SHELL_SURFACE_RESIZE_TOP)
width = wl->vo->aspdat.asp * height;
else
height = (1 / wl->vo->aspdat.asp) * width;
switch (edges) {
case WL_SHELL_SURFACE_RESIZE_TOP:
case WL_SHELL_SURFACE_RESIZE_BOTTOM:
width = w->aspect * height;
break;
case WL_SHELL_SURFACE_RESIZE_LEFT:
case WL_SHELL_SURFACE_RESIZE_RIGHT:
case WL_SHELL_SURFACE_RESIZE_TOP_LEFT: // just a preference
case WL_SHELL_SURFACE_RESIZE_TOP_RIGHT:
case WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT:
case WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT:
height = (1 / w->aspect) * width;
break;
default:
if (w->aspect < temp_aspect)
width = w->aspect * height;
else
height = (1 / w->aspect) * width;
break;
}
if (edges & WL_SHELL_SURFACE_RESIZE_LEFT)
x = w->width - width;
+2
View File
@@ -882,6 +882,8 @@ bool vo_wayland_config (struct vo *vo, uint32_t d_width,
w->width = d_width;
w->height = d_height;
w->aspect = w->width / (float) MPMAX(w->height, 1);
if ((VOFLAG_FULLSCREEN & flags) && w->type != TYPE_FULLSCREEN)
vo_wayland_fullscreen(vo);
+1
View File
@@ -79,6 +79,7 @@ struct vo_wayland_window {
int32_t height;
int32_t p_width;
int32_t p_height;
float aspect;
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;