mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gstqmlgl: create helper QRunnable-based class for render jobs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1032>
This commit is contained in:
parent
9af6ce974a
commit
211aaaf8b8
5 changed files with 14 additions and 51 deletions
|
@ -25,9 +25,21 @@
|
||||||
#include <gst/gl/gl.h>
|
#include <gst/gl/gl.h>
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QRunnable>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
struct RenderJob : public QRunnable {
|
||||||
|
using Callable = std::function<void()>;
|
||||||
|
|
||||||
|
explicit RenderJob(Callable c) : _c(c) { }
|
||||||
|
|
||||||
|
void run() { _c(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Callable _c;
|
||||||
|
};
|
||||||
|
|
||||||
GstGLDisplay * gst_qt_get_gl_display (gboolean sink);
|
GstGLDisplay * gst_qt_get_gl_display (gboolean sink);
|
||||||
gboolean gst_qt_get_gl_wrapcontext (GstGLDisplay * display,
|
gboolean gst_qt_get_gl_wrapcontext (GstGLDisplay * display,
|
||||||
GstGLContext **wrap_glcontext, GstGLContext **context);
|
GstGLContext **wrap_glcontext, GstGLContext **context);
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include "gstqsgtexture.h"
|
#include "gstqsgtexture.h"
|
||||||
#include "gstqtglutility.h"
|
#include "gstqtglutility.h"
|
||||||
|
|
||||||
#include <QtCore/QRunnable>
|
|
||||||
#include <QtCore/QMutexLocker>
|
#include <QtCore/QMutexLocker>
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
@ -90,27 +89,6 @@ struct _QtGLVideoItemPrivate
|
||||||
GQueue potentially_unbound_buffers;
|
GQueue potentially_unbound_buffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InitializeSceneGraph : public QRunnable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InitializeSceneGraph(QtGLVideoItem *item);
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QPointer<QtGLVideoItem> item_;
|
|
||||||
};
|
|
||||||
|
|
||||||
InitializeSceneGraph::InitializeSceneGraph(QtGLVideoItem *item) :
|
|
||||||
item_(item)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializeSceneGraph::run()
|
|
||||||
{
|
|
||||||
if(item_)
|
|
||||||
item_->onSceneGraphInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
QtGLVideoItem::QtGLVideoItem()
|
QtGLVideoItem::QtGLVideoItem()
|
||||||
{
|
{
|
||||||
static gsize _debug;
|
static gsize _debug;
|
||||||
|
@ -625,7 +603,7 @@ QtGLVideoItem::handleWindowChanged(QQuickWindow *win)
|
||||||
{
|
{
|
||||||
if (win) {
|
if (win) {
|
||||||
if (win->isSceneGraphInitialized())
|
if (win->isSceneGraphInitialized())
|
||||||
win->scheduleRenderJob(new InitializeSceneGraph(this), QQuickWindow::BeforeSynchronizingStage);
|
win->scheduleRenderJob(new RenderJob(std::bind(&QtGLVideoItem::onSceneGraphInitialized, this)), QQuickWindow::BeforeSynchronizingStage);
|
||||||
else
|
else
|
||||||
connect(win, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
|
connect(win, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,6 @@ private:
|
||||||
QMutex lock;
|
QMutex lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InitializeSceneGraph;
|
|
||||||
|
|
||||||
class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions
|
class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -108,7 +106,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class InitializeSceneGraph;
|
|
||||||
void setViewportSize(const QSize &size);
|
void setViewportSize(const QSize &size);
|
||||||
void shareContext();
|
void shareContext();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include "gstqtglutility.h"
|
#include "gstqtglutility.h"
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QRunnable>
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtQuick/QQuickWindow>
|
#include <QtQuick/QQuickWindow>
|
||||||
#include <QOpenGLFramebufferObject>
|
#include <QOpenGLFramebufferObject>
|
||||||
|
@ -80,26 +79,6 @@ struct _QtGLWindowPrivate
|
||||||
quint64 stop;
|
quint64 stop;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InitQtGLContext : public QRunnable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InitQtGLContext(QtGLWindow *window);
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QtGLWindow *window_;
|
|
||||||
};
|
|
||||||
|
|
||||||
InitQtGLContext::InitQtGLContext(QtGLWindow *window) :
|
|
||||||
window_(window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitQtGLContext::run()
|
|
||||||
{
|
|
||||||
window_->onSceneGraphInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
QtGLWindow::QtGLWindow ( QWindow * parent, QQuickWindow *src ) :
|
QtGLWindow::QtGLWindow ( QWindow * parent, QQuickWindow *src ) :
|
||||||
QQuickWindow( parent ), source (src)
|
QQuickWindow( parent ), source (src)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +103,7 @@ QtGLWindow::QtGLWindow ( QWindow * parent, QQuickWindow *src ) :
|
||||||
connect (source, SIGNAL(afterRendering()), this, SLOT(afterRendering()), Qt::DirectConnection);
|
connect (source, SIGNAL(afterRendering()), this, SLOT(afterRendering()), Qt::DirectConnection);
|
||||||
connect (app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()), Qt::DirectConnection);
|
connect (app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()), Qt::DirectConnection);
|
||||||
if (source->isSceneGraphInitialized())
|
if (source->isSceneGraphInitialized())
|
||||||
source->scheduleRenderJob(new InitQtGLContext(this), QQuickWindow::BeforeSynchronizingStage);
|
source->scheduleRenderJob(new RenderJob(std::bind(&QtGLWindow::onSceneGraphInitialized, this)), QQuickWindow::BeforeSynchronizingStage);
|
||||||
else
|
else
|
||||||
connect (source, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
|
connect (source, SIGNAL(sceneGraphInitialized()), this, SLOT(onSceneGraphInitialized()), Qt::DirectConnection);
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
typedef struct _QtGLWindowPrivate QtGLWindowPrivate;
|
typedef struct _QtGLWindowPrivate QtGLWindowPrivate;
|
||||||
|
|
||||||
class InitQtGLContext;
|
|
||||||
|
|
||||||
class QtGLWindow : public QQuickWindow, protected QOpenGLFunctions
|
class QtGLWindow : public QQuickWindow, protected QOpenGLFunctions
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -52,7 +50,6 @@ private Q_SLOTS:
|
||||||
void aboutToQuit();
|
void aboutToQuit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class InitQtGLContext;
|
|
||||||
QQuickWindow * source;
|
QQuickWindow * source;
|
||||||
QScopedPointer<QOpenGLFramebufferObject> fbo;
|
QScopedPointer<QOpenGLFramebufferObject> fbo;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue