diff options
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 35 | ||||
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 8 |
2 files changed, 12 insertions, 31 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 68947d3a3c..faa162f541 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -136,6 +136,7 @@ public: void maybeUpdate(QQuickWindow *window); void update(QQuickWindow *window) { maybeUpdate(window); } // identical for this implementation. + void handleUpdateRequest(QQuickWindow *); void releaseResources(QQuickWindow *) { } @@ -144,8 +145,6 @@ public: QSGContext *sceneGraphContext() const; QSGRenderContext *createRenderContext(QSGContext *) const { return rc; } - bool event(QEvent *); - struct WindowData { bool updatePending : 1; bool grabOnly : 1; @@ -158,9 +157,6 @@ public: QSGRenderContext *rc; QImage grabContent; - int m_update_timer; - - bool eventPending; }; QSGRenderLoop *QSGRenderLoop::instance() @@ -264,7 +260,6 @@ void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window, QSGGuiThreadRenderLoop::QSGGuiThreadRenderLoop() : gl(0) - , eventPending(false) { sg = QSGContext::createDefaultContext(); rc = sg->createRenderContext(); @@ -456,45 +451,23 @@ QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window) return grabbed; } - - void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window) { if (!m_windows.contains(window)) return; m_windows[window].updatePending = true; - - if (!eventPending) { - const int exhaust_delay = 5; - m_update_timer = startTimer(exhaust_delay, Qt::PreciseTimer); - eventPending = true; - } + window->requestUpdate(); } - - QSGContext *QSGGuiThreadRenderLoop::sceneGraphContext() const { return sg; } - -bool QSGGuiThreadRenderLoop::event(QEvent *e) +void QSGGuiThreadRenderLoop::handleUpdateRequest(QQuickWindow *window) { - if (e->type() == QEvent::Timer) { - eventPending = false; - killTimer(m_update_timer); - m_update_timer = 0; - for (QHash<QQuickWindow *, WindowData>::const_iterator it = m_windows.constBegin(); - it != m_windows.constEnd(); ++it) { - const WindowData &data = it.value(); - if (data.updatePending) - renderWindow(it.key()); - } - return true; - } - return QObject::event(e); + renderWindow(window); } #include "qsgrenderloop.moc" diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 063386ed8e..6a29dea505 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1280,6 +1280,14 @@ void QQuickWidget::triggerUpdate() Q_D(QQuickWidget); d->updatePending = true; if (!d->eventPending) { + // There's no sense in immediately kicking a render off now, as + // there may be a number of triggerUpdate calls to come from a multitude + // of different sources (network, touch/mouse/keyboard, timers, + // animations, ...), and we want to batch them all into single frames as + // much as possible for the sake of interactivity and responsiveness. + // + // To achieve this, we set a timer and only perform the rendering when + // this is complete. const int exhaustDelay = 5; d->updateTimer.start(exhaustDelay, Qt::PreciseTimer, this); d->eventPending = true; |