mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 00:07:33 +00:00
vo_opengl: x11egl: cleanup uninit path
Get rid of the config_window_x11_egl() indirection.
This commit is contained in:
parent
e0cb65e8ac
commit
0aa548457f
@ -46,6 +46,19 @@ static void * GLAPIENTRY get_native_display(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void mpegl_uninit(MPGLContext *ctx)
|
||||
{
|
||||
struct priv *p = ctx->priv;
|
||||
if (p->egl_context) {
|
||||
eglMakeCurrent(p->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
eglDestroyContext(p->egl_display, p->egl_context);
|
||||
}
|
||||
p->egl_context = EGL_NO_CONTEXT;
|
||||
current_context = NULL;
|
||||
vo_x11_uninit(ctx->vo);
|
||||
}
|
||||
|
||||
static EGLConfig select_fb_config_egl(struct MPGLContext *ctx, bool es)
|
||||
{
|
||||
struct priv *p = ctx->priv;
|
||||
@ -105,28 +118,31 @@ static bool create_context_egl(MPGLContext *ctx, EGLConfig config,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
||||
static int mpegl_init(struct MPGLContext *ctx, int flags)
|
||||
{
|
||||
struct priv *p = ctx->priv;
|
||||
struct vo *vo = ctx->vo;
|
||||
bool es = flags & VOFLAG_GLES;
|
||||
|
||||
if (!vo_x11_init(vo))
|
||||
goto uninit;
|
||||
|
||||
p->x_display = vo->x11->display;
|
||||
|
||||
if (!eglBindAPI(es ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
|
||||
MP_FATAL(vo, "Could not bind API (%s).\n", es ? "GLES" : "GL");
|
||||
return false;
|
||||
goto uninit;
|
||||
}
|
||||
|
||||
p->egl_display = eglGetDisplay(vo->x11->display);
|
||||
if (!eglInitialize(p->egl_display, NULL, NULL)) {
|
||||
MP_FATAL(vo, "Could not initialize EGL.\n");
|
||||
return false;
|
||||
goto uninit;
|
||||
}
|
||||
|
||||
EGLConfig config = select_fb_config_egl(ctx, es);
|
||||
if (!config)
|
||||
return false;
|
||||
goto uninit;
|
||||
|
||||
int vID, n;
|
||||
eglGetConfigAttrib(p->egl_display, config, EGL_NATIVE_VISUAL_ID, &vID);
|
||||
@ -134,8 +150,8 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
||||
XVisualInfo *vi = XGetVisualInfo(vo->x11->display, VisualIDMask, &template, &n);
|
||||
|
||||
if (!vi) {
|
||||
MP_FATAL(ctx->vo, "Getting X visual failed!\n");
|
||||
return false;
|
||||
MP_FATAL(vo, "Getting X visual failed!\n");
|
||||
goto uninit;
|
||||
}
|
||||
|
||||
vo_x11_config_vo_window(vo, vi, flags | VOFLAG_HIDDEN, "gl");
|
||||
@ -143,10 +159,7 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
||||
XFree(vi);
|
||||
|
||||
if (!create_context_egl(ctx, config, (EGLNativeWindowType)vo->x11->window, es))
|
||||
{
|
||||
vo_x11_uninit(ctx->vo);
|
||||
return false;
|
||||
}
|
||||
goto uninit;
|
||||
|
||||
const char *egl_exts = eglQueryString(p->egl_display, EGL_EXTENSIONS);
|
||||
|
||||
@ -157,14 +170,10 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags)
|
||||
assert(!current_context);
|
||||
current_context = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
uninit:
|
||||
mpegl_uninit(ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int mpegl_reconfig(struct MPGLContext *ctx, int flags)
|
||||
@ -179,19 +188,6 @@ static int mpegl_control(struct MPGLContext *ctx, int *events, int request,
|
||||
return vo_x11_control(ctx->vo, events, request, arg);
|
||||
}
|
||||
|
||||
static void mpegl_uninit(MPGLContext *ctx)
|
||||
{
|
||||
struct priv *p = ctx->priv;
|
||||
if (p->egl_context) {
|
||||
eglMakeCurrent(p->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
eglDestroyContext(p->egl_display, p->egl_context);
|
||||
}
|
||||
p->egl_context = EGL_NO_CONTEXT;
|
||||
current_context = NULL;
|
||||
vo_x11_uninit(ctx->vo);
|
||||
}
|
||||
|
||||
static void mpegl_swap_buffers(MPGLContext *ctx)
|
||||
{
|
||||
struct priv *p = ctx->priv;
|
||||
|
Loading…
Reference in New Issue
Block a user