mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
vo_opengl: update EGL code
Use the newer internal GL backend API.
This commit is contained in:
@@ -528,6 +528,7 @@ struct backend {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern const struct mpgl_driver mpgl_driver_x11;
|
extern const struct mpgl_driver mpgl_driver_x11;
|
||||||
|
extern const struct mpgl_driver mpgl_driver_x11egl;
|
||||||
|
|
||||||
static const struct backend backends[] = {
|
static const struct backend backends[] = {
|
||||||
#if HAVE_RPI_GLES
|
#if HAVE_RPI_GLES
|
||||||
@@ -548,7 +549,7 @@ static const struct backend backends[] = {
|
|||||||
{.driver = &mpgl_driver_x11},
|
{.driver = &mpgl_driver_x11},
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_EGL_X11
|
#if HAVE_EGL_X11
|
||||||
{"x11egl", mpgl_set_backend_x11egl},
|
{.driver = &mpgl_driver_x11egl},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,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_cocoa(MPGLContext *ctx);
|
||||||
void mpgl_set_backend_w32(MPGLContext *ctx);
|
void mpgl_set_backend_w32(MPGLContext *ctx);
|
||||||
void mpgl_set_backend_x11egl(MPGLContext *ctx);
|
|
||||||
void mpgl_set_backend_wayland(MPGLContext *ctx);
|
void mpgl_set_backend_wayland(MPGLContext *ctx);
|
||||||
void mpgl_set_backend_rpi(MPGLContext *ctx);
|
void mpgl_set_backend_rpi(MPGLContext *ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -99,11 +99,6 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
|||||||
struct vo *vo = ctx->vo;
|
struct vo *vo = ctx->vo;
|
||||||
bool es = flags & VOFLAG_GLES;
|
bool es = flags & VOFLAG_GLES;
|
||||||
|
|
||||||
if (p->egl_context) {
|
|
||||||
vo_x11_config_vo_window(vo, NULL, flags, "gl");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API))
|
if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -125,7 +120,7 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vo_x11_config_vo_window(vo, vi, flags, "gl");
|
vo_x11_config_vo_window(vo, vi, flags | VOFLAG_HIDDEN, "gl");
|
||||||
|
|
||||||
XFree(vi);
|
XFree(vi);
|
||||||
|
|
||||||
@@ -141,7 +136,27 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void releaseGlContext_egl(MPGLContext *ctx)
|
static int mpegl_init(struct MPGLContext *ctx, int vo_flags)
|
||||||
|
{
|
||||||
|
if (vo_x11_init(ctx->vo) && config_window_x11_egl(ctx, vo_flags))
|
||||||
|
return 0;
|
||||||
|
vo_x11_uninit(ctx->vo);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mpegl_reconfig(struct MPGLContext *ctx, int flags)
|
||||||
|
{
|
||||||
|
vo_x11_config_vo_window(ctx->vo, NULL, flags, "gl");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mpegl_control(struct MPGLContext *ctx, int *events, int request,
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
return vo_x11_control(ctx->vo, events, request, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mpegl_uninit(MPGLContext *ctx)
|
||||||
{
|
{
|
||||||
struct priv *p = ctx->priv;
|
struct priv *p = ctx->priv;
|
||||||
if (p->egl_context) {
|
if (p->egl_context) {
|
||||||
@@ -150,21 +165,21 @@ static void releaseGlContext_egl(MPGLContext *ctx)
|
|||||||
eglDestroyContext(p->egl_display, p->egl_context);
|
eglDestroyContext(p->egl_display, p->egl_context);
|
||||||
}
|
}
|
||||||
p->egl_context = EGL_NO_CONTEXT;
|
p->egl_context = EGL_NO_CONTEXT;
|
||||||
|
vo_x11_uninit(ctx->vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swapGlBuffers_egl(MPGLContext *ctx)
|
static void mpegl_swap_buffers(MPGLContext *ctx)
|
||||||
{
|
{
|
||||||
struct priv *p = ctx->priv;
|
struct priv *p = ctx->priv;
|
||||||
eglSwapBuffers(p->egl_display, p->egl_surface);
|
eglSwapBuffers(p->egl_display, p->egl_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mpgl_set_backend_x11egl(MPGLContext *ctx)
|
const struct mpgl_driver mpgl_driver_x11egl = {
|
||||||
{
|
.name = "x11egl",
|
||||||
ctx->priv = talloc_zero(ctx, struct priv);
|
.priv_size = sizeof(struct priv),
|
||||||
ctx->config_window = config_window_x11_egl;
|
.init = mpegl_init,
|
||||||
ctx->releaseGlContext = releaseGlContext_egl;
|
.reconfig = mpegl_reconfig,
|
||||||
ctx->swapGlBuffers = swapGlBuffers_egl;
|
.swap_buffers = mpegl_swap_buffers,
|
||||||
ctx->vo_init = vo_x11_init;
|
.control = mpegl_control,
|
||||||
ctx->vo_uninit = vo_x11_uninit;
|
.uninit = mpegl_uninit,
|
||||||
ctx->vo_control = vo_x11_control;
|
};
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user