mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 00:02:13 +00:00
x11: use new OpenGL backend API
This commit is contained in:
parent
df97c30e0e
commit
fa39dadb05
@ -528,6 +528,8 @@ struct backend {
|
||||
const struct mpgl_driver *driver;
|
||||
};
|
||||
|
||||
extern const struct mpgl_driver mpgl_driver_x11;
|
||||
|
||||
static const struct backend backends[] = {
|
||||
#if HAVE_RPI_GLES
|
||||
{"rpi", mpgl_set_backend_rpi},
|
||||
@ -544,7 +546,7 @@ static const struct backend backends[] = {
|
||||
{"wayland", mpgl_set_backend_wayland},
|
||||
#endif
|
||||
#if HAVE_GL_X11
|
||||
{"x11", mpgl_set_backend_x11},
|
||||
{.driver = &mpgl_driver_x11},
|
||||
#endif
|
||||
#if HAVE_EGL_X11
|
||||
{"x11egl", mpgl_set_backend_x11egl},
|
||||
|
@ -170,7 +170,6 @@ int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
|
||||
|
||||
void mpgl_set_backend_cocoa(MPGLContext *ctx);
|
||||
void mpgl_set_backend_w32(MPGLContext *ctx);
|
||||
void mpgl_set_backend_x11(MPGLContext *ctx);
|
||||
void mpgl_set_backend_x11egl(MPGLContext *ctx);
|
||||
void mpgl_set_backend_wayland(MPGLContext *ctx);
|
||||
void mpgl_set_backend_rpi(MPGLContext *ctx);
|
||||
|
@ -187,13 +187,6 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
|
||||
struct vo *vo = ctx->vo;
|
||||
struct glx_context *glx_ctx = ctx->priv;
|
||||
|
||||
if (glx_ctx->context) {
|
||||
// GL context and window already exist.
|
||||
// Only update window geometry etc.
|
||||
vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl");
|
||||
return true;
|
||||
}
|
||||
|
||||
int glx_major, glx_minor;
|
||||
|
||||
if (!glXQueryVersion(vo->x11->display, &glx_major, &glx_minor)) {
|
||||
@ -247,7 +240,7 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
|
||||
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->depth_g);
|
||||
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->depth_b);
|
||||
|
||||
vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags, "gl");
|
||||
vo_x11_config_vo_window(vo, glx_ctx->vinfo, flags | VOFLAG_HIDDEN, "gl");
|
||||
|
||||
int gl_version = ctx->requested_gl_version;
|
||||
bool success = false;
|
||||
@ -263,7 +256,25 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags)
|
||||
return success;
|
||||
}
|
||||
|
||||
static void releaseGlContext_x11(MPGLContext *ctx)
|
||||
static int glx_init(struct MPGLContext *ctx, int vo_flags)
|
||||
{
|
||||
return vo_x11_init(ctx->vo) && config_window_x11(ctx, vo_flags) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int glx_reconfig(struct MPGLContext *ctx, int flags)
|
||||
{
|
||||
struct glx_context *glx_ctx = ctx->priv;
|
||||
vo_x11_config_vo_window(ctx->vo, glx_ctx->vinfo, flags, "gl");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int glx_control(struct MPGLContext *ctx, int *events, int request,
|
||||
void *arg)
|
||||
{
|
||||
return vo_x11_control(ctx->vo, events, request, arg);
|
||||
}
|
||||
|
||||
static void glx_uninit(MPGLContext *ctx)
|
||||
{
|
||||
struct glx_context *glx_ctx = ctx->priv;
|
||||
XVisualInfo **vinfo = &glx_ctx->vinfo;
|
||||
@ -271,26 +282,24 @@ static void releaseGlContext_x11(MPGLContext *ctx)
|
||||
Display *display = ctx->vo->x11->display;
|
||||
if (*vinfo)
|
||||
XFree(*vinfo);
|
||||
*vinfo = NULL;
|
||||
if (*context) {
|
||||
glXMakeCurrent(display, None, NULL);
|
||||
glXDestroyContext(display, *context);
|
||||
}
|
||||
*context = 0;
|
||||
vo_x11_uninit(ctx->vo);
|
||||
}
|
||||
|
||||
static void swapGlBuffers_x11(MPGLContext *ctx)
|
||||
static void glx_swap_buffers(struct MPGLContext *ctx)
|
||||
{
|
||||
glXSwapBuffers(ctx->vo->x11->display, ctx->vo->x11->window);
|
||||
}
|
||||
|
||||
void mpgl_set_backend_x11(MPGLContext *ctx)
|
||||
{
|
||||
ctx->priv = talloc_zero(ctx, struct glx_context);
|
||||
ctx->config_window = config_window_x11;
|
||||
ctx->releaseGlContext = releaseGlContext_x11;
|
||||
ctx->swapGlBuffers = swapGlBuffers_x11;
|
||||
ctx->vo_init = vo_x11_init;
|
||||
ctx->vo_uninit = vo_x11_uninit;
|
||||
ctx->vo_control = vo_x11_control;
|
||||
}
|
||||
const struct mpgl_driver mpgl_driver_x11 = {
|
||||
.name = "x11",
|
||||
.priv_size = sizeof(struct glx_context),
|
||||
.init = glx_init,
|
||||
.reconfig = glx_reconfig,
|
||||
.swap_buffers = glx_swap_buffers,
|
||||
.control = glx_control,
|
||||
.uninit = glx_uninit,
|
||||
};
|
Loading…
Reference in New Issue
Block a user