From 451fc931b0f4924801b9a27d25a5c0339b2fcace Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 25 Dec 2017 16:04:09 +0100 Subject: vo_gpu/context: Let embedding application handle surface resizes The callbacks for this are Java-only and EGL does not reliably return the correct values. --- DOCS/man/options.rst | 7 +++++++ options/options.c | 5 +++++ options/options.h | 1 + video/out/opengl/context_android.c | 30 ++++++++++++++++++++---------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index ed27598b8a..3a2c1a9fc4 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4741,6 +4741,13 @@ The following video options are currently all specific to ``--vo=gpu`` and OS X only. +``--android-surface-width=`` +``--android-surface-height=`` + Set dimensions of the rendering surface used by the Android gpu context. + Needs to be set by the embedding application. + + Android with ``--gpu-context=android`` only. + ``--swapchain-depth=`` Allow up to N in-flight frames. This essentially controls the frame latency. Increasing the swapchain depth can improve pipelining and prevent diff --git a/options/options.c b/options/options.c index 3dafbf576b..5eb2cb525b 100644 --- a/options/options.c +++ b/options/options.c @@ -92,6 +92,7 @@ extern const struct m_sub_options d3d11_conf; extern const struct m_sub_options d3d11va_conf; extern const struct m_sub_options angle_conf; extern const struct m_sub_options cocoa_conf; +extern const struct m_sub_options android_conf; static const struct m_sub_options screenshot_conf = { .opts = image_writer_opts, @@ -668,6 +669,10 @@ const m_option_t mp_opts[] = { OPT_SUBSTRUCT("", cocoa_opts, cocoa_conf, 0), #endif +#if HAVE_ANDROID + OPT_SUBSTRUCT("", android_opts, android_conf, 0), +#endif + #if HAVE_GL_WIN32 OPT_CHOICE("opengl-dwmflush", wingl_dwm_flush, 0, ({"no", -1}, {"auto", 0}, {"windowed", 1}, {"yes", 2})), diff --git a/options/options.h b/options/options.h index c0164834d3..211284ff75 100644 --- a/options/options.h +++ b/options/options.h @@ -328,6 +328,7 @@ typedef struct MPOpts { struct d3d11_opts *d3d11_opts; struct d3d11va_opts *d3d11va_opts; struct cocoa_opts *cocoa_opts; + struct android_opts *android_opts; struct dvd_opts *dvd_opts; int cuda_device; diff --git a/video/out/opengl/context_android.c b/video/out/opengl/context_android.c index a2acce2223..dec420a120 100644 --- a/video/out/opengl/context_android.c +++ b/video/out/opengl/context_android.c @@ -26,6 +26,20 @@ #include "options/m_config.h" #include "context.h" +struct android_opts { + int w, h; +}; + +#define OPT_BASE_STRUCT struct android_opts +const struct m_sub_options android_conf = { + .opts = (const struct m_option[]) { + OPT_INT("android-surface-width", w, 0), + OPT_INT("android-surface-height", h, 0), + {0} + }, + .size = sizeof(struct android_opts), +}; + struct priv { struct GL gl; EGLDisplay egl_display; @@ -122,18 +136,14 @@ fail: static bool android_reconfig(struct ra_ctx *ctx) { - struct priv *p = ctx->priv; - int w, h; + void *tmp = talloc_new(NULL); + struct android_opts *opts = mp_get_config_group(tmp, ctx->global, &android_conf); - if (!eglQuerySurface(p->egl_display, p->egl_surface, EGL_WIDTH, &w) || - !eglQuerySurface(p->egl_display, p->egl_surface, EGL_HEIGHT, &h)) { - MP_FATAL(ctx, "Failed to get height and width!\n"); - return false; - } + ctx->vo->dwidth = opts->w; + ctx->vo->dheight = opts->h; + ra_gl_ctx_resize(ctx->swapchain, opts->w, opts->h, 0); - ctx->vo->dwidth = w; - ctx->vo->dheight = h; - ra_gl_ctx_resize(ctx->swapchain, w, h, 0); + talloc_free(tmp); return true; } -- cgit v1.2.3