diff options
Diffstat (limited to 'examples/quick/scenegraph')
-rw-r--r-- | examples/quick/scenegraph/textureinthread/threadrenderer.cpp | 30 | ||||
-rw-r--r-- | examples/quick/scenegraph/textureinthread/threadrenderer.h | 3 |
2 files changed, 10 insertions, 23 deletions
diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp index 7de1d294ba..072b4b9f0b 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp @@ -79,6 +79,7 @@ public: m_context = new QOpenGLContext(); m_context->setShareContext(context); m_context->setFormat(context->format()); + m_context->create(); m_context->moveToThread(this); // We need a non-visible surface to make current in the other thread @@ -93,9 +94,6 @@ public: public slots: void renderNext() { - if (!m_context->isValid()) - m_context->create(); - m_context->makeCurrent(m_fakeSurface); if (!m_renderFbo) { @@ -234,30 +232,22 @@ ThreadRenderer::ThreadRenderer() : m_renderThread(0) { setFlag(ItemHasContents, true); - polish(); -} - -void ThreadRenderer::updatePolish() -{ - if (!window() || !window()->openglContext()) - return; - - m_renderThread = new RenderThread(QSize(512, 512), window()->openglContext()); - m_renderThread->moveToThread(m_renderThread); - m_renderThread->start(); - connect(window(), SIGNAL(sceneGraphInvalidated()), m_renderThread, SLOT(shutDown()), Qt::QueuedConnection); } QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { + TextureNode *node = static_cast<TextureNode *>(oldNode); + if (!m_renderThread) { - polish(); - update(); - return 0; + QOpenGLContext *current = window()->openglContext(); + current->doneCurrent(); + m_renderThread = new RenderThread(QSize(512, 512), current); + current->makeCurrent(window()); + m_renderThread->moveToThread(m_renderThread); + m_renderThread->start(); + connect(window(), SIGNAL(sceneGraphInvalidated()), m_renderThread, SLOT(shutDown()), Qt::QueuedConnection); } - TextureNode *node = static_cast<TextureNode *>(oldNode); - if (!node) { node = new TextureNode(window()); diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.h b/examples/quick/scenegraph/textureinthread/threadrenderer.h index 8c68e27d92..7f720cb45a 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.h +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.h @@ -54,9 +54,6 @@ public: static QList<QThread *> threads; -public slots: - void updatePolish(); - protected: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); |