summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context_angle.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-20 13:38:28 +0100
committerwm4 <wm4@nowhere>2017-01-20 13:40:59 +0100
commitd890e0731c0a0c002c32e8be89130e178059d3ba (patch)
tree4e8d805b00283d24f1ee2edb72350b3bc5fe7e5c /video/out/opengl/context_angle.c
parenta35a5bb5f3c67f867ac6a21cad479657085f0230 (diff)
downloadmpv-d890e0731c0a0c002c32e8be89130e178059d3ba.tar.bz2
mpv-d890e0731c0a0c002c32e8be89130e178059d3ba.tar.xz
options: refactor how --opengl-dcomposition is declared
vo_opengl used to have it as sub-option, which made it very hard to pass down option values to backends in a generic way (even if these options were completely backend-specific). For --opengl-dcomposition we used a VOFLAG to deal with this. Fortunately, sub-options are gone, and we can just add it as global option. Move the option to context_angle.c and add it as global option. I thought about adding a mechanism to let backends declare options, which would get magically picked up my m_config instead of having to add them to the global option list manually (similar to VO vo_driver.options), but decided against this complexity just for 1 or 2 backends. Likewise, it could have been added as a single option to avoid the boilerplate of an option struct, but then again there are probably going to be more angle suboptions, and it's cleaner.
Diffstat (limited to 'video/out/opengl/context_angle.c')
-rw-r--r--video/out/opengl/context_angle.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c
index 44aed340e3..5af18e9928 100644
--- a/video/out/opengl/context_angle.c
+++ b/video/out/opengl/context_angle.c
@@ -24,6 +24,7 @@
#include "angle_dynamic.h"
#include "common/common.h"
+#include "options/m_config.h"
#include "video/out/w32_common.h"
#include "context.h"
@@ -36,6 +37,22 @@
// Windows 8 enum value, not present in mingw-w64 headers
#define DXGI_ADAPTER_FLAG_SOFTWARE (2)
+struct angle_opts {
+ int allow_direct_composition;
+};
+
+#define OPT_BASE_STRUCT struct angle_opts
+const struct m_sub_options angle_conf = {
+ .opts = (const struct m_option[]) {
+ OPT_FLAG("opengl-dcomposition", allow_direct_composition, 0),
+ {0}
+ },
+ .defaults = &(const struct angle_opts) {
+ .allow_direct_composition = 1,
+ },
+ .size = sizeof(struct angle_opts),
+};
+
struct priv {
EGLDisplay egl_display;
EGLContext egl_context;
@@ -43,6 +60,7 @@ struct priv {
bool use_es2;
bool sw_adapter_msg_shown;
PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV;
+ struct angle_opts *opts;
};
static void angle_uninit(MPGLContext *ctx)
@@ -217,6 +235,8 @@ static int angle_init(struct MPGLContext *ctx, int flags)
struct priv *p = ctx->priv;
struct vo *vo = ctx->vo;
+ p->opts = mp_get_config_group(ctx, ctx->global, &angle_conf);
+
if (!angle_load()) {
MP_VERBOSE(vo, "Failed to load LIBEGL.DLL\n");
goto fail;
@@ -309,7 +329,7 @@ static int angle_init(struct MPGLContext *ctx, int flags)
// behavior with some drivers (Intel? symptom - whole desktop is black for
// some seconds after spending some minutes in fullscreen and then leaving
// fullscreen).
- if ((flags & VOFLAG_ANGLE_DCOMP) &&
+ if (p->opts->allow_direct_composition &&
strstr(exts, "EGL_ANGLE_direct_composition"))
{
MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len,