diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-03-08 19:45:07 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-12 07:05:20 +0100 |
commit | 7c7207b4722d5da981bb53b6c68ecd42338e01e1 (patch) | |
tree | ab1b10ea3c1d63b1417c8e8ff2dea59b15f6f2b6 /src/quick | |
parent | 2f9d0346f00e37725f0f1bce1318501a25c5e438 (diff) |
Create the sg render thread's opengl context on the GUI thread
Change-Id: I710d80ebb4e5a12fda1f58f54089b0e72268dfcf
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/scenegraph/qsgthreadedrenderloop.cpp | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index fb26f543c3..55b27dc151 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -523,37 +523,6 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor) } } -void QSGRenderThread::initializeOpenGL() -{ - RLDEBUG1(" Render: initializeOpenGL()"); - QWindow *win = m_windows.at(0).window; - bool temp = false; - - // Workaround for broken expose logic... We should not get an - // expose when the size of a window is invalid, but we sometimes do. - // On Mac this leads to harmless, yet annoying, console warnings - if (m_windows.at(0).size.isEmpty()) { - temp = true; - win = new QWindow(); - win->setFormat(m_windows.at(0).window->requestedFormat()); - win->setSurfaceType(QWindow::OpenGLSurface); - win->setGeometry(0, 0, 64, 64); - win->create(); - } - - gl = new QOpenGLContext(); - // Pick up the surface format from one of them - gl->setFormat(win->requestedFormat()); - gl->create(); - if (!gl->makeCurrent(win)) - qWarning("QQuickWindow: makeCurrent() failed..."); - sg->initialize(gl); - - if (temp) { - delete win; - } -} - /*! Enters the mutex lock to make sure GUI is blocking and performs sync, then wakes GUI. @@ -692,10 +661,10 @@ void QSGRenderThread::run() while (!shouldExit) { if (m_windows.size() > 0) { - if (!gl) - initializeOpenGL(); - if (!sg->isReady()) + if (!sg->isReady()) { + gl->makeCurrent(m_windows.at(0).window); sg->initialize(gl); + } syncAndRender(); } @@ -879,6 +848,15 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) m_thread->shouldExit = false; RLDEBUG1("GUI: - starting render thread..."); + + if (!m_thread->gl) { + QOpenGLContext *ctx = new QOpenGLContext(); + ctx->setFormat(window->requestedFormat()); + ctx->create(); + ctx->moveToThread(m_thread); + m_thread->gl = ctx; + } + m_thread->start(); } else { |