summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksii Piskun <o.piskun@samsung.com>2017-11-02 14:33:33 +0200
committerMykyta Biliavskyi <m.biliavskyi@samsung.com>2017-11-02 14:43:13 +0200
commit14ffe44865ded758fbdcbaad6f8a73722a3b0cc7 (patch)
tree9a563442d7f24b466f066243ae8a7c6477f99433
parent7289e8810dbb54d04f1e29dde9f888a5cdb6658c (diff)
UI: add function for updating event area when new data received.epv_1.0.2
Summary: In realtime mode profiler doesn't know about events which happens in future. So may happens situation, when received new events and sizes of previously initiated grids aren't big enough and they must be updated. This commit change updating all event area to updating only that elements that might be changed. Also it fixes memory leaks and infinity loops in zoom. T6292 @fix Reviewers: NikaWhite, i.furs Differential Revision: https://phab.enlightenment.org/D5420
-rw-r--r--src/lib/ui.c84
1 files changed, 66 insertions, 18 deletions
diff --git a/src/lib/ui.c b/src/lib/ui.c
index c4028df..ac38f50 100644
--- a/src/lib/ui.c
+++ b/src/lib/ui.c
@@ -51,6 +51,7 @@ typedef struct _Grids
51 Evas_Object *states_grid; 51 Evas_Object *states_grid;
52 Evas_Object *cpufreq_grid; 52 Evas_Object *cpufreq_grid;
53 Evas_Object **thread_grid; 53 Evas_Object **thread_grid;
54 unsigned int thread_grid_arrays_size;
54 Evas_Object *over_grid; 55 Evas_Object *over_grid;
55 Evas_Object *timemarks_grid; 56 Evas_Object *timemarks_grid;
56 int over_grid_size; 57 int over_grid_size;
@@ -489,37 +490,29 @@ _zoom_events_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, v
489} 490}
490 491
491/* background filling */ 492/* background filling */
492static Evas_Object * 493static void
493thread_background_create(Evas_Object *win, int max_events) 494_thread_grid_resize(Evas_Object *thread_grid, int max_events)
494{ 495{
495 Evas_Object *thread_grid;
496
497/* 496/*
498 * 1 for cpuuse, 2 for single events, 2 for each thread event. 497 * 1 for cpuuse, 2 for single events, 2 for each thread event.
499 */ 498 */
500 int grid_virtual_height = 1 + 2 + 2 * max_events; 499 int grid_virtual_height = 1 + 2 + 2 * max_events;
501 thread_grid = elm_grid_add(win);
502 elm_grid_size_set(thread_grid, GRID_SCALE, grid_virtual_height); 500 elm_grid_size_set(thread_grid, GRID_SCALE, grid_virtual_height);
503 evas_object_size_hint_min_set(thread_grid, 0, grid_virtual_height * 10); 501 evas_object_size_hint_min_set(thread_grid, 0, grid_virtual_height * 10);
504 return thread_grid;
505} 502}
506 503
507static Evas_Object * 504static void
508cpufreq_background_create(Evas_Object *win, int cpucores) 505_cpufreq_grid_resize(Evas_Object *freq_grid, int cpucores)
509{ 506{
510 Evas_Object *freq_grid = elm_grid_add(win);
511 elm_grid_size_set(freq_grid, GRID_SCALE, cpucores); 507 elm_grid_size_set(freq_grid, GRID_SCALE, cpucores);
512 evas_object_size_hint_min_set(freq_grid, 0, cpucores * 10); 508 evas_object_size_hint_min_set(freq_grid, 0, cpucores * 10);
513 return freq_grid;
514} 509}
515 510
516static Evas_Object * 511static void
517states_background_create(Evas_Object *win, int state_uniq) 512_states_grid_resize(Evas_Object *state_grid, int state_uniq)
518{ 513{
519 Evas_Object *state_grid = elm_grid_add(win);
520 elm_grid_size_set(state_grid, GRID_SCALE, state_uniq); 514 elm_grid_size_set(state_grid, GRID_SCALE, state_uniq);
521 evas_object_size_hint_min_set(state_grid, 0, state_uniq * 20); 515 evas_object_size_hint_min_set(state_grid, 0, state_uniq * 20);
522 return state_grid;
523} 516}
524 517
525static Evas_Object * 518static Evas_Object *
@@ -557,7 +550,8 @@ background_fill(Global_Data *gd)
557 label_size = object_width_calc(label); 550 label_size = object_width_calc(label);
558 if (label_size > biggest_label) biggest_label = label_size; 551 if (label_size > biggest_label) biggest_label = label_size;
559 bg_to_table_add(tb, 1, y, (Color){16, 16, 16, 255}); 552 bg_to_table_add(tb, 1, y, (Color){16, 16, 16, 255});
560 grids->cpufreq_grid = cpufreq_background_create(win, sd->cpucores); 553 grids->cpufreq_grid = elm_grid_add(win);
554 _cpufreq_grid_resize(grids->cpufreq_grid, sd->cpucores);
561 evas_object_size_hint_weight_set(grids->cpufreq_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 555 evas_object_size_hint_weight_set(grids->cpufreq_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
562 evas_object_size_hint_align_set(grids->cpufreq_grid, EVAS_HINT_FILL, EVAS_HINT_FILL); 556 evas_object_size_hint_align_set(grids->cpufreq_grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
563 elm_table_pack(tb, grids->cpufreq_grid, 1, y++, 1, 1); 557 elm_table_pack(tb, grids->cpufreq_grid, 1, y++, 1, 1);
@@ -568,7 +562,8 @@ background_fill(Global_Data *gd)
568 if (label_size > biggest_label) biggest_label = label_size; 562 if (label_size > biggest_label) biggest_label = label_size;
569 bg_to_table_add(tb, 1, y, (Color){24, 24, 24, 255}); 563 bg_to_table_add(tb, 1, y, (Color){24, 24, 24, 255});
570 unsigned int state_num = eina_list_count(gd->thd->uniq_states); 564 unsigned int state_num = eina_list_count(gd->thd->uniq_states);
571 grids->states_grid = states_background_create(win, state_num); 565 grids->states_grid = elm_grid_add(win);
566 _states_grid_resize(grids->states_grid, state_num);
572 evas_object_size_hint_weight_set(grids->states_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 567 evas_object_size_hint_weight_set(grids->states_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
573 evas_object_size_hint_align_set(grids->states_grid, EVAS_HINT_FILL, EVAS_HINT_FILL); 568 evas_object_size_hint_align_set(grids->states_grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
574 elm_table_pack(tb, grids->states_grid, 1, y++, 1, 1); 569 elm_table_pack(tb, grids->states_grid, 1, y++, 1, 1);
@@ -590,7 +585,9 @@ background_fill(Global_Data *gd)
590 thread_grid_color, 255}); 585 thread_grid_color, 255});
591 586
592 Log_Thread *thread = eina_array_data_get(threads, i); 587 Log_Thread *thread = eina_array_data_get(threads, i);
593 grids->thread_grid[i] = thread_background_create(win, thread->max_events); 588 thread = eina_array_data_get(threads, i);
589 grids->thread_grid[i] = elm_grid_add(win);
590 _thread_grid_resize(grids->thread_grid[i], thread->max_events);
594 evas_object_size_hint_weight_set(grids->thread_grid[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 591 evas_object_size_hint_weight_set(grids->thread_grid[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
595 evas_object_size_hint_align_set(grids->thread_grid[i], EVAS_HINT_FILL, EVAS_HINT_FILL); 592 evas_object_size_hint_align_set(grids->thread_grid[i], EVAS_HINT_FILL, EVAS_HINT_FILL);
596 elm_table_pack(tb, grids->thread_grid[i], 1, y++, 1, 1); 593 elm_table_pack(tb, grids->thread_grid[i], 1, y++, 1, 1);
@@ -629,6 +626,57 @@ background_fill(Global_Data *gd)
629 _zoom_events_cb, gd); 626 _zoom_events_cb, gd);
630 eina_evlog("-background_fill", NULL, 0.0, NULL); 627 eina_evlog("-background_fill", NULL, 0.0, NULL);
631} 628}
629
630static void
631_background_update_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
632{
633 Global_Data *gd = data;
634 In_Thread_Data *thd = gd->thd;
635 Grids *grids = gd->ui->grids;
636 int cpucores = thd->stored_data->cpucores;
637 unsigned int i, threads_count;
638 char buf[STRING_LENGTH];
639 Evas_Object *tb = gd->ui->table;
640 Color rgba;
641 Log_Thread *thread;
642 if (!thd) return;
643
644 _cpufreq_grid_resize(grids->cpufreq_grid, cpucores);
645
646 unsigned int state_num = eina_list_count(gd->thd->uniq_states);
647 _states_grid_resize(grids->states_grid, state_num);
648
649 threads_count = eina_array_count(thd->all_offs->threads);
650 grids->thread_grid = realloc(grids->thread_grid, threads_count * sizeof(Evas_Object *));
651 for (i = 0; i < grids->thread_grid_arrays_size; i++)
652 {
653 thread = eina_array_data_get(thd->all_offs->threads, i);
654 _thread_grid_resize(grids->thread_grid[i], thread->max_events);
655 }
656
657 for (i = grids->thread_grid_arrays_size; i < threads_count; i++)
658 {
659 snprintf(buf, STRING_LENGTH, "<b>%i</b>", i + 1);
660 label_to_table_add(tb, 0, i + 2, buf);
661
662 /* Make neighboring threads color different */
663 int thread_grid_color = 32 + ((i % 2) * 16);
664 rgba = (Color){thread_grid_color, thread_grid_color, thread_grid_color, 255};
665 bg_to_table_add(tb, 1, i + 2, rgba);
666
667 thread = eina_array_data_get(thd->all_offs->threads, i);
668 grids->thread_grid[i] = elm_grid_add(obj);
669 _thread_grid_resize(grids->thread_grid[i], thread->max_events);
670 evas_object_size_hint_weight_set(grids->thread_grid[i], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
671 evas_object_size_hint_align_set(grids->thread_grid[i], EVAS_HINT_FILL, EVAS_HINT_FILL);
672 elm_table_pack(tb, grids->thread_grid[i], 1, i + 2, 1, 1);
673 evas_object_show(grids->thread_grid[i]);
674 }
675 grids->thread_grid_arrays_size = threads_count;
676
677 elm_table_pack(tb, grids->over_grid, 1, 0, 1, grids->thread_grid_arrays_size + 2);
678 evas_object_raise(grids->over_grid);
679}
632/* background filling */ 680/* background filling */
633 681
634/* events selecting */ 682/* events selecting */
@@ -2506,7 +2554,7 @@ _realtime_callbacks_register(void *data, Evas_Object *obj, void *event_info EINA
2506{ 2554{
2507 evas_object_smart_callback_priority_add(obj, "display,interval", 2555 evas_object_smart_callback_priority_add(obj, "display,interval",
2508 EVAS_CALLBACK_PRIORITY_BEFORE, 2556 EVAS_CALLBACK_PRIORITY_BEFORE,
2509 _event_area_init_cb, data); 2557 _background_update_cb, data);
2510 //evas_object_smart_callback_add(obj, "graph,draw", _navigation_area_change_cb, data); 2558 //evas_object_smart_callback_add(obj, "graph,draw", _navigation_area_change_cb, data);
2511 evas_object_smart_callback_add(obj, "graph,draw", _realtime_timemarks_update, data); 2559 evas_object_smart_callback_add(obj, "graph,draw", _realtime_timemarks_update, data);
2512} 2560}