summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2023-07-17 12:18:21 +0200
committersfan5 <sfan5@live.de>2023-07-19 13:01:08 +0200
commitd46a31317faaa80ae6fe2d7f1bec5e98dd0ca0a2 (patch)
tree76e64061046ef037892f2135bc05e1f89a14d53d /video
parente3992664008c6d37012e968e2656a38edd8aa151 (diff)
downloadmpv-d46a31317faaa80ae6fe2d7f1bec5e98dd0ca0a2.tar.bz2
mpv-d46a31317faaa80ae6fe2d7f1bec5e98dd0ca0a2.tar.xz
wayland_common: remove questionable gcd impl and global state
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c30
-rw-r--r--video/out/wayland_common.h1
2 files changed, 9 insertions, 22 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index cd06009635..799dad543f 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -189,7 +189,7 @@ static int spawn_cursor(struct vo_wayland_state *wl);
static void add_feedback(struct vo_wayland_feedback_pool *fback_pool,
struct wp_presentation_feedback *fback);
static void get_shape_device(struct vo_wayland_state *wl);
-static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b);
+static int greatest_common_divisor(int a, int b);
static void guess_focus(struct vo_wayland_state *wl);
static void prepare_resize(struct vo_wayland_state *wl, int width, int height);
static void remove_feedback(struct vo_wayland_feedback_pool *fback_pool,
@@ -1584,24 +1584,12 @@ static void get_shape_device(struct vo_wayland_state *wl)
#endif
}
-static void greatest_common_divisor(struct vo_wayland_state *wl, int a, int b)
+static int greatest_common_divisor(int a, int b)
{
- // euclidean algorithm
- int larger;
- int smaller;
- if (a > b) {
- larger = a;
- smaller = b;
- } else {
- larger = b;
- smaller = a;
- }
- int remainder = larger - smaller * floor(larger/smaller);
- if (remainder == 0) {
- wl->gcd = smaller;
- } else {
- greatest_common_divisor(wl, smaller, remainder);
- }
+ int rem = a % b;
+ if (rem == 0)
+ return b;
+ return greatest_common_divisor(b, rem);
}
static void guess_focus(struct vo_wayland_state *wl)
@@ -1784,9 +1772,9 @@ static void set_geometry(struct vo_wayland_state *wl, bool resize)
vo_calc_window_geometry2(vo, &screenrc, wl->scaling, &geo);
vo_apply_window_geometry(vo, &geo);
- greatest_common_divisor(wl, vo->dwidth, vo->dheight);
- wl->reduced_width = vo->dwidth / wl->gcd;
- wl->reduced_height = vo->dheight / wl->gcd;
+ int gcd = greatest_common_divisor(vo->dwidth, vo->dheight);
+ wl->reduced_width = vo->dwidth / gcd;
+ wl->reduced_height = vo->dheight / gcd;
wl->window_size = (struct mp_rect){0, 0, vo->dwidth, vo->dheight};
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index 1607bb3a56..3b4366318c 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -62,7 +62,6 @@ struct vo_wayland_state {
struct vo_wayland_output *current_output;
int bounded_height;
int bounded_width;
- int gcd;
int reduced_height;
int reduced_width;
int toplevel_width;