summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-09-19 17:26:21 -0500
committerDudemanguy <random342@airmail.cc>2023-09-22 14:20:38 +0000
commit73ad9eef2875247d38af99f4d8c804f2749a8588 (patch)
treed03d912b0ae85cbf99de2f893634e5f74a191aff
parent58ac0dd6db87c6cdabff79f1cfba575f15f3328d (diff)
downloadmpv-73ad9eef2875247d38af99f4d8c804f2749a8588.tar.bz2
mpv-73ad9eef2875247d38af99f4d8c804f2749a8588.tar.xz
opengl/context_win: move opengl-dwmflush to wingl_opts group
Gets rid of yet another mp_read_option_raw call.
-rw-r--r--options/options.c4
-rw-r--r--options/options.h3
-rw-r--r--video/out/opengl/context_win.c31
3 files changed, 26 insertions, 12 deletions
diff --git a/options/options.c b/options/options.c
index 523f172298..d91a72c3a3 100644
--- a/options/options.c
+++ b/options/options.c
@@ -95,6 +95,7 @@ extern const struct m_sub_options d3d11va_conf;
extern const struct m_sub_options angle_conf;
extern const struct m_sub_options macos_conf;
extern const struct m_sub_options wayland_conf;
+extern const struct m_sub_options wingl_conf;
extern const struct m_sub_options vaapi_conf;
static const struct m_sub_options screenshot_conf = {
@@ -840,8 +841,7 @@ static const m_option_t mp_opts[] = {
#endif
#if HAVE_GL_WIN32
- {"opengl-dwmflush", OPT_CHOICE(wingl_dwm_flush,
- {"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})},
+ {"", OPT_SUBSTRUCT(wingl_opts, wingl_conf)},
#endif
#if HAVE_CUDA_HWACCEL
diff --git a/options/options.h b/options/options.h
index 2182e25397..da37345edc 100644
--- a/options/options.h
+++ b/options/options.h
@@ -350,8 +350,6 @@ typedef struct MPOpts {
char *ipc_path;
char *ipc_client;
- int wingl_dwm_flush;
-
struct mp_resample_opts *resample_opts;
struct ra_ctx_opts *ra_ctx_opts;
@@ -366,6 +364,7 @@ typedef struct MPOpts {
struct macos_opts *macos_opts;
struct drm_opts *drm_opts;
struct wayland_opts *wayland_opts;
+ struct wingl_opts *wingl_opts;
struct dvd_opts *dvd_opts;
struct vaapi_opts *vaapi_opts;
struct sws_opts *sws_opts;
diff --git a/video/out/opengl/context_win.c b/video/out/opengl/context_win.c
index 6bf04547ad..968b1763bf 100644
--- a/video/out/opengl/context_win.c
+++ b/video/out/opengl/context_win.c
@@ -37,6 +37,20 @@
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#endif
+struct wingl_opts {
+ int wingl_dwm_flush;
+};
+
+#define OPT_BASE_STRUCT struct wingl_opts
+const struct m_sub_options wingl_conf = {
+ .opts = (const struct m_option[]) {
+ {"opengl-dwmflush", OPT_CHOICE(wingl_dwm_flush,
+ {"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})},
+ {0}
+ },
+ .size = sizeof(struct wingl_opts),
+};
+
struct priv {
GL gl;
@@ -44,6 +58,8 @@ struct priv {
int current_swapinterval;
int (GLAPIENTRY *real_wglSwapInterval)(int);
+ struct m_config_cache *opts_cache;
+ struct wingl_opts *opts;
HGLRC context;
HDC hdc;
@@ -247,14 +263,10 @@ static void wgl_swap_buffers(struct ra_ctx *ctx)
// default if we don't DwmFLush
int new_swapinterval = p->opt_swapinterval;
- int dwm_flush_opt;
- mp_read_option_raw(ctx->global, "opengl-dwmflush", &m_option_type_choice,
- &dwm_flush_opt);
-
- if (dwm_flush_opt >= 0) {
- if ((dwm_flush_opt == 1 && !ctx->vo->opts->fullscreen) ||
- (dwm_flush_opt == 2) ||
- (dwm_flush_opt == 0 && compositor_active(ctx)))
+ if (p->opts->wingl_dwm_flush >= 0) {
+ if ((p->opts->wingl_dwm_flush == 1 && !ctx->vo->opts->fullscreen) ||
+ (p->opts->wingl_dwm_flush == 2) ||
+ (p->opts->wingl_dwm_flush == 0 && compositor_active(ctx)))
{
if (DwmFlush() == S_OK)
new_swapinterval = 0;
@@ -275,6 +287,9 @@ static bool wgl_init(struct ra_ctx *ctx)
struct priv *p = ctx->priv = talloc_zero(ctx, struct priv);
GL *gl = &p->gl;
+ p->opts_cache = m_config_cache_alloc(ctx, ctx->global, &wingl_conf);
+ p->opts = p->opts_cache->opts;
+
if (!vo_w32_init(ctx->vo))
goto fail;