summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2017-12-25 16:04:09 +0100
committerKevin Mitchell <kevmitch@gmail.com>2017-12-27 14:29:15 -0700
commit451fc931b0f4924801b9a27d25a5c0339b2fcace (patch)
treec96683a962052059e1ab9c02c6ee1c8476c929c0
parent8a2db0c4b1a4e11b37541ac1eff90d4085fcb608 (diff)
downloadmpv-451fc931b0f4924801b9a27d25a5c0339b2fcace.tar.bz2
mpv-451fc931b0f4924801b9a27d25a5c0339b2fcace.tar.xz
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.
-rw-r--r--DOCS/man/options.rst7
-rw-r--r--options/options.c5
-rw-r--r--options/options.h1
-rw-r--r--video/out/opengl/context_android.c30
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=<number>``
+``--android-surface-height=<number>``
+ 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=<N>``
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;
}