add fps debug display to comp...

to toggle interactively:
  killall -USR2 enlightenment 
or
  ctrl+alt+shift+F
or just change it in the config panel - the longer the average
interval is, the more accurate it will be, but the less often you get
updates. you can choose the screen corner here too. :) also note that
if comp doesnt get a stream of input (frames to render) then it's also
not going to tel you much interesting about its "best possible
framerate" as its likely got lots of spare time to do more, but it
just never got any to do. so this is useful if:

1. there is a continual strem of input (video playback, animated gui,
continual user input).
2. the longer the rolling average framecount is, the more accurate it
will be.



SVN revision: 56260
This commit is contained in:
Carsten Haitzler 2011-01-22 09:52:48 +00:00
parent 5ae3b52a17
commit 720f53b264
4 changed files with 246 additions and 16 deletions

View File

@ -36,8 +36,12 @@ struct _E_Comp
Ecore_Animator *render_animator;
Ecore_Job *update_job;
Ecore_Timer *new_up_timer;
Evas_Object *fps_bg;
Evas_Object *fps_fg;
int animating;
int render_overflow;
double frametimes[122];
int frameskip;
E_Manager_Comp comp;
@ -724,6 +728,41 @@ _e_mod_comp_cb_delayed_update_timer(void *data)
return ECORE_CALLBACK_CANCEL;
}
static void
_e_mod_comp_fps_update(E_Comp *c)
{
if (_comp_mod->conf->fps_show)
{
if (!c->fps_bg)
{
c->fps_bg = evas_object_rectangle_add(c->evas);
evas_object_color_set(c->fps_bg, 0, 0, 0, 128);
evas_object_show(c->fps_bg);
}
if (!c->fps_fg)
{
c->fps_fg = evas_object_text_add(c->evas);
evas_object_text_font_set(c->fps_fg, "Sans", 10);
evas_object_text_text_set(c->fps_fg, "???");
evas_object_color_set(c->fps_fg, 255, 255, 255, 255);
evas_object_show(c->fps_fg);
}
}
else
{
if (c->fps_fg)
{
evas_object_del(c->fps_fg);
c->fps_fg = NULL;
}
if (c->fps_bg)
{
evas_object_del(c->fps_bg);
c->fps_bg = NULL;
}
}
}
static Eina_Bool
_e_mod_comp_cb_update(E_Comp *c)
{
@ -763,6 +802,67 @@ _e_mod_comp_cb_update(E_Comp *c)
if (cw->update)
new_updates = eina_list_append(new_updates, cw);
}
_e_mod_comp_fps_update(c);
if (_comp_mod->conf->fps_show)
{
char buf[128];
double fps = 0.0, t, dt;
int i;
Evas_Coord x, y, w, h;
E_Zone *z;
t = ecore_time_get();
if (_comp_mod->conf->fps_average_range < 1)
_comp_mod->conf->fps_average_range = 30;
else if (_comp_mod->conf->fps_average_range > 120)
_comp_mod->conf->fps_average_range = 120;
dt = t - c->frametimes[_comp_mod->conf->fps_average_range - 1];
if (dt > 0.0)
fps = (double)_comp_mod->conf->fps_average_range / dt;
else fps = 0.0;
if (fps > 0.0)
snprintf(buf, sizeof(buf), "FPS: %1.1f", fps);
else
snprintf(buf, sizeof(buf), "N/A");
for (i = 31; i >= 1; i--) c->frametimes[i] = c->frametimes[i - 1];
c->frametimes[0] = t;
c->frameskip++;
if (c->frameskip >= _comp_mod->conf->fps_average_range)
{
c->frameskip = 0;
evas_object_text_text_set(c->fps_fg, buf);
}
evas_object_geometry_get(c->fps_fg, NULL, NULL, &w, &h);
w += 8;
h += 4;
z = e_util_zone_current_get(c->man);
if (z)
{
switch (_comp_mod->conf->fps_corner)
{
case 3:
x = z->x + z->w - w;
y = z->y + z->h - h;
break;
case 2:
x = z->x;
y = z->y + z->h - h;
break;
case 1:
x = z->x + z->w - w;
y = z->y;
break;
case 0:
default:
x = z->x;
y = z->y;
break;
}
evas_object_move(c->fps_bg, x, y);
evas_object_resize(c->fps_bg, w, h);
evas_object_move(c->fps_fg, x + 4, y + 4);
}
}
if (_comp_mod->conf->lock_fps)
{
DBG("MANUAL RENDER...\n");
@ -793,7 +893,7 @@ _e_mod_comp_cb_update(E_Comp *c)
}
c->updates = new_updates;
if (!c->animating) c->render_overflow--;
/*
if (doframeinfo == -1)
{
doframeinfo = 0;
@ -816,7 +916,7 @@ _e_mod_comp_cb_update(E_Comp *c)
}
t0 = t;
}
*/
nocomp:
cw = _e_mod_comp_fullscreen_check(c);
if (cw)
@ -2476,6 +2576,27 @@ _e_mod_comp_bd_property(void *data __UNUSED__, int type __UNUSED__, void *event)
}
//////////////////////////////////////////////////////////////////////////
static void
_e_mod_comp_fps_toggle(void)
{
if (_comp_mod)
{
Eina_List *l;
E_Comp *c;
if (_comp_mod->conf->fps_show)
{
_comp_mod->conf->fps_show = 0;
e_config_save_queue();
}
else
{
_comp_mod->conf->fps_show = 1;
e_config_save_queue();
}
EINA_LIST_FOREACH(compositors, l, c) _e_mod_comp_cb_update(c);
}
}
static Eina_Bool
_e_mod_comp_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
@ -2497,9 +2618,32 @@ _e_mod_comp_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
e_sys_action_do(E_SYS_RESTART, NULL);
}
}
else if ((!strcasecmp(ev->keyname, "f")) &&
(ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) &&
(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
(ev->modifiers & ECORE_EVENT_MODIFIER_ALT))
{
_e_mod_comp_fps_toggle();
}
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_e_mod_comp_signal_user(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
{
Ecore_Event_Signal_User *e = ev;
if (e->number == 1)
{
// core e uses this for popping up config panel
}
else if (e->number == 2)
{
_e_mod_comp_fps_toggle();
}
return ECORE_CALLBACK_RENEW;
}
//////////////////////////////////////////////////////////////////////////
static Evas *
_e_mod_comp_evas_get_func(void *data, E_Manager *man __UNUSED__)
@ -2740,7 +2884,12 @@ _e_mod_comp_add(E_Manager *man)
ECORE_EVENT_MODIFIER_SHIFT |
ECORE_EVENT_MODIFIER_CTRL |
ECORE_EVENT_MODIFIER_ALT, 0);
ecore_x_window_key_grab(c->man->root,
"F",
ECORE_EVENT_MODIFIER_SHIFT |
ECORE_EVENT_MODIFIER_CTRL |
ECORE_EVENT_MODIFIER_ALT, 0);
c->comp.data = c;
c->comp.func.evas_get = _e_mod_comp_evas_get_func;
c->comp.func.update = _e_mod_comp_update_func;
@ -2761,8 +2910,23 @@ _e_mod_comp_del(E_Comp *c)
{
E_Comp_Win *cw;
if (c->fps_fg)
{
evas_object_del(c->fps_fg);
c->fps_fg = NULL;
}
if (c->fps_bg)
{
evas_object_del(c->fps_bg);
c->fps_bg = NULL;
}
e_manager_comp_set(c->man, NULL);
ecore_x_window_key_ungrab(c->man->root,
"F",
ECORE_EVENT_MODIFIER_SHIFT |
ECORE_EVENT_MODIFIER_CTRL |
ECORE_EVENT_MODIFIER_ALT, 0);
ecore_x_window_key_ungrab(c->man->root,
"Home",
ECORE_EVENT_MODIFIER_SHIFT |
@ -2803,6 +2967,7 @@ _e_mod_comp_del(E_Comp *c)
}
//////////////////////////////////////////////////////////////////////////
static Ecore_Event_Handler *sig_user_handler = NULL;
Eina_Bool
e_mod_comp_init(void)
@ -2810,6 +2975,9 @@ e_mod_comp_init(void)
Eina_List *l;
E_Manager *man;
sig_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
_e_mod_comp_signal_user, NULL);
windows = eina_hash_string_superfast_new(NULL);
borders = eina_hash_string_superfast_new(NULL);
damages = eina_hash_string_superfast_new(NULL);
@ -2890,6 +3058,12 @@ e_mod_comp_shutdown(void)
damages = NULL;
windows = NULL;
borders = NULL;
if (sig_user_handler)
{
ecore_event_handler_del(sig_user_handler);
sig_user_handler = NULL;
}
}
void
@ -2903,6 +3077,7 @@ e_mod_comp_shadow_set(void)
E_Comp_Win *cw;
ecore_evas_manual_render_set(c->ee, _comp_mod->conf->lock_fps);
_e_mod_comp_fps_update(c);
EINA_INLIST_FOREACH(c->wins, cw)
{
if ((cw->shobj) && (cw->obj))

View File

@ -58,6 +58,10 @@ struct _E_Config_Dialog_Data
int send_flush;
int send_dump;
int nocomp_fs;
int fps_show;
int fps_corner;
int fps_average_range;
};
@ -138,6 +142,11 @@ _create_data(E_Config_Dialog *cfd)
cfdata->send_dump = _comp_mod->conf->send_dump;
cfdata->nocomp_fs = _comp_mod->conf->nocomp_fs;
cfdata->fps_show = _comp_mod->conf->fps_show;
cfdata->fps_corner = _comp_mod->conf->fps_corner;
cfdata->fps_average_range = _comp_mod->conf->fps_average_range;
if (cfdata->fps_average_range < 1) cfdata->fps_average_range = 12;
EINA_LIST_FOREACH(_comp_mod->conf->match.popups, l, m)
{
m2 = E_NEW(Match_Config, 1);
@ -1105,6 +1114,36 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
e_widget_list_object_append(ol, ol2, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Timeouts"), ol, 0, 0, 0, 0, 0.5, 0.0);
///////////////////////////////////////////
ol = e_widget_list_add(evas, 0, 0);
ob = e_widget_check_add(evas, _("Show Framerate"), &(cfdata->fps_show));
e_widget_list_object_append(ol, ob, 1, 1, 0.5);
ob = e_widget_label_add(evas, _("Rolling average frame count"));
e_widget_list_object_append(ol, ob, 1, 1, 0.5);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f Frames"), 1, 120, 1, 0,
NULL, &(cfdata->fps_average_range), 240);
e_widget_list_object_append(ol, ob, 1, 1, 0.5);
of = e_widget_frametable_add(evas, _("Corner"), 0);
e_widget_frametable_content_align_set(of, 0.5, 0.5);
rg = e_widget_radio_group_new(&(cfdata->fps_corner));
ob = e_widget_radio_icon_add(evas, NULL, "preferences-position-top-left",
24, 24, 0, rg);
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 1, 1, 1, 1);
ob = e_widget_radio_icon_add(evas, NULL, "preferences-position-top-right",
24, 24, 1, rg);
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 1, 1, 1, 1);
ob = e_widget_radio_icon_add(evas, NULL, "preferences-position-bottom-left",
24, 24, 2, rg);
e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 1, 1, 1);
ob = e_widget_radio_icon_add(evas, NULL, "preferences-position-bottom-right",
24, 24, 3, rg);
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 1, 1, 1, 1);
e_widget_list_object_append(ol, of, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Debug"), ol, 0, 0, 0, 0, 0.5, 0.0);
e_widget_toolbook_page_show(otb, 0);
e_dialog_resizable_set(cfd->dia, 1);
@ -1155,6 +1194,9 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
(cfdata->min_unmapped_time != _comp_mod->conf->min_unmapped_time) ||
(cfdata->send_flush != _comp_mod->conf->send_flush) ||
(cfdata->send_dump != _comp_mod->conf->send_dump) ||
(cfdata->fps_show != _comp_mod->conf->fps_show) ||
(cfdata->fps_corner != _comp_mod->conf->fps_corner) ||
(cfdata->fps_average_range != _comp_mod->conf->fps_average_range) ||
(cfdata->match.changed)
)
{
@ -1215,6 +1257,9 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
_comp_mod->conf->min_unmapped_time = cfdata->min_unmapped_time;
_comp_mod->conf->send_flush = cfdata->send_flush;
_comp_mod->conf->send_dump = cfdata->send_dump;
_comp_mod->conf->fps_show = cfdata->fps_show;
_comp_mod->conf->fps_corner = cfdata->fps_corner;
_comp_mod->conf->fps_average_range = cfdata->fps_average_range;
if (_comp_mod->conf->shadow_style)
eina_stringshare_del(_comp_mod->conf->shadow_style);
_comp_mod->conf->shadow_style = NULL;

View File

@ -68,10 +68,16 @@ e_modapi_init(E_Module *m)
#undef D
#define T Config
#define D mod->conf_edd
E_CONFIG_VAL(D, T, use_shadow, UCHAR);
E_CONFIG_VAL(D, T, shadow_file, STR);
E_CONFIG_VAL(D, T, shadow_style, STR);
E_CONFIG_VAL(D, T, engine, INT);
E_CONFIG_VAL(D, T, max_unmapped_pixels, INT);
E_CONFIG_VAL(D, T, max_unmapped_time, INT);
E_CONFIG_VAL(D, T, min_unmapped_time, INT);
E_CONFIG_VAL(D, T, fps_average_range, INT);
E_CONFIG_VAL(D, T, fps_corner, UCHAR);
E_CONFIG_VAL(D, T, fps_show, UCHAR);
E_CONFIG_VAL(D, T, use_shadow, UCHAR);
E_CONFIG_VAL(D, T, indirect, UCHAR);
E_CONFIG_VAL(D, T, texture_from_pixmap, UCHAR);
E_CONFIG_VAL(D, T, lock_fps, UCHAR);
@ -84,9 +90,6 @@ e_modapi_init(E_Module *m)
E_CONFIG_VAL(D, T, send_dump, UCHAR);
E_CONFIG_VAL(D, T, nocomp_fs, UCHAR);
E_CONFIG_VAL(D, T, smooth_windows, UCHAR);
E_CONFIG_VAL(D, T, max_unmapped_pixels, INT);
E_CONFIG_VAL(D, T, max_unmapped_time, INT);
E_CONFIG_VAL(D, T, min_unmapped_time, INT);
E_CONFIG_LIST(D, T, match.popups, mod->conf_match_edd);
E_CONFIG_LIST(D, T, match.borders, mod->conf_match_edd);
E_CONFIG_LIST(D, T, match.overrides, mod->conf_match_edd);
@ -120,10 +123,16 @@ _e_mod_config_new(E_Module *m)
Match *mat;
mod->conf = E_NEW(Config, 1);
mod->conf->use_shadow = 1;
mod->conf->shadow_file = NULL;
mod->conf->shadow_style = eina_stringshare_add("default");
mod->conf->engine = E_EVAS_ENGINE_SOFTWARE_X11;
mod->conf->max_unmapped_pixels = 32 * 1024; // implement
mod->conf->max_unmapped_time = 10 * 3600; // implement
mod->conf->min_unmapped_time = 5 * 60; // implement
mod->conf->fps_average_range = 30;
mod->conf->fps_corner = 0;
mod->conf->fps_show = 0;
mod->conf->use_shadow = 1;
mod->conf->indirect = 0;
mod->conf->texture_from_pixmap = 0;
mod->conf->lock_fps = 0;
@ -136,9 +145,6 @@ _e_mod_config_new(E_Module *m)
mod->conf->send_dump = 0; // implement
mod->conf->nocomp_fs = 0; // buggy
mod->conf->smooth_windows = 0;
mod->conf->max_unmapped_pixels = 32 * 1024; // implement
mod->conf->max_unmapped_time = 10 * 3600; // implement
mod->conf->min_unmapped_time = 5 * 60; // implement
mod->conf->match.popups = NULL;
mat = E_NEW(Match, 1);

View File

@ -8,10 +8,16 @@ typedef struct _Match Match;
struct _Config
{
unsigned char use_shadow;
const char *shadow_file;
const char *shadow_style;
int engine;
int max_unmapped_pixels;
int max_unmapped_time;
int min_unmapped_time;
int fps_average_range;
unsigned char fps_corner;
unsigned char fps_show;
unsigned char use_shadow;
unsigned char indirect;
unsigned char texture_from_pixmap;
unsigned char lock_fps;
@ -24,9 +30,6 @@ struct _Config
unsigned char send_dump;
unsigned char nocomp_fs;
unsigned char smooth_windows;
int max_unmapped_pixels;
int max_unmapped_time;
int min_unmapped_time;
struct {
Eina_List *popups; // used for e popups
@ -54,6 +57,8 @@ struct _Match
const char *clas; // glob - used for borders, overrides, NULL if not to be used
const char *role; // glob - used for borders
const char *shadow_style; // shadow style to use
int primary_type; // Ecore_X_Window_Type - used for borders, overrides, first one found - ECORE_X_WINDOW_TYPE_UNKNOWN if not to be used
char borderless; // used for borders, 0 == dont use, 1 == borderless, -1 == not borderless
char dialog; // used for borders, 0 == don't use, 1 == dialog, -1 == not dialog
@ -64,7 +69,6 @@ struct _Match
char fullscreen; // used for borders, 0 == don't use, 1 == is fullscreen, -1 == not fullscreen
char modal; // used for borders, 0 == don't use, 1 == is modal, -1 == not modal
const char *shadow_style; // shadow style to use
};
extern Mod *_comp_mod;