summaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-05-27 11:49:33 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-08-07 08:51:10 +0200
commit8daa8bcb8e9a7110289d15c94f53a4be9adac1ac (patch)
tree56330947d547e59efd9b08182a51589d82be5049 /src/input
parentfd64e870fad0e619704e79689f20645760dbdc0e (diff)
Remove the Aspect Thread
This now makes the Qt3D simulation loop run in the Main Thread. In theory having the Aspect Thread allowed Qt3D to continue rendering even if the main thread got locked. In practice however this leads to a large amount of complexities in the Qt3D implementations and provides little value as in most cases blocking the main thread would block animations driven by frontend nodes. Removing the Aspect Thread will allow to remove the backend tree copies each aspect had to make which will allow to reduce memory. In addition, getting direct access to frontend nodes, will now be possible without introducing races which should allow to make more optimizations and reduce latencies on some operations. Change-Id: I80e4cd6427de06ddedfa1bb50d40710b91867b24 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r--src/input/backend/eventsourcesetterhelper.cpp25
-rw-r--r--src/input/backend/eventsourcesetterhelper_p.h6
-rw-r--r--src/input/backend/inputhandler.cpp20
-rw-r--r--src/input/backend/mousedevice.cpp1
4 files changed, 17 insertions, 35 deletions
diff --git a/src/input/backend/eventsourcesetterhelper.cpp b/src/input/backend/eventsourcesetterhelper.cpp
index bbc7ea54c..fe800a1a4 100644
--- a/src/input/backend/eventsourcesetterhelper.cpp
+++ b/src/input/backend/eventsourcesetterhelper.cpp
@@ -56,21 +56,21 @@ EventSourceSetterHelper::EventSourceSetterHelper(InputHandler *inputHandler)
{
}
-// Aspect thread
+// Main thread
void EventSourceSetterHelper::setEventFilterService(Qt3DCore::QEventFilterService *service)
{
- QMutexLocker lock(&m_mutex);
m_service = service;
}
-// Any thread
+// Main thread
void EventSourceSetterHelper::setEventSource(QObject *eventSource)
{
if (eventSource && m_lastEventSource != eventSource) {
- QMetaObject::invokeMethod(this,
- "setEventSourceHelper",
- Qt::BlockingQueuedConnection,
- Q_ARG(QObject*, eventSource));
+ if (m_service) {
+ m_service->initialize(eventSource);
+ m_inputHandler->registerEventFilters(m_service);
+ m_lastEventSource = eventSource;
+ }
}
}
@@ -83,17 +83,6 @@ void EventSourceSetterHelper::unsetEventSource(QObject *eventSource)
}
}
-// Main Thread
-void EventSourceSetterHelper::setEventSourceHelper(QObject *eventSource)
-{
- QMutexLocker lock(&m_mutex);
- if (m_service) {
- m_service->initialize(eventSource);
- m_inputHandler->registerEventFilters(m_service);
- m_lastEventSource = eventSource;
- }
-}
-
} // Input
} // Qt3DInput
diff --git a/src/input/backend/eventsourcesetterhelper_p.h b/src/input/backend/eventsourcesetterhelper_p.h
index 48418f1b9..b8800d8a6 100644
--- a/src/input/backend/eventsourcesetterhelper_p.h
+++ b/src/input/backend/eventsourcesetterhelper_p.h
@@ -75,14 +75,10 @@ public:
// Called from aspect thread
void setEventFilterService(Qt3DCore::QEventFilterService *service);
- // Called from any thread
+ // Called from main thread
void setEventSource(QObject *eventSource);
void unsetEventSource(QObject *eventSource);
-private Q_SLOTS:
- // Called in main thread
- void setEventSourceHelper(QObject *);
-
private:
Qt3DCore::QEventFilterService *m_service;
InputHandler *m_inputHandler;
diff --git a/src/input/backend/inputhandler.cpp b/src/input/backend/inputhandler.cpp
index 18559e9d4..9484909ab 100644
--- a/src/input/backend/inputhandler.cpp
+++ b/src/input/backend/inputhandler.cpp
@@ -127,58 +127,55 @@ void InputHandler::unregisterEventFilters(Qt3DCore::QEventFilterService *service
// Called by the keyboardEventFilter in the main thread
void InputHandler::appendKeyEvent(const QT_PREPEND_NAMESPACE(QKeyEvent) &event)
{
- QMutexLocker lock(&m_mutex);
m_pendingKeyEvents.append(event);
}
-// Called by QInputASpect::jobsToExecute (aspectThread)
+// Called by QInputASpect::jobsToExecute (Main Thread)
QList<QT_PREPEND_NAMESPACE(QKeyEvent)> InputHandler::pendingKeyEvents()
{
- QMutexLocker lock(&m_mutex);
return std::move(m_pendingKeyEvents);
}
-// Called by QInputASpect::jobsToExecute (aspectThread)
+// Called by QInputASpect::jobsToExecute (Main Thread)
void InputHandler::clearPendingKeyEvents()
{
- QMutexLocker lock(&m_mutex);
m_pendingKeyEvents.clear();
}
+// Main Thread
void InputHandler::appendMouseEvent(const QT_PREPEND_NAMESPACE(QMouseEvent) &event)
{
- QMutexLocker lock(&m_mutex);
m_pendingMouseEvents.append(event);
}
+// Main Thread
QList<QT_PREPEND_NAMESPACE(QMouseEvent)> InputHandler::pendingMouseEvents()
{
- QMutexLocker lock(&m_mutex);
return std::move(m_pendingMouseEvents);
}
+// Main Thread
void InputHandler::clearPendingMouseEvents()
{
- QMutexLocker lock(&m_mutex);
m_pendingMouseEvents.clear();
}
#if QT_CONFIG(wheelevent)
+// Main Thread
void InputHandler::appendWheelEvent(const QT_PREPEND_NAMESPACE(QWheelEvent) &event)
{
- QMutexLocker lock(&m_mutex);
m_pendingWheelEvents.append(event);
}
+// Main Thread
QList<QT_PREPEND_NAMESPACE (QWheelEvent)> Qt3DInput::Input::InputHandler::pendingWheelEvents()
{
- QMutexLocker lock(&m_mutex);
return std::move(m_pendingWheelEvents);
}
+// Main Thread
void InputHandler::clearPendingWheelEvents()
{
- QMutexLocker lock(&m_mutex);
m_pendingWheelEvents.clear();
}
#endif
@@ -253,7 +250,6 @@ QVector<Qt3DCore::QAspectJobPtr> InputHandler::mouseJobs()
#if QT_CONFIG(wheelevent)
const QList<QT_PREPEND_NAMESPACE(QWheelEvent)> wheelEvents = pendingWheelEvents();
#endif
-
for (const HMouseDevice &cHandle : qAsConst(m_activeMouseDevices)) {
MouseDevice *controller = m_mouseDeviceManager->data(cHandle);
diff --git a/src/input/backend/mousedevice.cpp b/src/input/backend/mousedevice.cpp
index 128988637..e285783b7 100644
--- a/src/input/backend/mousedevice.cpp
+++ b/src/input/backend/mousedevice.cpp
@@ -150,6 +150,7 @@ void MouseDevice::updateWheelEvents(const QList<QT_PREPEND_NAMESPACE (QWheelEven
}
#endif
+// Main Thread
void MouseDevice::updateMouseEvents(const QList<QT_PREPEND_NAMESPACE(QMouseEvent)> &events)
{
// Reset axis values before we accumulate new values for this frame