summaryrefslogtreecommitdiffstats
path: root/video/out/gl_hwdec.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-09 17:47:02 +0100
committerwm4 <wm4@nowhere>2014-12-09 17:59:04 +0100
commitfb855b86593ad2a9db71cce3aa652ace93af38b5 (patch)
treeffca8eb74c8cf58dc5e97e0fac2c519b958b7cf7 /video/out/gl_hwdec.c
parentd38bc531cc7ce9c90b74145e2be2e24cb48e501a (diff)
downloadmpv-fb855b86593ad2a9db71cce3aa652ace93af38b5.tar.bz2
mpv-fb855b86593ad2a9db71cce3aa652ace93af38b5.tar.xz
client API: expose OpenGL renderer
This adds API to libmpv that lets host applications use the mpv opengl renderer. This is a more flexible (and possibly more portable) option to foreign window embedding (via --wid). This assumes that methods like context sharing and multithreaded OpenGL rendering are infeasible, and that a way is needed to integrate it with an application that uses a single thread to render everything. Add an example that does this with QtQuick/qml. The example is relatively lazy, but still shows how relatively simple the integration is. The FBO indirection could probably be avoided, but would require more work (and would probably lead to worse QtQuick integration, because it would have to ignore transformations like rotation). Because this makes mpv directly use the host application's OpenGL context, there is no platform specific code involved in mpv, except for hw decoding interop. main.qml is derived from some Qt example. The following things are still missing: - a way to do better video timing - expose GL renderer options, allow changing them at runtime - support for color equalizer controls - support for screenshots
Diffstat (limited to 'video/out/gl_hwdec.c')
-rw-r--r--video/out/gl_hwdec.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/video/out/gl_hwdec.c b/video/out/gl_hwdec.c
index 92f0ad095e..3bab1c1e9c 100644
--- a/video/out/gl_hwdec.c
+++ b/video/out/gl_hwdec.c
@@ -38,18 +38,19 @@ static const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = {
#if HAVE_VAAPI_GLX
&gl_hwdec_vaglx,
#endif
-#if HAVE_VDA_GL
- &gl_hwdec_vda,
-#endif
#if HAVE_VDPAU_GL_X11
&gl_hwdec_vdpau,
#endif
+#if HAVE_VDA_GL
+ &gl_hwdec_vda,
+#endif
NULL
};
static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
const struct gl_hwdec_driver *drv,
- struct mp_hwdec_info *info)
+ struct mp_hwdec_info *info,
+ bool is_auto)
{
struct gl_hwdec *hwdec = talloc(NULL, struct gl_hwdec);
*hwdec = (struct gl_hwdec) {
@@ -58,6 +59,7 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
.gl = gl,
.info = info,
.gl_texture_target = GL_TEXTURE_2D,
+ .reject_emulated = is_auto,
};
if (hwdec->driver->create(hwdec) < 0) {
talloc_free(hwdec);
@@ -71,10 +73,11 @@ struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
const char *api_name,
struct mp_hwdec_info *info)
{
+ bool is_auto = api_name && strcmp(api_name, "auto") == 0;
for (int n = 0; mpgl_hwdec_drivers[n]; n++) {
const struct gl_hwdec_driver *drv = mpgl_hwdec_drivers[n];
- if (api_name && strcmp(drv->api_name, api_name) == 0) {
- struct gl_hwdec *r = load_hwdec_driver(log, gl, drv, info);
+ if (is_auto || (api_name && strcmp(drv->api_name, api_name) == 0)) {
+ struct gl_hwdec *r = load_hwdec_driver(log, gl, drv, info, is_auto);
if (r)
return r;
}