summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorAlexander Preisinger <alexander.preisinger@gmail.com>2013-07-16 17:52:57 +0200
committerAlexander Preisinger <alexander.preisinger@gmail.com>2013-07-16 19:13:29 +0200
commit6230e0b896f2f022a83f034e401d18c259f22012 (patch)
tree9c854c88cf164f5a7168682d2629cb560cf7ba78 /video
parentdc142991f12c379282d6c52e6d98333765767c3c (diff)
downloadmpv-6230e0b896f2f022a83f034e401d18c259f22012.tar.bz2
mpv-6230e0b896f2f022a83f034e401d18c259f22012.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_wayland.c31
-rw-r--r--video/out/wayland_common.c2
-rw-r--r--video/out/wayland_common.h1
3 files changed, 27 insertions, 7 deletions
diff --git a/video/out/gl_wayland.c b/video/out/gl_wayland.c
index 7fb9c4d810..45c58cf42a 100644
--- a/video/out/gl_wayland.c
+++ b/video/out/gl_wayland.c
@@ -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;
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index b78b283e9c..2ba8dcec9f 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -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);
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index d55fcc0bbc..dce992beb2 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -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;