diff options
author | wm4 <wm4@nowhere> | 2015-07-02 00:25:30 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-02 00:25:30 +0200 |
commit | c169292902f59adcb4bc6bcf8bd4db89d5ce2e78 (patch) | |
tree | 2d3d4f3afcf021837934cc04cb210330818a7567 | |
parent | 99bc0497453b79beea42a6d6986b1282d9137706 (diff) | |
download | mpv-c169292902f59adcb4bc6bcf8bd4db89d5ce2e78.tar.bz2 mpv-c169292902f59adcb4bc6bcf8bd4db89d5ce2e78.tar.xz |
vo_opengl: update EGL code
Use the newer internal GL backend API.
-rw-r--r-- | video/out/gl_common.c | 3 | ||||
-rw-r--r-- | video/out/gl_common.h | 1 | ||||
-rw-r--r-- | video/out/gl_x11egl.c | 51 |
3 files changed, 35 insertions, 20 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 7cc54980fa..63078a1e00 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -528,6 +528,7 @@ struct backend { }; extern const struct mpgl_driver mpgl_driver_x11; +extern const struct mpgl_driver mpgl_driver_x11egl; static const struct backend backends[] = { #if HAVE_RPI_GLES @@ -548,7 +549,7 @@ static const struct backend backends[] = { {.driver = &mpgl_driver_x11}, #endif #if HAVE_EGL_X11 - {"x11egl", mpgl_set_backend_x11egl}, + {.driver = &mpgl_driver_x11egl}, #endif }; diff --git a/video/out/gl_common.h b/video/out/gl_common.h index a48ce93968..0df44c75ec 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -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_w32(MPGLContext *ctx); -void mpgl_set_backend_x11egl(MPGLContext *ctx); void mpgl_set_backend_wayland(MPGLContext *ctx); void mpgl_set_backend_rpi(MPGLContext *ctx); diff --git a/video/out/gl_x11egl.c b/video/out/gl_x11egl.c index 9db0bee0a9..417d1526f9 100644 --- a/video/out/gl_x11egl.c +++ b/video/out/gl_x11egl.c @@ -99,11 +99,6 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags) struct vo *vo = ctx->vo; 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)) return false; @@ -125,7 +120,7 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags) return false; } - vo_x11_config_vo_window(vo, vi, flags, "gl"); + vo_x11_config_vo_window(vo, vi, flags | VOFLAG_HIDDEN, "gl"); XFree(vi); @@ -141,7 +136,27 @@ static bool config_window_x11_egl(struct MPGLContext *ctx, int flags) 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; if (p->egl_context) { @@ -150,21 +165,21 @@ static void releaseGlContext_egl(MPGLContext *ctx) eglDestroyContext(p->egl_display, p->egl_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; eglSwapBuffers(p->egl_display, p->egl_surface); } -void mpgl_set_backend_x11egl(MPGLContext *ctx) -{ - ctx->priv = talloc_zero(ctx, struct priv); - ctx->config_window = config_window_x11_egl; - ctx->releaseGlContext = releaseGlContext_egl; - ctx->swapGlBuffers = swapGlBuffers_egl; - ctx->vo_init = vo_x11_init; - ctx->vo_uninit = vo_x11_uninit; - ctx->vo_control = vo_x11_control; -} +const struct mpgl_driver mpgl_driver_x11egl = { + .name = "x11egl", + .priv_size = sizeof(struct priv), + .init = mpegl_init, + .reconfig = mpegl_reconfig, + .swap_buffers = mpegl_swap_buffers, + .control = mpegl_control, + .uninit = mpegl_uninit, +}; |