From cfcf900910f7f899746043c818ebbf13b8b7e622 Mon Sep 17 00:00:00 2001 From: Mykyta Biliavskyi Date: Fri, 22 Dec 2017 13:56:06 +0200 Subject: [PATCH] Profiling Viewer: improve UI. Summary: Due to latest changes in Profiling Viewer project the UI was updated. Added toolbar with next buttons: - Start/stop processing data from eina_debug. - Update displayed interval by latest received data. - Open filters dialog window. - Open find dialog window . - Open time range dialog window. - Open preference window (disable until not merged into Profiling Viewer project master branch.) Reviewers: Deepwarrior, i.furs Reviewed By: Deepwarrior Tags: PHID-PROJ-r7aoq2gq7sou6dugjj5o, #clouseau Maniphest Tasks: T6348 Differential Revision: https://phab.enlightenment.org/D5443 --- src/lib/extensions/profiling_viewer/main.c | 285 ++++++++++++++++++--- 1 file changed, 247 insertions(+), 38 deletions(-) diff --git a/src/lib/extensions/profiling_viewer/main.c b/src/lib/extensions/profiling_viewer/main.c index 293ea20..fe786e9 100644 --- a/src/lib/extensions/profiling_viewer/main.c +++ b/src/lib/extensions/profiling_viewer/main.c @@ -8,17 +8,25 @@ typedef enum { - STREAM_STOPPED = 0, - STREAM_PROCESSING, - STREAM_PAUSED + STREAM_PAUSED = 0, + STREAM_PROCESSING } CLOUSEAU_PROFILER_STATUS; typedef struct { Evas_Object *profiler; Ecore_Timer *record_get_timer; + CLOUSEAU_PROFILER_STATUS status; /*<< 0 - stopped, 1 - processing, 2 - paused */ struct { - CLOUSEAU_PROFILER_STATUS status; /*<< 0 - stopped, 1 - processing, 2 - paused */ - } stream; + Evas_Object *obj; + Evas_Object *status_btn; + Evas_Object *follow_btn; + Evas_Object *filters_btn; + Evas_Object *find_btn; + Evas_Object *time_range_btn; + Evas_Object *setting_btn; + } toolbar; + Eina_Bool follow; + Eina_Bool block_processed; } Inf; static int _clouseau_profiling_extension_log_dom = 0; @@ -28,6 +36,7 @@ static int _record_off_op = EINA_DEBUG_OPCODE_INVALID; static int _record_get_op = EINA_DEBUG_OPCODE_INVALID; static Eina_Bool _record_get_cb(Eina_Debug_Session *, int, void *, int); +static void _follow_interval_status_change_cb(void *data, Evas_Object *obj, void *event_info); EINA_DEBUG_OPCODES_ARRAY_DEFINE(_ops, {"CPU/Freq/on", &_record_on_op, NULL}, @@ -36,7 +45,6 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_ops, {NULL, NULL, NULL} ); - EAPI const char * extension_name_get() { @@ -51,18 +59,6 @@ _record_request_cb(void *data) return EINA_TRUE; } -static void -_stream_processing_pause_cb(void *data, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - Clouseau_Extension *ext = data; - Inf *inf = ext->data; - - eina_debug_session_send(ext->session, ext->app_id, _record_off_op, NULL, 0); - ecore_timer_del(inf->record_get_timer); -} - static void _stream_processing_resume_cb(void *data, Evas_Object *obj EINA_UNUSED, @@ -79,21 +75,10 @@ _stream_processing_resume_cb(void *data, static void _session_changed(Clouseau_Extension *ext) { - Inf *inf = ext->data; int i = 0; Eina_Debug_Opcode *ops = _ops(); + Inf *inf = ext->data; - switch (inf->stream.status) - { - case STREAM_PROCESSING: - evas_object_smart_callback_call(inf->profiler, "stream,processing,pause", NULL); - break; - case STREAM_PAUSED: - case STREAM_STOPPED: - default: - evas_object_smart_callback_call(inf->profiler, "stream,processing,resume", NULL); - - } EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Session changed"); while (ops[i].opcode_name) @@ -101,12 +86,24 @@ _session_changed(Clouseau_Extension *ext) if (ops[i].opcode_id) *(ops[i].opcode_id) = EINA_DEBUG_OPCODE_INVALID; i++; } + if (ext->session) { eina_debug_session_data_set(ext->session, ext); eina_debug_opcodes_register(ext->session, ops, NULL, NULL); } + /*disable controls on toolbar */ + elm_object_disabled_set(inf->toolbar.status_btn, EINA_TRUE); + elm_object_disabled_set(inf->toolbar.follow_btn, EINA_TRUE); + + if (!inf->block_processed) + { + elm_object_disabled_set(inf->toolbar.filters_btn, EINA_TRUE); + elm_object_disabled_set(inf->toolbar.time_range_btn, EINA_TRUE); + elm_object_disabled_set(inf->toolbar.find_btn, EINA_TRUE); + } + return; } @@ -114,8 +111,19 @@ static void _app_changed(Clouseau_Extension *ext) { Inf *inf = ext->data; - evas_object_smart_callback_call(inf->profiler, "stream,processing,stop", &ext->app_id); + evas_object_smart_callback_call(inf->profiler, "stream,app,changed", &ext->app_id); EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Application changed"); + + /*enable controls on toolbar */ + elm_object_disabled_set(inf->toolbar.status_btn, EINA_FALSE); + elm_object_disabled_set(inf->toolbar.follow_btn, EINA_FALSE); + elm_object_disabled_set(inf->toolbar.filters_btn, EINA_TRUE); + elm_object_disabled_set(inf->toolbar.time_range_btn, EINA_TRUE); + elm_object_disabled_set(inf->toolbar.find_btn, EINA_TRUE); + _follow_interval_status_change_cb(ext, inf->toolbar.follow_btn, NULL); + + inf->block_processed = EINA_FALSE; + return; } @@ -130,7 +138,15 @@ _profiling_import(Clouseau_Extension *ext, Stream_Block_Data block_data = { .size = size, .data = buffer }; evas_object_smart_callback_call(inf->profiler, "stream,block,process", &block_data); + inf->block_processed = EINA_TRUE; _stream_processing_resume_cb(ext,NULL, NULL); + if (inf->block_processed) + { + elm_object_disabled_set(inf->toolbar.filters_btn, EINA_FALSE); + elm_object_disabled_set(inf->toolbar.time_range_btn, EINA_FALSE); + elm_object_disabled_set(inf->toolbar.find_btn, EINA_FALSE); + } + return; } @@ -141,20 +157,212 @@ _record_get_cb(Eina_Debug_Session *session, int cid EINA_UNUSED, void *buffer, i _profiling_import(ext, buffer, size, -1); return EINA_TRUE; } + +static void +_find_dialog_show_cb(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + evas_object_smart_callback_call(inf->profiler, "find,show", NULL); +} + +static void +_time_range_dialog_show_cb(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + evas_object_smart_callback_call(inf->profiler, "time,interval,win", NULL); +} + +static void +_filters_dialog_show_cb(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + evas_object_smart_callback_call(inf->profiler, "filters,show", NULL); +} + +static void +_unfollow_interval_cb(void *data, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + Evas_Object *icon = NULL; + + evas_object_smart_callback_call(inf->profiler, "unfollow,processed,data", NULL); + inf->follow = EINA_FALSE; + icon = elm_object_part_content_get(inf->toolbar.follow_btn, "icon"); + elm_icon_standard_set(icon, "go-last"); +} + +static void +_follow_interval_status_change_cb(void *data, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + char *icon_name = NULL; + Evas_Object *icon = NULL; + + if (inf->follow) + { + evas_object_smart_callback_call(inf->profiler, "unfollow,processed,data", NULL); + inf->follow = EINA_FALSE; + icon_name = "go-last"; + } + else + { + evas_object_smart_callback_call(inf->profiler, "follow,processed,data", NULL); + inf->follow = EINA_TRUE; + icon_name = "go-bottom"; + } + icon = elm_object_part_content_get(obj, "icon"); + elm_icon_standard_set(icon, icon_name); +} + +static void +_profiling_status_change_cb(void *data, + Evas_Object *obj, + void *event_info EINA_UNUSED) +{ + Clouseau_Extension *ext = (Clouseau_Extension *)data; + Inf *inf = ext->data; + char *icon_name = NULL; + Evas_Object *icon = NULL; + + switch (inf->status) + { + case STREAM_PROCESSING: + { + eina_debug_session_send(ext->session, ext->app_id, _record_off_op, NULL, 0); + ecore_timer_del(inf->record_get_timer); + inf->status = STREAM_PAUSED; + icon_name = "media-playback-start"; + break; + } + case STREAM_PAUSED: + { + eina_debug_session_send(ext->session, ext->app_id, _record_on_op, NULL, 0); + inf->record_get_timer = NULL; + _stream_processing_resume_cb(ext,NULL, NULL); + inf->status = STREAM_PROCESSING; + icon_name = "media-playback-pause"; + break; + } + } + icon = elm_object_part_content_get(obj, "icon"); + elm_icon_standard_set(icon, icon_name); +} + static Eo * _ui_get(Clouseau_Extension *ext, Eo *parent) { Inf *inf = ext->data; - inf->profiler = efl_profiling_viewer_init(parent); + Evas_Object *toolbar = NULL; + Evas_Object *box = NULL; + Evas_Object *button = NULL, *icon = NULL; + Elm_Object_Item *item = NULL; + + box = elm_box_add(parent); + evas_object_size_hint_weight_set(box, 1, 1); + evas_object_size_hint_align_set(box, -1, -1); + evas_object_show(box); + + toolbar = elm_toolbar_add(parent); + inf->toolbar.obj = toolbar; + elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL); + elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_NONE); + elm_toolbar_homogeneous_set(toolbar, EINA_TRUE); + elm_object_style_set(toolbar, "transparent"); + elm_toolbar_menu_parent_set(toolbar, parent); + evas_object_size_hint_weight_set(toolbar, 0, 0); + evas_object_size_hint_align_set(toolbar, -1, 0); + evas_object_show(toolbar); + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + evas_object_smart_callback_add(button, "clicked", _profiling_status_change_cb, ext); + icon = elm_icon_add(button); + elm_image_resizable_set(icon, EINA_FALSE, EINA_FALSE); + elm_icon_standard_set(icon, "media-playback-start"); + elm_object_part_content_set(button, "icon", icon); + inf->toolbar.status_btn = button; + evas_object_show(button); + elm_object_disabled_set(button, EINA_TRUE); + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + evas_object_smart_callback_add(button, "clicked", _follow_interval_status_change_cb, ext); + icon = elm_icon_add(button); + elm_icon_standard_set(icon, "go-last"); + elm_object_part_content_set(button, "icon", icon); + evas_object_show(button); + inf->toolbar.follow_btn = button; + elm_object_disabled_set(button, EINA_TRUE); + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + evas_object_smart_callback_add(button, "clicked", _filters_dialog_show_cb, ext); + icon = elm_icon_add(button); + elm_icon_standard_set(icon, "view-list-details"); + elm_object_part_content_set(button, "icon", icon); + evas_object_show(button); + inf->toolbar.filters_btn = button; + elm_object_disabled_set(button, EINA_TRUE); + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + evas_object_smart_callback_add(button, "clicked", _find_dialog_show_cb, ext); + icon = elm_icon_add(button); + elm_icon_standard_set(icon, "system-search"); + elm_object_part_content_set(button, "icon", icon); + evas_object_show(button); + inf->toolbar.find_btn = button; + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + evas_object_smart_callback_add(button, "clicked", _time_range_dialog_show_cb, ext); + icon = elm_icon_add(button); + elm_icon_standard_set(icon, "clock"); + elm_object_part_content_set(button, "icon", icon); + evas_object_show(button); + inf->toolbar.time_range_btn = button; + elm_object_disabled_set(button, EINA_TRUE); + + item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL); + button = elm_button_add(toolbar); + elm_object_item_part_content_set(item, "object", button); + icon = elm_icon_add(button); + elm_icon_standard_set(icon, "preferences-other"); + elm_object_part_content_set(button, "icon", icon); + evas_object_show(button); + inf->toolbar.setting_btn= button; + elm_object_disabled_set(button, EINA_TRUE); + + + inf->profiler = efl_profiling_viewer_init(parent); evas_object_size_hint_weight_set(inf->profiler, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(inf->profiler, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add(inf->profiler, "unfollow", _unfollow_interval_cb, ext); - evas_object_smart_callback_add(inf->profiler, "stream,processing,pause", - _stream_processing_pause_cb, ext); - evas_object_smart_callback_add(inf->profiler, "stream,processing,resume", - _stream_processing_resume_cb, ext); + elm_box_pack_end(box, toolbar); + elm_box_pack_end(box, inf->profiler); - return inf->profiler; + return box; } EAPI Eina_Bool @@ -189,9 +397,10 @@ extension_stop(Clouseau_Extension *ext) Inf *inf = ext->data; evas_object_smart_callback_call(inf->profiler, "log,close", NULL); - efl_del(ext->ui_object); + efl_profiling_viewer_shutdown(inf->profiler); free(inf); + efl_del(ext->ui_object); EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension stopped"); eina_log_domain_unregister(_clouseau_profiling_extension_log_dom);