From 2bac9b8cd6853f9adc38ac99ed6a14b0cbf417d6 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Thu, 11 Feb 2016 15:44:36 +0900 Subject: [PATCH] Add ttrace Change-Id: I82a316d226c967a396f6ce5671feeafbfb37bd0f --- meson.build | 11 ++++++- packaging/libinput.spec | 2 +- src/evdev-fallback.c | 36 +++++++++++++++++---- src/evdev.c | 4 +++ src/libinput-private.h | 10 ++++++ src/libinput.c | 72 +++++++++++++++++++++++++++++++++++------ 6 files changed, 118 insertions(+), 17 deletions(-) diff --git a/meson.build b/meson.build index e2945611..c37f4599 100644 --- a/meson.build +++ b/meson.build @@ -178,6 +178,14 @@ else dep_libwacom = declare_dependency() endif +############ ttrace configuration ############ + +dep_ttrace = dependency('ttrace', required : false) +if dep_ttrace.found() + config_h.set10('ENABLE_TTRACE', 1) +endif + + ############ udev bits ############ executable('libinput-device-group', @@ -386,7 +394,8 @@ deps_libinput = [ dep_rt, dep_libwacom, dep_libinput_util, - dep_libquirks + dep_libquirks, + dep_ttrace ] libinput_version_h_config = configuration_data() diff --git a/packaging/libinput.spec b/packaging/libinput.spec index af0deada..d666dee2 100644 --- a/packaging/libinput.spec +++ b/packaging/libinput.spec @@ -16,7 +16,7 @@ BuildRequires: pkgconfig(libevdev) BuildRequires: pkgconfig(libevent) BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(mtdev) -BuildRequires: pkgconfig(wacom) +BuildRequires: pkgconfig(ttrace) %description diff --git a/src/evdev-fallback.c b/src/evdev-fallback.c index 87fd26f6..49be0fc5 100644 --- a/src/evdev-fallback.c +++ b/src/evdev-fallback.c @@ -173,8 +173,12 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch, struct libinput_device *base = &device->base; struct normalized_coords accel; - if (!(device->seat_caps & EVDEV_DEVICE_POINTER)) + TRACE_BEGIN(fallback_flush_relative_motion); + + if (!(device->seat_caps & EVDEV_DEVICE_POINTER)) { + TRACE_END(); return; + } struct device_float_coords raw = fallback_rotate_relative(dispatch, device); @@ -182,8 +186,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch, dispatch->rel.y = 0; /* Use unaccelerated deltas for pointing stick scroll */ - if (post_button_scroll(device, raw, time)) + if (post_button_scroll(device, raw, time)) { + TRACE_END(); return; + } if (device->pointer.filter) { /* Apply pointer acceleration. */ @@ -197,10 +203,13 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch, accel.x = accel.y = 0; } - if (normalized_is_zero(accel)) + if (normalized_is_zero(accel)) { + TRACE_END(); return; + } pointer_notify_motion(base, time, &accel, &raw); + TRACE_END(); } static void @@ -480,9 +489,13 @@ fallback_process_key(struct fallback_dispatch *dispatch, { enum key_type type; + TRACE_BEGIN(fallbak_process_key); + /* ignore kernel key repeat */ - if (e->value == 2) + if (e->value == 2) { + TRACE_END(); return; + } if (e->code == BTN_TOUCH) { if (!device->is_mt) @@ -490,6 +503,7 @@ fallback_process_key(struct fallback_dispatch *dispatch, device, time, e->value); + TRACE_END(); return; } @@ -504,8 +518,10 @@ fallback_process_key(struct fallback_dispatch *dispatch, case KEY_TYPE_KEY: case KEY_TYPE_BUTTON: if ((e->value && hw_is_key_down(dispatch, e->code)) || - (e->value == 0 && !hw_is_key_down(dispatch, e->code))) + (e->value == 0 && !hw_is_key_down(dispatch, e->code))) { + TRACE_END(); return; + } dispatch->pending_event |= EVDEV_KEY; break; @@ -528,6 +544,7 @@ fallback_process_key(struct fallback_dispatch *dispatch, case KEY_TYPE_BUTTON: break; } + TRACE_END(); } static void @@ -786,8 +803,12 @@ fallback_process_relative(struct fallback_dispatch *dispatch, struct evdev_device *device, struct input_event *e, uint64_t time) { - if (fallback_reject_relative(device, e, time)) + TRACE_BEGIN(fallback_process_relative); + + if (fallback_reject_relative(device, e, time)) { + TRACE_END(); return; + } switch (e->code) { case REL_X: @@ -801,6 +822,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch, } fallback_wheel_process_relative(dispatch, device, e, time); + TRACE_END(); } static inline void @@ -809,11 +831,13 @@ fallback_process_absolute(struct fallback_dispatch *dispatch, struct input_event *e, uint64_t time) { + TRACE_BEGIN(fallback_process_absolute); if (device->is_mt) { fallback_process_touch(dispatch, device, e, time); } else { fallback_process_absolute_motion(dispatch, device, e); } + TRACE_END(); } static inline bool diff --git a/src/evdev.c b/src/evdev.c index cc02e7bb..6ff76385 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1106,7 +1106,11 @@ evdev_process_event(struct evdev_device *device, struct input_event *e) libinput_timer_flush(evdev_libinput_context(device), time); + TRACE_BEGIN(evdev_process_event); + dispatch->interface->process(dispatch, device, e, time); + + TRACE_END(); } static inline void diff --git a/src/libinput-private.h b/src/libinput-private.h index c282e350..19cec18b 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -42,6 +42,16 @@ #include "libinput-util.h" #include "libinput-version.h" +#ifdef ENABLE_TTRACE +#include + +#define TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, "INPUT:LIBINPUT:"#NAME) +#define TRACE_END() traceEnd(TTRACE_TAG_INPUT) +#else +#define TRACE_BEGIN(NAME) +#define TRACE_END() +#endif + struct libinput_source; /* A coordinate pair in device coordinates */ diff --git a/src/libinput.c b/src/libinput.c index 94bdff9c..640ef0ee 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -2481,6 +2481,8 @@ notify_added_device(struct libinput_device *device) { struct libinput_event_device_notify *added_device_event; + TRACE_BEGIN(notify_added_device); + added_device_event = zalloc(sizeof *added_device_event); post_base_event(device, @@ -2492,6 +2494,7 @@ notify_added_device(struct libinput_device *device) * pretend to free it */ free(added_device_event); #endif + TRACE_END(); } void @@ -2499,6 +2502,8 @@ notify_removed_device(struct libinput_device *device) { struct libinput_event_device_notify *removed_device_event; + TRACE_BEGIN(notify_removed_device); + removed_device_event = zalloc(sizeof *removed_device_event); post_base_event(device, @@ -2510,6 +2515,7 @@ notify_removed_device(struct libinput_device *device) * pretend to free it */ free(removed_device_event); #endif + TRACE_END(); } static inline bool @@ -2562,8 +2568,12 @@ keyboard_notify_key(struct libinput_device *device, struct libinput_event_keyboard *key_event; uint32_t seat_key_count; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) + TRACE_BEGIN(keyboard_notify_key); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) { + TRACE_END(); return; + } key_event = zalloc(sizeof *key_event); @@ -2579,6 +2589,8 @@ keyboard_notify_key(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_KEYBOARD_KEY, &key_event->base); + + TRACE_END(); } void @@ -2589,9 +2601,13 @@ pointer_notify_motion(struct libinput_device *device, { struct libinput_event_pointer *motion_event; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) - return; + TRACE_BEGIN(pointer_notify_motion); + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) { + TRACE_END(); + return; + } + motion_event = zalloc(sizeof *motion_event); *motion_event = (struct libinput_event_pointer) { @@ -2603,6 +2619,8 @@ pointer_notify_motion(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_POINTER_MOTION, &motion_event->base); + + TRACE_END(); } void @@ -2612,8 +2630,12 @@ pointer_notify_motion_absolute(struct libinput_device *device, { struct libinput_event_pointer *motion_absolute_event; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) + TRACE_BEGIN(pointer_notify_motion_absolute); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) { + TRACE_END(); return; + } motion_absolute_event = zalloc(sizeof *motion_absolute_event); @@ -2625,6 +2647,8 @@ pointer_notify_motion_absolute(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, &motion_absolute_event->base); + + TRACE_END(); } void @@ -2636,8 +2660,12 @@ pointer_notify_button(struct libinput_device *device, struct libinput_event_pointer *button_event; int32_t seat_button_count; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) + TRACE_BEGIN(pointer_notify_button); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) { + TRACE_END(); return; + } button_event = zalloc(sizeof *button_event); @@ -2655,6 +2683,8 @@ pointer_notify_button(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_POINTER_BUTTON, &button_event->base); + + TRACE_END(); } void @@ -2735,8 +2765,12 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device, struct libinput_event_pointer *axis_event; const struct wheel_v120 zero_v120 = {0}; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) + TRACE_BEGIN(pointer_notify_axis); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) { + TRACE_END(); return; + } axis_event = zalloc(sizeof *axis_event); @@ -2752,6 +2786,8 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_POINTER_AXIS, &axis_event->base); + + TRACE_END(); } void @@ -2796,8 +2832,12 @@ touch_notify_touch_down(struct libinput_device *device, { struct libinput_event_touch *touch_event; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) + TRACE_BEGIN(touch_notify_touch_down); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) { + TRACE_END(); return; + } touch_event = zalloc(sizeof *touch_event); @@ -2813,6 +2853,8 @@ touch_notify_touch_down(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_TOUCH_DOWN, &touch_event->base); + + TRACE_END(); } void @@ -2826,8 +2868,12 @@ touch_notify_touch_motion(struct libinput_device *device, { struct libinput_event_touch *touch_event; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) + TRACE_BEGIN(touch_notify_touch_motion); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) { + TRACE_END(); return; + } touch_event = zalloc(sizeof *touch_event); @@ -2843,6 +2889,8 @@ touch_notify_touch_motion(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_TOUCH_MOTION, &touch_event->base); + + TRACE_END(); } void @@ -2853,8 +2901,12 @@ touch_notify_touch_up(struct libinput_device *device, { struct libinput_event_touch *touch_event; - if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) + TRACE_BEGIN(touch_notify_touch_up); + + if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) { + TRACE_END(); return; + } touch_event = zalloc(sizeof *touch_event); @@ -2867,6 +2919,8 @@ touch_notify_touch_up(struct libinput_device *device, post_device_event(device, time, LIBINPUT_EVENT_TOUCH_UP, &touch_event->base); + + TRACE_END(); } void -- 2.34.1