diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index f035e87d995055dff242b01ff66c50352a850082..bc8558e1d8580048bc7b221f28dbae02dd991128 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -3044,6 +3044,16 @@ QQmlIncubationController *QQuickWindow::incubationController() const do so can result in the scene not rendering properly. */ +/*! + \fn void QQuickWindow::afterAnimating() + + This signal is emitted on the gui thread before requesting the render thread to + perform the synchronization of the scene graph. + + Unlike the other similar signals, this one is emitted on the gui thread instead + of the render thread. It can be used to synchronize external animation systems + with the QML content. + */ /*! diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index 233340d6facb492b4a4378bb09fb360d99bd7ac5..ced232467b2079db248cdcece077c37eab4d4ca8 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -138,6 +138,7 @@ Q_SIGNALS: void beforeSynchronizing(); void beforeRendering(); void afterRendering(); + void afterAnimating(); Q_REVISION(1) void closing(QQuickCloseEvent *close); void colorChanged(const QColor &); Q_REVISION(1) void activeFocusItemChanged(); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 4e8fa67869f896813b47f3edc2df527a13bcc65c..50c5b141c394a4568b3c6aa68ef1d71b5b1badb9 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -302,6 +302,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); cd->polishItems(); + emit window->afterAnimating(); + qint64 renderTime = 0, syncTime = 0; QElapsedTimer renderTimer; bool profileFrames = qsg_render_timing() || QQuickProfiler::enabled; diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index ffc6d31aa70a5d34829cd166dcf1197fefe03d3d..ddf724b89f6927b4353dd14ebe771b7d893768a0 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -1096,6 +1096,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w) w->updateDuringSync = false; + emit w->window->afterAnimating(); + QSG_GUI_DEBUG(w->window, " - lock for sync..."); w->thread->mutex.lock(); m_locked = true; diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 995d80bb826231e01521c777c4c34c41913cdfe8..204a303d2c8cde2864cbf4a5eae29e5968734c6b 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -442,6 +442,8 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) d->polishItems(); QSG_RENDER_TIMING_SAMPLE(time_polished); + emit window->afterAnimating(); + RLDEBUG(" - syncing"); d->syncSceneGraph(); QSG_RENDER_TIMING_SAMPLE(time_synced); diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index bdd70f6a6eb741f10c4ca8969c7313329ccf370c..edde8d2134f74a232cc4b14d6de4b3cc692833ba 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -351,6 +351,8 @@ private slots: void cursor(); #endif + void animatingSignal(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -1657,6 +1659,19 @@ void tst_qquickwindow::qobjectEventFilter_mouse() QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, point); } +void tst_qquickwindow::animatingSignal() +{ + QQuickWindow window; + window.setGeometry(100, 100, 300, 200); + + QSignalSpy spy(&window, SIGNAL(afterAnimating())); + + window.show(); + QTRY_VERIFY(window.isExposed()); + + QTRY_VERIFY(spy.count() > 1); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc"