From b41c106f3c84ae84c51e3f83d70548f4f3f08c5e Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 22 Mar 2016 18:40:26 -0700 Subject: [PATCH] Only set the context once per QML surface --- libraries/gl/src/gl/OffscreenQmlSurface.cpp | 22 +++------------------ 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 563c590874..6056e8234f 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -214,22 +214,19 @@ void OffscreenQmlRenderThread::init() { connect(_renderControl, &QQuickRenderControl::sceneChanged, _surface, &OffscreenQmlSurface::requestUpdate); if (!_canvas.makeCurrent()) { - qWarning("Failed to make context current on render thread"); + // Failed to make GL context current, this OffscreenQmlSurface is basically dead + qWarning("Failed to make context current on QML Renderer Thread"); return; } + _renderControl->initialize(_canvas.getContext()); setupFbo(); _escrow.setRecycler([this](GLuint texture){ _textures.recycleTexture(texture); }); - _canvas.doneCurrent(); } void OffscreenQmlRenderThread::cleanup() { - if (!_canvas.makeCurrent()) { - qFatal("Failed to make context current on render thread"); - return; - } _renderControl->invalidate(); _fbo.reset(); @@ -237,7 +234,6 @@ void OffscreenQmlRenderThread::cleanup() { _textures.clear(); _canvas.doneCurrent(); - _canvas.getContextObject()->moveToThread(QCoreApplication::instance()->thread()); _quit = true; @@ -267,18 +263,11 @@ void OffscreenQmlRenderThread::resize() { } _size = newOffscreenSize; - // Clear out any fbos with the old size - if (!_canvas.makeCurrent()) { - qWarning("Failed to make context current on render thread"); - return; - } - qDebug() << "Offscreen UI resizing to " << _newSize.width() << "x" << _newSize.height() << " with pixel ratio " << pixelRatio; locker.unlock(); setupFbo(); - _canvas.doneCurrent(); } void OffscreenQmlRenderThread::render() { @@ -287,11 +276,6 @@ void OffscreenQmlRenderThread::render() { return; } - if (!_canvas.makeCurrent()) { - qWarning("Failed to make context current on render thread"); - return; - } - QMutexLocker locker(&_mutex); _renderControl->sync(); _waitCondition.wakeOne();