summaryrefslogtreecommitdiff
path: root/ext/qt/qtitem.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/qt/qtitem.cc')
-rw-r--r--ext/qt/qtitem.cc156
1 files changed, 4 insertions, 152 deletions
diff --git a/ext/qt/qtitem.cc b/ext/qt/qtitem.cc
index c306c6dbd..f088c76fb 100644
--- a/ext/qt/qtitem.cc
+++ b/ext/qt/qtitem.cc
@@ -27,32 +27,13 @@
#include <gst/video/video.h>
#include "qtitem.h"
#include "gstqsgtexture.h"
+#include "gstqtglutility.h"
#include <QtCore/QRunnable>
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickWindow>
#include <QtQuick/QSGSimpleTextureNode>
-#if GST_GL_HAVE_WINDOW_X11 && GST_GL_HAVE_PLATFORM_GLX && defined (HAVE_QT_X11)
-#include <QX11Info>
-#include <gst/gl/x11/gstgldisplay_x11.h>
-#include <gst/gl/x11/gstglcontext_glx.h>
-#endif
-
-#if GST_GL_HAVE_WINDOW_WAYLAND && GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_WAYLAND)
-#include <qpa/qplatformnativeinterface.h>
-#include <gst/gl/wayland/gstgldisplay_wayland.h>
-#endif
-
-#if GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_EGLFS)
-#include <gst/gl/egl/gstgldisplay_egl.h>
-#include <gst/gl/egl/gstglcontext_egl.h>
-#endif
-
-#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_COCOA && defined (HAVE_QT_MAC)
-#include <gst/gl/coaoa/gstgldisplay_cocoa.h>
-#endif
-
/**
* SECTION:gtkgstglwidget
* @short_description: a #GtkGLArea that renders GStreamer video #GstBuffers
@@ -123,11 +104,8 @@ void InitializeSceneGraph::run()
QtGLVideoItem::QtGLVideoItem()
{
- QGuiApplication *app = static_cast<QGuiApplication *> (QCoreApplication::instance ());
static volatile gsize _debug;
- g_assert (app != NULL);
-
if (g_once_init_enter (&_debug)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "qtglwidget", 0, "Qt GL Widget");
g_once_init_leave (&_debug, 1);
@@ -143,48 +121,7 @@ QtGLVideoItem::QtGLVideoItem()
g_mutex_init (&this->priv->lock);
- GST_INFO ("QGuiApplication::instance()->platformName() %s", app->platformName().toUtf8().data());
-
-#if GST_GL_HAVE_WINDOW_X11 && defined (HAVE_QT_X11)
- if (QString::fromUtf8 ("xcb") == app->platformName())
- this->priv->display = (GstGLDisplay *)
- gst_gl_display_x11_new_with_display (QX11Info::display ());
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND && GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_WAYLAND)
- if (QString::fromUtf8 ("wayland") == app->platformName()
- || QString::fromUtf8 ("wayland-egl") == app->platformName()){
- struct wl_display * wayland_display;
- QPlatformNativeInterface *native =
- QGuiApplication::platformNativeInterface();
- wayland_display = (struct wl_display *)
- native->nativeResourceForWindow("display", NULL);
- this->priv->display = (GstGLDisplay *)
- gst_gl_display_wayland_new_with_display (wayland_display);
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_WINDOW_ANDROID
- if (QString::fromUtf8 ("android") == app->platformName())
- this->priv->display = (GstGLDisplay *) gst_gl_display_egl_new ();
-#elif GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_EGLFS)
- if (QString::fromUtf8("eglfs") == app->platformName())
- this->priv->display = (GstGLDisplay *) gst_gl_display_egl_new ();
-#endif
-
-#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_COCOA && defined (HAVE_QT_MAC)
- if (QString::fromUtf8 ("cocoa") == app->platformName())
- this->priv->display = (GstGLDisplay *) gst_gl_display_cocoa_new ();
-#endif
-#if GST_GL_HAVE_WINDOW_EAGL && GST_GL_HAVE_PLATFORM_EAGL && defined (HAVE_QT_IOS)
- if (QString::fromUtf8 ("ios") == app->platformName())
- this->priv->display = gst_gl_display_new ();
-#endif
-#if GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (HAVE_QT_WIN32)
- if (QString::fromUtf8 ("windows") == app->platformName())
- this->priv->display = gst_gl_display_new ();
-#endif
-
- if (!this->priv->display)
- this->priv->display = gst_gl_display_new ();
+ this->priv->display = gst_qt_get_gl_display();
connect(this, SIGNAL(windowChanged(QQuickWindow*)), this,
SLOT(handleWindowChanged(QQuickWindow*)));
@@ -318,10 +255,6 @@ qt_item_set_buffer (QtGLVideoItem * widget, GstBuffer * buffer)
void
QtGLVideoItem::onSceneGraphInitialized ()
{
- GstGLPlatform platform = (GstGLPlatform) 0;
- GstGLAPI gl_api;
- guintptr gl_handle;
-
GST_DEBUG ("scene graph initialization with Qt GL context %p",
this->window()->openglContext ());
@@ -334,89 +267,8 @@ QtGLVideoItem::onSceneGraphInitialized ()
return;
}
-#if GST_GL_HAVE_WINDOW_X11 && defined (HAVE_QT_X11)
- if (GST_IS_GL_DISPLAY_X11 (this->priv->display)) {
- platform = GST_GL_PLATFORM_GLX;
- }
-#endif
-#if GST_GL_HAVE_WINDOW_WAYLAND && defined (HAVE_QT_WAYLAND)
- if (GST_IS_GL_DISPLAY_WAYLAND (this->priv->display)) {
- platform = GST_GL_PLATFORM_EGL;
- }
-#endif
-#if GST_GL_HAVE_PLATFORM_EGL && defined (HAVE_QT_EGLFS)
- if (GST_IS_GL_DISPLAY_EGL (this->priv->display)) {
- platform = GST_GL_PLATFORM_EGL;
- }
-#endif
- if (platform == 0 && this->priv->display) {
-#if GST_GL_HAVE_WINDOW_COCOA && GST_GL_HAVE_PLATFORM_COCOA && defined (HAVE_QT_MAC)
- platform = GST_GL_PLATFORM_CGL;
-#elif GST_GL_HAVE_WINDOW_EAGL && GST_GL_HAVE_PLATFORM_EAGL && defined (HAVE_QT_IOS)
- platform = GST_GL_PLATFORM_EAGL;
-#elif GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (HAVE_QT_WIN32)
- platform = GST_GL_PLATFORM_WGL;
-#else
- GST_ERROR ("Unknown platform");
- return;
-#endif
- }
-
- gl_api = gst_gl_context_get_current_gl_api (platform, NULL, NULL);
- gl_handle = gst_gl_context_get_current_gl_context (platform);
- if (gl_handle)
- this->priv->other_context =
- gst_gl_context_new_wrapped (this->priv->display, gl_handle,
- platform, gl_api);
-
- (void) platform;
- (void) gl_api;
- (void) gl_handle;
-
- if (this->priv->other_context) {
- GError *error = NULL;
-
- gst_gl_context_activate (this->priv->other_context, TRUE);
- if (!gst_gl_context_fill_info (this->priv->other_context, &error)) {
- GST_ERROR ("%p failed to retrieve qt context info: %s", this, error->message);
- g_object_unref (this->priv->other_context);
- this->priv->other_context = NULL;
- } else {
- gst_gl_display_filter_gl_api (this->priv->display, gst_gl_context_get_gl_api (this->priv->other_context));
-#if GST_GL_HAVE_WINDOW_WIN32 && GST_GL_HAVE_PLATFORM_WGL && defined (HAVE_QT_WIN32)
- if (!wglGetProcAddress ("wglCreateContextAttribsARB")) {
- GstGLWindow *window;
- HDC device;
-
- /* If there's no wglCreateContextAttribsARB() support, then we would fallback to
- * wglShareLists() which will fail with ERROR_BUSY (0xaa) if either of the GL
- * contexts are current in any other thread.
- *
- * The workaround here is to temporarily disable Qt's GL context while we
- * set up our own.
- */
- this->priv->context = gst_gl_context_new (this->priv->display);
- window = gst_gl_context_get_window (this->priv->context);
- device = (HDC) gst_gl_window_get_display (window);
-
- wglMakeCurrent (device, 0);
- gst_object_unref (window);
- if (!gst_gl_context_create (this->priv->context, this->priv->other_context, &error)) {
- GST_ERROR ("%p failed to create shared GL context: %s", this, error->message);
- g_object_unref (this->priv->context);
- this->priv->context = NULL;
- g_object_unref (this->priv->other_context);
- this->priv->other_context = NULL;
- wglMakeCurrent (device, (HGLRC) gl_handle);
- return;
- }
- wglMakeCurrent (device, (HGLRC) gl_handle);
- }
-#endif
- gst_gl_context_activate (this->priv->other_context, FALSE);
- m_openGlContextInitialized = true;
- }
- }
+ m_openGlContextInitialized = gst_qt_get_gl_wrapcontext (this->priv->display,
+ &this->priv->other_context, &this->priv->context);
GST_DEBUG ("%p created wrapped GL context %" GST_PTR_FORMAT, this,
this->priv->other_context);