summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2022-09-14 16:18:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-09-14 16:18:18 +0000
commitf150000736cd00fc7c8bbd8a55131b468244bc07 (patch)
tree04f9898097a1228ef434f110ea81da8d403182ee
parentaa50ac1958f46122f2b5b3ebc66c8012a91dd656 (diff)
parent474c1674ee543f4508800ac12e4928fa761594dd (diff)
Merge "[Optimization] It's no need to start the dispatch cycle going if the outbound queue was not previously empty."
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 5e9427ad87..564acc09f9 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -3640,6 +3640,8 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
target.inputChannel = connection->inputChannel;
target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
+ const bool wasEmpty = connection->outboundQueue.empty();
+
for (size_t i = 0; i < cancelationEvents.size(); i++) {
std::unique_ptr<EventEntry> cancelationEventEntry = std::move(cancelationEvents[i]);
switch (cancelationEventEntry->type) {
@@ -3674,7 +3676,10 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked(
InputTarget::FLAG_DISPATCH_AS_IS);
}
- startDispatchCycleLocked(currentTime, connection);
+ // If the outbound queue was previously empty, start the dispatch cycle going.
+ if (wasEmpty && !connection->outboundQueue.empty()) {
+ startDispatchCycleLocked(currentTime, connection);
+ }
}
void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
@@ -3708,6 +3713,8 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
target.inputChannel = connection->inputChannel;
target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
+ const bool wasEmpty = connection->outboundQueue.empty();
+
for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) {
switch (downEventEntry->type) {
case EventEntry::Type::MOTION: {
@@ -3733,8 +3740,10 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked(
enqueueDispatchEntryLocked(connection, std::move(downEventEntry), target,
InputTarget::FLAG_DISPATCH_AS_IS);
}
-
- startDispatchCycleLocked(currentTime, connection);
+ // If the outbound queue was previously empty, start the dispatch cycle going.
+ if (wasEmpty && !connection->outboundQueue.empty()) {
+ startDispatchCycleLocked(currentTime, connection);
+ }
}
std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent(