Commit b8b3a95c authored by Tomi Korpipää's avatar Tomi Korpipää
Browse files

Getting rid of invokeMethod calls


Change-Id: I3687682d0cae4eff4259e171bca2fa11c08b561f
Reviewed-by: default avatarPasi Keränen <pasi.keranen@digia.com>
Showing with 11 additions and 14 deletions
...@@ -103,6 +103,7 @@ Canvas::Canvas(QQuickItem *parent): ...@@ -103,6 +103,7 @@ Canvas::Canvas(QQuickItem *parent):
{ {
if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__; if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__;
connect(this, &QQuickItem::windowChanged, this, &Canvas::handleWindowChanged); connect(this, &QQuickItem::windowChanged, this, &Canvas::handleWindowChanged);
connect(this, &Canvas::needRender, this, &Canvas::renderNext, Qt::QueuedConnection);
setAntialiasing(false); setAntialiasing(false);
// Set contents to false in case we are in qml designer to make component look nice // Set contents to false in case we are in qml designer to make component look nice
...@@ -124,16 +125,14 @@ Canvas::~Canvas() ...@@ -124,16 +125,14 @@ Canvas::~Canvas()
*/ */
void Canvas::shutDown() void Canvas::shutDown()
{ {
if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__;
if (!m_glContext) if (!m_glContext)
return; return;
if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__;
disconnect(m_contextWindow, 0, this, 0); disconnect(m_contextWindow, 0, this, 0);
disconnect(this, 0, this, 0); disconnect(this, 0, this, 0);
if (m_logAllCalls) qDebug() << QOpenGLContext::currentContext() << m_glContext << m_glContextQt;
m_glContext->makeCurrent(m_offscreenSurface); m_glContext->makeCurrent(m_offscreenSurface);
delete m_renderFbo; delete m_renderFbo;
delete m_displayFbo; delete m_displayFbo;
...@@ -407,7 +406,7 @@ void Canvas::handleWindowChanged(QQuickWindow *window) ...@@ -407,7 +406,7 @@ void Canvas::handleWindowChanged(QQuickWindow *window)
if (!window) if (!window)
return; return;
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
} }
/*! /*!
...@@ -420,7 +419,7 @@ void Canvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometr ...@@ -420,7 +419,7 @@ void Canvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometr
m_cachedGeometry = newGeometry; m_cachedGeometry = newGeometry;
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
} }
/*! /*!
...@@ -431,7 +430,7 @@ void Canvas::itemChange(ItemChange change, const ItemChangeData &value) ...@@ -431,7 +430,7 @@ void Canvas::itemChange(ItemChange change, const ItemChangeData &value)
if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__ << change; if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__ << change;
QQuickItem::itemChange(change, value); QQuickItem::itemChange(change, value);
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
} }
/*! /*!
...@@ -482,7 +481,7 @@ void Canvas::setAnimated(bool animated) ...@@ -482,7 +481,7 @@ void Canvas::setAnimated(bool animated)
if (animated != m_isAnimated) { if (animated != m_isAnimated) {
m_isAnimated = animated; m_isAnimated = animated;
emit animatedChanged(animated); emit animatedChanged(animated);
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
} }
} }
...@@ -525,8 +524,7 @@ void Canvas::ready() ...@@ -525,8 +524,7 @@ void Canvas::ready()
if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__; if (m_logAllCalls) qDebug() << "Canvas3D::" << __FUNCTION__;
connect(window(), &QQuickWindow::sceneGraphInvalidated, connect(window(), &QQuickWindow::sceneGraphInvalidated,
this, &Canvas::shutDown, this, &Canvas::shutDown);
Qt::QueuedConnection);
update(); update();
} }
...@@ -553,8 +551,7 @@ QSGNode *Canvas::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) ...@@ -553,8 +551,7 @@ QSGNode *Canvas::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
if (!m_glContextQt) { if (!m_glContextQt) {
m_glContextQt = window()->openglContext(); m_glContextQt = window()->openglContext();
ready();
QMetaObject::invokeMethod(this, "ready");
return 0; return 0;
} }
...@@ -592,13 +589,13 @@ QSGNode *Canvas::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) ...@@ -592,13 +589,13 @@ QSGNode *Canvas::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
Qt::QueuedConnection); Qt::QueuedConnection);
// Get the production of FBO textures started.. // Get the production of FBO textures started..
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
update(); update();
} }
node->setRect(boundingRect()); node->setRect(boundingRect());
QMetaObject::invokeMethod(this, "renderNext", Qt::QueuedConnection); emit needRender();
m_renderNodeReady = true; m_renderNodeReady = true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment