diff options
author | wm4 <wm4@nowhere> | 2015-10-02 18:28:03 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-02 18:33:09 +0200 |
commit | e87f7054979a1014e11b804b46dbfd0291728419 (patch) | |
tree | a7a915036a2c259566c1a6f2f533810773c9f0f8 /video | |
parent | 93db4233af840767a74acc95649538a7ef8c9c1e (diff) | |
download | mpv-e87f7054979a1014e11b804b46dbfd0291728419.tar.bz2 mpv-e87f7054979a1014e11b804b46dbfd0291728419.tar.xz |
vo_opengl: rpi: switch to new internal API
Diffstat (limited to 'video')
-rw-r--r-- | video/out/opengl/common.c | 3 | ||||
-rw-r--r-- | video/out/opengl/common.h | 2 | ||||
-rw-r--r-- | video/out/opengl/rpi.c | 69 |
3 files changed, 35 insertions, 39 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index 3973a533e9..3be714541e 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -503,10 +503,11 @@ extern const struct mpgl_driver mpgl_driver_x11egl; extern const struct mpgl_driver mpgl_driver_cocoa; extern const struct mpgl_driver mpgl_driver_wayland; extern const struct mpgl_driver mpgl_driver_w32; +extern const struct mpgl_driver mpgl_driver_rpi; static const struct backend backends[] = { #if HAVE_RPI - {"rpi", mpgl_set_backend_rpi}, + {.driver = &mpgl_driver_rpi}, #endif #if HAVE_GL_COCOA {.driver = &mpgl_driver_cocoa}, diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h index 5622702f16..dbae77c3f9 100644 --- a/video/out/opengl/common.h +++ b/video/out/opengl/common.h @@ -151,8 +151,6 @@ struct m_option; int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt, struct bstr name, struct bstr param); -void mpgl_set_backend_rpi(MPGLContext *ctx); - void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log); void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), diff --git a/video/out/opengl/rpi.c b/video/out/opengl/rpi.c index 23993bb31c..0e0f0813e9 100644 --- a/video/out/opengl/rpi.c +++ b/video/out/opengl/rpi.c @@ -152,32 +152,34 @@ struct priv { int w, h; }; -static bool sc_config_window(struct MPGLContext *ctx, int flags) +static void rpi_uninit(MPGLContext *ctx) +{ + struct priv *p = ctx->priv; + mp_egl_rpi_destroy(&p->egl); + if (p->display) + vc_dispmanx_display_close(p->display); +} + +static int rpi_init(struct MPGLContext *ctx, int flags) { struct priv *p = ctx->priv; struct vo *vo = ctx->vo; p->egl.log = vo->log; - if (p->egl.gl) { - vo->dwidth = p->w; - vo->dheight = p->h; - return true; - } - bcm_host_init(); p->display = vc_dispmanx_display_open(0); p->update = vc_dispmanx_update_start(0); if (!p->display || !p->update) { MP_FATAL(ctx->vo, "Could not get DISPMANX objects.\n"); - return false; + goto fail; } uint32_t w, h; if (graphics_get_display_size(0, &w, &h) < 0) { MP_FATAL(ctx->vo, "Could not get display size.\n"); - return false; + goto fail; } // dispmanx is like a neanderthal version of Wayland - you can add an @@ -192,56 +194,51 @@ static bool sc_config_window(struct MPGLContext *ctx, int flags) &src, DISPMANX_PROTECTION_NONE, &alpha, 0, 0); if (!p->window) { MP_FATAL(ctx->vo, "Could not add DISPMANX element.\n"); - return false; + goto fail; } vc_dispmanx_update_submit_sync(p->update); if (mp_egl_rpi_init(&p->egl, p->window, w, h) < 0) - return false; + goto fail; ctx->gl = p->egl.gl; vo->dwidth = p->w = w; vo->dheight = p->h = h; - return true; + return 0; + +fail: + rpi_uninit(ctx); + return -1; } -static void sc_releaseGlContext(MPGLContext *ctx) +static int rpi_reconfig(struct MPGLContext *ctx, int flags) { struct priv *p = ctx->priv; - mp_egl_rpi_destroy(&p->egl); - vc_dispmanx_display_close(p->display); + ctx->vo->dwidth = p->w; + ctx->vo->dheight = p->h; + return 0; } -static void sc_swapGlBuffers(MPGLContext *ctx) +static void rpi_swap_buffers(MPGLContext *ctx) { struct priv *p = ctx->priv; eglSwapBuffers(p->egl.egl_display, p->egl.egl_surface); } -static int sc_vo_init(struct vo *vo) -{ - return 1; -} - -static void sc_vo_uninit(struct vo *vo) -{ -} - -static int sc_vo_control(struct vo *vo, int *events, int request, void *arg) +static int rpi_control(MPGLContext *ctx, int *events, int request, void *arg) { return VO_NOTIMPL; } -void mpgl_set_backend_rpi(MPGLContext *ctx) -{ - ctx->priv = talloc_zero(ctx, struct priv); - ctx->config_window = sc_config_window; - ctx->releaseGlContext = sc_releaseGlContext; - ctx->swapGlBuffers = sc_swapGlBuffers; - ctx->vo_init = sc_vo_init; - ctx->vo_uninit = sc_vo_uninit; - ctx->vo_control = sc_vo_control; -} +const struct mpgl_driver mpgl_driver_rpi = { + .name = "rpi", + .priv_size = sizeof(struct priv), + .init = rpi_init, + .reconfig = rpi_reconfig, + .swap_buffers = rpi_swap_buffers, + .control = rpi_control, + .uninit = rpi_uninit, +};
\ No newline at end of file |