diff options
author | Sergey Borovkov <sergey.borovkov@wireload.net> | 2016-01-24 17:40:37 +0300 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2016-02-22 20:26:41 +1100 |
commit | 0d80be0ce0fe523fad59a74d431767322161cb7b (patch) | |
tree | bf7a8679229ea10c48c36f3b16e0a7535f622276 /ext | |
parent | a3019ffb63b1213cbad10abafa4e0ee9cd53c66b (diff) |
qmlglsink: Schedule onSceneGrpahInitialized to execute on render thread
onSceneGraphInitialized() is called from non render thread currently when
scene graph is already initialized.
https://bugzilla.gnome.org/show_bug.cgi?id=761003
Diffstat (limited to 'ext')
-rw-r--r-- | ext/qt/qtitem.cc | 32 | ||||
-rw-r--r-- | ext/qt/qtitem.h | 4 |
2 files changed, 33 insertions, 3 deletions
diff --git a/ext/qt/qtitem.cc b/ext/qt/qtitem.cc index 9dc058a23..648e0e84c 100644 --- a/ext/qt/qtitem.cc +++ b/ext/qt/qtitem.cc @@ -28,6 +28,7 @@ #include "qtitem.h" #include "gstqsgtexture.h" +#include <QtCore/QRunnable> #include <QtGui/QGuiApplication> #include <QtQuick/QQuickWindow> #include <QtQuick/QSGSimpleTextureNode> @@ -99,6 +100,26 @@ struct _QtGLVideoItemPrivate GstGLContext *context; }; +class InitializeSceneGraph : public QRunnable +{ +public: + InitializeSceneGraph(QtGLVideoItem *item); + void run(); + +private: + QtGLVideoItem *item_; +}; + +InitializeSceneGraph::InitializeSceneGraph(QtGLVideoItem *item) : + item_(item) +{ +} + +void InitializeSceneGraph::run() +{ + item_->onSceneGraphInitialized(); +} + QtGLVideoItem::QtGLVideoItem() { QGuiApplication *app = dynamic_cast<QGuiApplication *> (QCoreApplication::instance ()); @@ -110,7 +131,7 @@ QtGLVideoItem::QtGLVideoItem() GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "qtglwidget", 0, "Qt GL Widget"); g_once_init_leave (&_debug, 1); } - + this->m_openGlContextInitialized = false; this->setFlag (QQuickItem::ItemHasContents, true); this->priv = g_new0 (QtGLVideoItemPrivate, 1); @@ -188,6 +209,10 @@ QSGNode * QtGLVideoItem::updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) { + if (!m_openGlContextInitialized) { + return oldNode; + } + QSGSimpleTextureNode *texNode = static_cast<QSGSimpleTextureNode *> (oldNode); GstVideoRectangle src, dst, result; GstQSGTexture *tex; @@ -354,6 +379,7 @@ QtGLVideoItem::onSceneGraphInitialized () } else { gst_gl_display_filter_gl_api (this->priv->display, gst_gl_context_get_gl_api (this->priv->other_context)); gst_gl_context_activate (this->priv->other_context, FALSE); + m_openGlContextInitialized = true; } } @@ -414,9 +440,9 @@ QtGLVideoItem::handleWindowChanged(QQuickWindow *win) { if (win) { if (win->isSceneGraphInitialized()) - onSceneGraphInitialized(); + win->scheduleRenderJob(new InitializeSceneGraph(this), QQuickWindow::BeforeSynchronizingStage); else - connect(win, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection); + connect(win, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection); connect(win, SIGNAL(sceneGraphInvalidated()), this, SLOT(onSceneGraphInvalidated()), Qt::DirectConnection); } else { diff --git a/ext/qt/qtitem.h b/ext/qt/qtitem.h index 5a0763455..ae23eff10 100644 --- a/ext/qt/qtitem.h +++ b/ext/qt/qtitem.h @@ -31,6 +31,8 @@ typedef struct _QtGLVideoItemPrivate QtGLVideoItemPrivate; +class InitializeSceneGraph; + class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions { Q_OBJECT @@ -55,10 +57,12 @@ protected: QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData); private: + friend class InitializeSceneGraph; void setViewportSize(const QSize &size); void shareContext(); QSize m_viewportSize; + bool m_openGlContextInitialized; }; extern "C" |