mirror of https://github.com/mpv-player/mpv
vo_gl: add "backend" suboption to allow selecting the GUI backend
The "backend" suboption allows selecting the GUI backend used by vo_gl. Normally, it's auto-selected, but sometimes it's desireable to explicitly select it. Remove the gl_sdl VO. This can now be done by using: --vo=gl:backend=sdl This is based on svn commit 34438, and tries to be compatible with it. The undocumented numeric backend names serve this purpose. (They are undocumented because names are preferred.)
This commit is contained in:
parent
93ae55c2c3
commit
4352f9feca
|
@ -2087,6 +2087,36 @@ static void new_vo_sdl_fullscreen(struct vo *vo) { vo_sdl_fullscreen(); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct backend {
|
||||||
|
const char *name;
|
||||||
|
enum MPGLType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct backend backends[] = {
|
||||||
|
{"auto", GLTYPE_AUTO},
|
||||||
|
{"cocoa", GLTYPE_COCOA},
|
||||||
|
{"win", GLTYPE_W32},
|
||||||
|
{"x11", GLTYPE_X11},
|
||||||
|
{"sdl", GLTYPE_SDL},
|
||||||
|
// mplayer-svn aliases (note that mplayer-svn couples these with the numeric
|
||||||
|
// values of the internal GLTYPE_* constants)
|
||||||
|
{"-1", GLTYPE_AUTO},
|
||||||
|
{ "0", GLTYPE_W32},
|
||||||
|
{ "1", GLTYPE_X11},
|
||||||
|
{ "2", GLTYPE_SDL},
|
||||||
|
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
|
||||||
|
int mpgl_find_backend(const char *name)
|
||||||
|
{
|
||||||
|
for (const struct backend *entry = backends; entry->name; entry++) {
|
||||||
|
if (strcmp(entry->name, name) == 0)
|
||||||
|
return entry->type;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo)
|
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo)
|
||||||
{
|
{
|
||||||
MPGLContext *ctx;
|
MPGLContext *ctx;
|
||||||
|
|
|
@ -399,6 +399,8 @@ typedef struct MPGLContext {
|
||||||
void (*ontop)(struct vo *vo);
|
void (*ontop)(struct vo *vo);
|
||||||
} MPGLContext;
|
} MPGLContext;
|
||||||
|
|
||||||
|
int mpgl_find_backend(const char *name);
|
||||||
|
|
||||||
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo);
|
MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo);
|
||||||
void uninit_mpglcontext(MPGLContext *ctx);
|
void uninit_mpglcontext(MPGLContext *ctx);
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,6 @@ extern struct vo_driver video_out_vdpau;
|
||||||
extern struct vo_driver video_out_xv;
|
extern struct vo_driver video_out_xv;
|
||||||
extern struct vo_driver video_out_gl_nosw;
|
extern struct vo_driver video_out_gl_nosw;
|
||||||
extern struct vo_driver video_out_gl;
|
extern struct vo_driver video_out_gl;
|
||||||
extern struct vo_driver video_out_gl_sdl;
|
|
||||||
extern struct vo_driver video_out_dga;
|
extern struct vo_driver video_out_dga;
|
||||||
extern struct vo_driver video_out_sdl;
|
extern struct vo_driver video_out_sdl;
|
||||||
extern struct vo_driver video_out_3dfx;
|
extern struct vo_driver video_out_3dfx;
|
||||||
|
@ -181,9 +180,6 @@ const struct vo_driver *video_out_drivers[] =
|
||||||
#ifdef CONFIG_GL
|
#ifdef CONFIG_GL
|
||||||
&video_out_gl,
|
&video_out_gl,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_GL_SDL
|
|
||||||
&video_out_gl_sdl,
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_DGA
|
#ifdef CONFIG_DGA
|
||||||
&video_out_dga,
|
&video_out_dga,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1183,8 +1183,12 @@ static void uninit(struct vo *vo)
|
||||||
p->gl = NULL;
|
p->gl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
static int backend_valid(void *arg)
|
||||||
enum MPGLType gltype)
|
{
|
||||||
|
return mpgl_find_backend(*(const char **)arg) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int preinit_internal(struct vo *vo, const char *arg, int allow_sw)
|
||||||
{
|
{
|
||||||
struct gl_priv *p = talloc_zero(vo, struct gl_priv);
|
struct gl_priv *p = talloc_zero(vo, struct gl_priv);
|
||||||
vo->priv = p;
|
vo->priv = p;
|
||||||
|
@ -1211,6 +1215,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
||||||
int user_colorspace = 0;
|
int user_colorspace = 0;
|
||||||
int levelconv = -1;
|
int levelconv = -1;
|
||||||
int aspect = -1;
|
int aspect = -1;
|
||||||
|
char *backend_arg = NULL;
|
||||||
|
|
||||||
const opt_t subopts[] = {
|
const opt_t subopts[] = {
|
||||||
{"manyfmts", OPT_ARG_BOOL, &p->many_fmts, NULL},
|
{"manyfmts", OPT_ARG_BOOL, &p->many_fmts, NULL},
|
||||||
|
@ -1235,6 +1240,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
||||||
{"mipmapgen", OPT_ARG_BOOL, &p->mipmap_gen, NULL},
|
{"mipmapgen", OPT_ARG_BOOL, &p->mipmap_gen, NULL},
|
||||||
{"osdcolor", OPT_ARG_INT, &p->osd_color, NULL},
|
{"osdcolor", OPT_ARG_INT, &p->osd_color, NULL},
|
||||||
{"stereo", OPT_ARG_INT, &p->stereo_mode, NULL},
|
{"stereo", OPT_ARG_INT, &p->stereo_mode, NULL},
|
||||||
|
{"backend", OPT_ARG_MSTRZ,&backend_arg, backend_valid},
|
||||||
// Removed options.
|
// Removed options.
|
||||||
// They are only parsed to notify the user about the replacements.
|
// They are only parsed to notify the user about the replacements.
|
||||||
{"aspect", OPT_ARG_BOOL, &aspect, NULL},
|
{"aspect", OPT_ARG_BOOL, &aspect, NULL},
|
||||||
|
@ -1310,6 +1316,12 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
||||||
" 1: side-by-side to red-cyan stereo\n"
|
" 1: side-by-side to red-cyan stereo\n"
|
||||||
" 2: side-by-side to green-magenta stereo\n"
|
" 2: side-by-side to green-magenta stereo\n"
|
||||||
" 3: side-by-side to quadbuffer stereo\n"
|
" 3: side-by-side to quadbuffer stereo\n"
|
||||||
|
" backend=<sys>\n"
|
||||||
|
" auto: auto-select (default)\n"
|
||||||
|
" cocoa: Cocoa/OSX\n"
|
||||||
|
" win: Win32/WGL\n"
|
||||||
|
" x11: X11/GLX\n"
|
||||||
|
" sdl: SDL\n"
|
||||||
"\n");
|
"\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1329,7 +1341,11 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
||||||
" been removed, using yuv=2 instead.\n");
|
" been removed, using yuv=2 instead.\n");
|
||||||
p->use_yuv = 2;
|
p->use_yuv = 2;
|
||||||
}
|
}
|
||||||
p->glctx = init_mpglcontext(gltype, vo);
|
|
||||||
|
int backend = backend_arg ? mpgl_find_backend(backend_arg) : GLTYPE_AUTO;
|
||||||
|
free(backend_arg);
|
||||||
|
|
||||||
|
p->glctx = init_mpglcontext(backend, vo);
|
||||||
if (!p->glctx)
|
if (!p->glctx)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
p->gl = p->glctx->gl;
|
p->gl = p->glctx->gl;
|
||||||
|
@ -1353,7 +1369,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
||||||
// acceleration and so on. Destroy that window to make sure all state
|
// acceleration and so on. Destroy that window to make sure all state
|
||||||
// associated with it is lost.
|
// associated with it is lost.
|
||||||
uninit(vo);
|
uninit(vo);
|
||||||
p->glctx = init_mpglcontext(gltype, vo);
|
p->glctx = init_mpglcontext(backend, vo);
|
||||||
if (!p->glctx)
|
if (!p->glctx)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
p->gl = p->glctx->gl;
|
p->gl = p->glctx->gl;
|
||||||
|
@ -1373,7 +1389,7 @@ err_out:
|
||||||
|
|
||||||
static int preinit(struct vo *vo, const char *arg)
|
static int preinit(struct vo *vo, const char *arg)
|
||||||
{
|
{
|
||||||
return preinit_internal(vo, arg, 1, GLTYPE_AUTO);
|
return preinit_internal(vo, arg, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int control(struct vo *vo, uint32_t request, void *data)
|
static int control(struct vo *vo, uint32_t request, void *data)
|
||||||
|
@ -1498,7 +1514,7 @@ const struct vo_driver video_out_gl = {
|
||||||
|
|
||||||
static int preinit_nosw(struct vo *vo, const char *arg)
|
static int preinit_nosw(struct vo *vo, const char *arg)
|
||||||
{
|
{
|
||||||
return preinit_internal(vo, arg, 0, GLTYPE_AUTO);
|
return preinit_internal(vo, arg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct vo_driver video_out_gl_nosw =
|
const struct vo_driver video_out_gl_nosw =
|
||||||
|
@ -1519,28 +1535,3 @@ const struct vo_driver video_out_gl_nosw =
|
||||||
.check_events = check_events,
|
.check_events = check_events,
|
||||||
.uninit = uninit,
|
.uninit = uninit,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_GL_SDL
|
|
||||||
static int preinit_sdl(struct vo *vo, const char *arg)
|
|
||||||
{
|
|
||||||
return preinit_internal(vo, arg, 1, GLTYPE_SDL);
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct vo_driver video_out_gl_sdl = {
|
|
||||||
.is_new = true,
|
|
||||||
.info = &(const vo_info_t) {
|
|
||||||
"OpenGL with SDL",
|
|
||||||
"gl_sdl",
|
|
||||||
"Reimar Doeffinger <Reimar.Doeffinger@gmx.de>",
|
|
||||||
""
|
|
||||||
},
|
|
||||||
.preinit = preinit_sdl,
|
|
||||||
.config = config,
|
|
||||||
.control = control,
|
|
||||||
.draw_slice = draw_slice,
|
|
||||||
.draw_osd = draw_osd,
|
|
||||||
.flip_page = flip_page,
|
|
||||||
.check_events = check_events,
|
|
||||||
.uninit = uninit,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue