Skip to contentSkip to conversation

input: improve performance of mouse event handle

PATCH New FelixYao 1 participant 1 message Nov 27, 2018

lore
Share & tools
lore

FelixYao

author
#0 lore raw

PATCH 1/1 input: improve performance of mouse event handle

Hi Gerd Hoffmann:

Qemu doesn't put mouse event into queue. It handle mouse event one by one independently. So, I think there is no need to use g_new0 to malloc memory dynamically. Using local variable can improve event handle performance.

I have tested this patch in my platform. after applying this patch. Time of handling 100,000 mouse move events changes from 50ms to 9ms.

Please review it and consider whether it can be applied!

---
 include/ui/input.h |  7 ++++---
 ui/input.c         | 47 +++++++++++++++++++++++++----------------------
 2 files changed, 29 insertions(+), 25 deletions(-)
include/ui/input.h +4 -3
index 34ebc67..bb5e782 100644
@@ -49,7 +49,8 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
                                      int *codes);
 int qemu_input_linux_to_qcode(unsigned int lnx);
 
-InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
+void qemu_input_event_set_btn(InputButton btn, bool down,
+                            InputEvent *evt, InputBtnEvent *button_evt);
 void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
 void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
                                uint32_t button_old, uint32_t button_new);
@@ -58,8 +59,8 @@ bool qemu_input_is_absolute(void);
 int qemu_input_scale_axis(int value,
                           int min_in, int max_in,
                           int min_out, int max_out);
-InputEvent *qemu_input_event_new_move(InputEventKind kind,
-                                      InputAxis axis, int value);
+void qemu_input_event_set_move(InputEventKind kind, InputAxis axis, int value,
+                               InputEvent *evt, InputMoveEvent *move);
 void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
 void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
                           int min_in, int max_in);
ui/input.c +25 -22

84 lines not on this page · raw message

Signature · 1 line
1.8.3.1