diff options
Diffstat (limited to 'src/quick/scenegraph/qsgrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 163d1d35c5..aa0d7b5a6c 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -87,13 +87,13 @@ class QSGGuiThreadRenderLoop : public QSGRenderLoop Q_OBJECT public: QSGGuiThreadRenderLoop(); + ~QSGGuiThreadRenderLoop(); void show(QQuickWindow *window); void hide(QQuickWindow *window); void windowDestroyed(QQuickWindow *window); - void initializeGL(); void renderWindow(QQuickWindow *window); void exposureChanged(QQuickWindow *window); QImage grab(QQuickWindow *window); @@ -106,6 +106,7 @@ public: QAnimationDriver *animationDriver() const { return 0; } QSGContext *sceneGraphContext() const; + QSGRenderContext *createRenderContext(QSGContext *) const { return rc; } bool event(QEvent *); @@ -118,6 +119,7 @@ public: QOpenGLContext *gl; QSGContext *sg; + QSGRenderContext *rc; QImage grabContent; @@ -140,11 +142,15 @@ bool QSGRenderLoop::useConsistentTiming() QSGRenderLoop *QSGRenderLoop::instance() { if (!s_instance) { - s_instance = QSGContext::createWindowManager(); - if (useConsistentTiming()) + bool info = qEnvironmentVariableIsSet("QSG_INFO"); + + if (useConsistentTiming()) { QUnifiedTimer::instance(true)->setConsistentTiming(true); + if (info) + qDebug() << "QSG: using fixed animation steps"; + } if (!s_instance) { @@ -177,12 +183,15 @@ QSGRenderLoop *QSGRenderLoop::instance() switch (loopType) { case ThreadedRenderLoop: + if (info) qDebug() << "QSG: threaded render loop"; s_instance = new QSGThreadedRenderLoop(); break; case WindowsRenderLoop: + if (info) qDebug() << "QSG: windows render loop"; s_instance = new QSGWindowsRenderLoop(); break; default: + if (info) qDebug() << "QSG: basic render loop"; s_instance = new QSGGuiThreadRenderLoop(); break; } @@ -202,8 +211,14 @@ QSGGuiThreadRenderLoop::QSGGuiThreadRenderLoop() , eventPending(false) { sg = QSGContext::createDefaultContext(); + rc = new QSGRenderContext(sg); } +QSGGuiThreadRenderLoop::~QSGGuiThreadRenderLoop() +{ + delete rc; + delete sg; +} void QSGGuiThreadRenderLoop::show(QQuickWindow *window) { @@ -226,7 +241,8 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window) if (m_windows.size() == 0) { if (!cd->persistentSceneGraph) { - sg->invalidate(); + rc->invalidate(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); if (!cd->persistentGLContext) { delete gl; gl = 0; @@ -239,7 +255,8 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) { hide(window); if (m_windows.size() == 0) { - sg->invalidate(); + rc->invalidate(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); delete gl; gl = 0; } @@ -257,14 +274,17 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (!gl) { gl = new QOpenGLContext(); gl->setFormat(window->requestedFormat()); + if (QSGContext::sharedOpenGLContext()) + gl->setShareContext(QSGContext::sharedOpenGLContext()); if (!gl->create()) { + qWarning("QtQuick: failed to create OpenGL context"); delete gl; gl = 0; } else { current = gl->makeCurrent(window); } if (current) - sg->initialize(gl); + QQuickWindowPrivate::get(window)->context->initialize(gl); } else { current = gl->makeCurrent(window); } |