aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2023-02-03 13:28:53 +0100
committerFriedemann Kleint <[email protected]>2023-02-09 16:04:00 +0100
commita54890352151e9bef4475a6282199d608de1e175 (patch)
tree83887c6843549a83c6749b49421f4cc3ecd97f4e /src
parent9268c2db58125fa482b1168bd340da53b75fb1a8 (diff)
QtQuick: Fix conflicting definition of helper windowFor in CMake Unity (Jumbo) builds
Make them member functions. As a drive-by use range-based/std::as_const and use QList. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I2fb5632a076b6ccff1bd387bf95cc2ddedd4e0d9 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Laszlo Agocs <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp30
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h4
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp35
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop_p.h2
4 files changed, 37 insertions, 34 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
index 5c5bc8d626..39aa89472f 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp
@@ -499,11 +499,11 @@ void QSGSoftwareRenderThread::syncAndRender()
QQuickProfiler::SceneGraphRenderLoopSwap);
}
-template<class T> T *windowFor(const QVector<T> &list, QQuickWindow *window)
+QSGSoftwareThreadedRenderLoop::WindowData *QSGSoftwareThreadedRenderLoop::windowFor(QQuickWindow *window)
{
- for (const T &t : list) {
+ for (const auto &t : std::as_const(m_windows)) {
if (t.window == window)
- return const_cast<T *>(&t);
+ return const_cast<WindowData *>(&t);
}
return nullptr;
}
@@ -535,7 +535,7 @@ void QSGSoftwareThreadedRenderLoop::hide(QQuickWindow *window)
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "hide" << window;
if (window->isExposed())
- handleObscurity(windowFor(m_windows, window));
+ handleObscurity(windowFor(window));
releaseResources(window);
}
@@ -552,7 +552,7 @@ void QSGSoftwareThreadedRenderLoop::windowDestroyed(QQuickWindow *window)
{
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "window destroyed" << window;
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (!w)
return;
@@ -586,7 +586,7 @@ void QSGSoftwareThreadedRenderLoop::exposureChanged(QQuickWindow *window)
if (window->isExposed()) {
handleExposure(window);
} else {
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (w)
handleObscurity(w);
}
@@ -596,13 +596,13 @@ QImage QSGSoftwareThreadedRenderLoop::grab(QQuickWindow *window)
{
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "grab" << window;
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
// Have to support invisible (but created()'ed) windows as well.
// Unlike with GL, leaving that case for QQuickWindow to handle is not feasible.
const bool tempExpose = !w;
if (tempExpose) {
handleExposure(window);
- w = windowFor(m_windows, window);
+ w = windowFor(window);
Q_ASSERT(w);
}
@@ -633,7 +633,7 @@ QImage QSGSoftwareThreadedRenderLoop::grab(QQuickWindow *window)
void QSGSoftwareThreadedRenderLoop::update(QQuickWindow *window)
{
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (!w)
return;
@@ -650,7 +650,7 @@ void QSGSoftwareThreadedRenderLoop::update(QQuickWindow *window)
void QSGSoftwareThreadedRenderLoop::maybeUpdate(QQuickWindow *window)
{
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (w)
scheduleUpdate(w);
}
@@ -659,7 +659,7 @@ void QSGSoftwareThreadedRenderLoop::handleUpdateRequest(QQuickWindow *window)
{
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "handleUpdateRequest" << window;
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (w)
polishAndSync(w, false);
}
@@ -683,14 +683,14 @@ void QSGSoftwareThreadedRenderLoop::releaseResources(QQuickWindow *window)
{
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "releaseResources" << window;
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (w)
handleResourceRelease(w, false);
}
void QSGSoftwareThreadedRenderLoop::postJob(QQuickWindow *window, QRunnable *job)
{
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (w && w->thread && w->thread->exposedWindow)
w->thread->postEvent(new QSGSoftwareJobEvent(window, job));
else
@@ -774,7 +774,7 @@ void QSGSoftwareThreadedRenderLoop::handleExposure(QQuickWindow *window)
{
qCDebug(QSG_RASTER_LOG_RENDERLOOP) << "handleExposure" << window;
- WindowData *w = windowFor(m_windows, window);
+ WindowData *w = windowFor(window);
if (!w) {
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "adding window to list");
WindowData win;
@@ -904,7 +904,7 @@ void QSGSoftwareThreadedRenderLoop::polishAndSync(QSGSoftwareThreadedRenderLoop:
// Flush pending touch events.
QQuickWindowPrivate::get(window)->deliveryAgentPrivate()->flushFrameSynchronousEvents(window);
// The delivery of the event might have caused the window to stop rendering
- w = windowFor(m_windows, window);
+ w = windowFor(window);
if (!w || !w->thread || !w->thread->exposedWindow) {
qCDebug(QSG_RASTER_LOG_RENDERLOOP, "polishAndSync - removed after touch event flushing, abort");
return;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h
index adb3c401db..02adb28ab3 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop_p.h
@@ -61,6 +61,8 @@ private:
uint forceRenderPass : 1;
};
+ WindowData *windowFor(QQuickWindow *window);
+
void startOrStopAnimationTimer();
void handleExposure(QQuickWindow *window);
void handleObscurity(WindowData *w);
@@ -72,7 +74,7 @@ private:
QAnimationDriver *m_anim;
int animationTimer = 0;
bool lockedForSync = false;
- QVector<WindowData> m_windows;
+ QList<WindowData> m_windows;
friend class QSGSoftwareRenderThread;
};
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 6d94274b60..8c8a9a7ab1 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -92,17 +92,16 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_
// RL: Render Loop
// RT: Render Thread
-template <typename T> T *windowFor(const QList<T> &list, QQuickWindow *window)
+
+QSGThreadedRenderLoop::Window *QSGThreadedRenderLoop::windowFor(QQuickWindow *window)
{
- for (int i=0; i<list.size(); ++i) {
- const T &t = list.at(i);
+ for (const auto &t : std::as_const(m_windows)) {
if (t.window == window)
- return const_cast<T *>(&t);
+ return const_cast<Window *>(&t);
}
return nullptr;
}
-
class WMWindowEvent : public QEvent
{
public:
@@ -1105,7 +1104,7 @@ void QSGThreadedRenderLoop::hide(QQuickWindow *window)
qCDebug(QSG_LOG_RENDERLOOP) << "hide()" << window;
if (window->isExposed())
- handleObscurity(windowFor(m_windows, window));
+ handleObscurity(windowFor(window));
releaseResources(window);
}
@@ -1114,7 +1113,7 @@ void QSGThreadedRenderLoop::resize(QQuickWindow *window)
{
qCDebug(QSG_LOG_RENDERLOOP) << "reisze()" << window;
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (!w)
return;
@@ -1131,7 +1130,7 @@ void QSGThreadedRenderLoop::windowDestroyed(QQuickWindow *window)
{
qCDebug(QSG_LOG_RENDERLOOP) << "begin windowDestroyed()" << window;
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (!w)
return;
@@ -1202,7 +1201,7 @@ void QSGThreadedRenderLoop::exposureChanged(QQuickWindow *window)
if (!skipThisExpose)
handleExposure(window);
} else {
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w)
handleObscurity(w);
}
@@ -1216,7 +1215,7 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window)
{
qCDebug(QSG_LOG_RENDERLOOP) << "handleExposure()" << window;
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (!w) {
qCDebug(QSG_LOG_RENDERLOOP, "- adding window to list");
Window win;
@@ -1326,7 +1325,7 @@ bool QSGThreadedRenderLoop::eventFilter(QObject *watched, QEvent *event)
if (static_cast<QPlatformSurfaceEvent *>(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) {
QQuickWindow *window = qobject_cast<QQuickWindow *>(watched);
if (window) {
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w && w->thread->isRunning()) {
w->thread->mutex.lock();
w->thread->postEvent(new WMReleaseSwapchainEvent(window));
@@ -1351,14 +1350,14 @@ void QSGThreadedRenderLoop::handleUpdateRequest(QQuickWindow *window)
qCDebug(QSG_LOG_RENDERLOOP, "- updatesEnabled is false, abort");
return;
}
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w)
polishAndSync(w);
}
void QSGThreadedRenderLoop::maybeUpdate(QQuickWindow *window)
{
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w)
maybeUpdate(w);
}
@@ -1410,7 +1409,7 @@ void QSGThreadedRenderLoop::maybeUpdate(Window *w)
*/
void QSGThreadedRenderLoop::update(QQuickWindow *window)
{
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (!w)
return;
@@ -1430,7 +1429,7 @@ void QSGThreadedRenderLoop::update(QQuickWindow *window)
void QSGThreadedRenderLoop::releaseResources(QQuickWindow *window)
{
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w)
releaseResources(w, false);
}
@@ -1488,7 +1487,7 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose)
// Flush pending touch events.
QQuickWindowPrivate::get(window)->deliveryAgentPrivate()->flushFrameSynchronousEvents(window);
// The delivery of the event might have caused the window to stop rendering
- w = windowFor(m_windows, window);
+ w = windowFor(window);
if (!w || !w->thread || !w->thread->window) {
qCDebug(QSG_LOG_RENDERLOOP, "- removed after event flushing, abort");
return;
@@ -1692,7 +1691,7 @@ QImage QSGThreadedRenderLoop::grab(QQuickWindow *window)
{
qCDebug(QSG_LOG_RENDERLOOP) << "grab()" << window;
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
Q_ASSERT(w);
if (!w->thread->isRunning())
@@ -1727,7 +1726,7 @@ QImage QSGThreadedRenderLoop::grab(QQuickWindow *window)
*/
void QSGThreadedRenderLoop::postJob(QQuickWindow *window, QRunnable *job)
{
- Window *w = windowFor(m_windows, window);
+ Window *w = windowFor(window);
if (w && w->thread && w->thread->window)
w->thread->postEvent(new WMJobEvent(window, job));
else
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
index 4e0c471ab4..5d209f2f0f 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h
+++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
@@ -76,6 +76,8 @@ private:
friend class QSGRenderThread;
+
+ Window *windowFor(QQuickWindow *window);
void releaseResources(Window *window, bool inDestructor);
bool checkAndResetForceUpdate(QQuickWindow *window);