From fd3c1e4f2aebcb4a6206fb39a95889f326e87b74 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 31 Jan 2010 13:05:56 +0000 Subject: [PATCH] allow the "limit compositor framerate to fixed e framerate" to be optional SVN revision: 45754 --- src/modules/comp/e_mod_comp.c | 64 +++++++++++++++++++++++++++------ src/modules/comp/e_mod_config.c | 14 +++++--- src/modules/comp/e_mod_main.c | 2 ++ src/modules/comp/e_mod_main.h | 1 + 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/src/modules/comp/e_mod_comp.c b/src/modules/comp/e_mod_comp.c index 91d17eb31..5b2d199af 100644 --- a/src/modules/comp/e_mod_comp.c +++ b/src/modules/comp/e_mod_comp.c @@ -34,6 +34,7 @@ struct _E_Comp Eina_Inlist *wins; Eina_List *updates; Ecore_Animator *render_animator; + Ecore_Job *update_job; int render_overflow; Eina_Bool gl : 1; @@ -317,9 +318,8 @@ _e_mod_comp_pre_swap(void *data, Evas *e) } static int -_e_mod_comp_cb_animator(void *data) +_e_mod_comp_cb_update(E_Comp *c) { - E_Comp *c = data; E_Comp_Win *cw; Eina_List *new_updates = NULL; // for failed pixmap fetches - get them next frame @@ -332,7 +332,8 @@ _e_mod_comp_cb_animator(void *data) if (cw->update) new_updates = eina_list_append(new_updates, cw); } - ecore_evas_manual_render(c->ee); + if (_comp_mod->conf->lock_fps) + ecore_evas_manual_render(c->ee); if (c->grabbed) { c->grabbed = 0; @@ -341,23 +342,48 @@ _e_mod_comp_cb_animator(void *data) if (new_updates) _e_mod_comp_render_queue(c); c->updates = new_updates; c->render_overflow--; + c->update_job = NULL; if (c->render_overflow == 0) { - c->render_animator = NULL; + if (c->render_animator) c->render_animator = NULL; return 0; } return 1; } +static void +_e_mod_comp_cb_job(void *data) +{ + _e_mod_comp_cb_update(data); +} + +static int +_e_mod_comp_cb_animator(void *data) +{ + return _e_mod_comp_cb_update(data); +} + static void _e_mod_comp_render_queue(E_Comp *c) { - if (c->render_animator) + if (_comp_mod->conf->lock_fps) { - c->render_overflow = 10; - return; + if (c->render_animator) + { + c->render_overflow = 10; + return; + } + c->render_animator = ecore_animator_add(_e_mod_comp_cb_animator, c); + } + else + { + if (c->update_job) + { + ecore_job_del(c->update_job); + c->render_overflow = 0; + } + c->update_job = ecore_job_add(_e_mod_comp_cb_job, c); } - c->render_animator = ecore_animator_add(_e_mod_comp_cb_animator, c); } static void @@ -399,6 +425,20 @@ _e_mod_comp_win_damage_find(Ecore_X_Damage damage) return cw; } +static Eina_Bool +_e_mod_comp_win_do_shadow(E_Comp_Win *cw) +{ + if (cw->shaped) return 0; + if (cw->argb) + { + if (!cw->bd) return 0; + if ((cw->bd->client.border.name) && + (!strcmp(cw->bd->client.border.name, "borderless"))) + return 0; + } + return 1; +} + static E_Comp_Win * _e_mod_comp_win_add(E_Comp *c, Ecore_X_Window win) { @@ -608,7 +648,7 @@ _e_mod_comp_win_show(E_Comp_Win *cw) { if (_comp_mod->conf->use_shadow) { - if ((!cw->argb) && (!cw->shaped)) + if (_e_mod_comp_win_do_shadow(cw)) { int ok = 0; char buf[PATH_MAX]; @@ -1042,7 +1082,7 @@ _e_mod_comp_add(E_Manager *man) if (!c->ee) c->ee = ecore_evas_software_x11_new(NULL, c->win, 0, 0, man->w, man->h); - ecore_evas_manual_render_set(c->ee, 1); + ecore_evas_manual_render_set(c->ee, _comp_mod->conf->lock_fps); c->evas = ecore_evas_get(c->ee); ecore_evas_show(c->ee); @@ -1099,6 +1139,7 @@ _e_mod_comp_del(E_Comp *c) ecore_x_composite_render_window_disable(c->win); if (c->man->num == 0) e_alert_composite_win = 0; if (c->render_animator) ecore_animator_del(c->render_animator); + if (c->update_job) ecore_job_del(c->update_job); free(c); } @@ -1161,13 +1202,14 @@ e_mod_comp_shadow_set(void) { E_Comp_Win *cw; + ecore_evas_manual_render_set(c->ee, _comp_mod->conf->lock_fps); EINA_INLIST_FOREACH(c->wins, cw) { if (evas_object_visible_get(cw->obj) && (cw->shobj)) { if (_comp_mod->conf->use_shadow) { - if ((!cw->argb) && (!cw->shaped)) + if (_e_mod_comp_win_do_shadow(cw)) { int ok = 0; char buf[PATH_MAX]; diff --git a/src/modules/comp/e_mod_config.c b/src/modules/comp/e_mod_config.c index 7edeebbfb..dba408e0e 100644 --- a/src/modules/comp/e_mod_config.c +++ b/src/modules/comp/e_mod_config.c @@ -9,6 +9,7 @@ struct _E_Config_Dialog_Data int use_shadow; int engine; int texture_from_pixmap; + int lock_fps; }; /* Protos */ @@ -56,6 +57,7 @@ _create_data(E_Config_Dialog *cfd) (cfdata->engine != E_EVAS_ENGINE_GL_X11)) cfdata->engine = E_EVAS_ENGINE_SOFTWARE_X11; cfdata->texture_from_pixmap = _comp_mod->conf->texture_from_pixmap; + cfdata->lock_fps = _comp_mod->conf->lock_fps; return cfdata; } @@ -76,9 +78,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf o = e_widget_list_add(evas, 0, 0); ot = e_widget_table_add(evas, 1); - of = e_widget_framelist_add(evas, _("Shadow"), 0); + of = e_widget_framelist_add(evas, _("General"), 0); e_widget_framelist_content_align_set(of, 0.5, 0.0); - ob = e_widget_check_add(evas, _("Enabled"), &(cfdata->use_shadow)); + ob = e_widget_check_add(evas, _("Shadow"), &(cfdata->use_shadow)); + e_widget_framelist_object_append(of, ob); + ob = e_widget_check_add(evas, _("Limit FPS"), &(cfdata->lock_fps)); e_widget_framelist_object_append(of, ob); e_widget_table_object_append(ot, of, 0, 0, 1, 1, 1, 1, 1, 1); @@ -100,7 +104,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf e_widget_table_object_append(ot, of, 0, 1, 1, 1, 1, 1, 1, 1); - of = e_widget_framelist_add(evas, _("GL Options"), 0); + of = e_widget_framelist_add(evas, _("OpenGL Options"), 0); e_widget_framelist_content_align_set(of, 0.5, 0.0); ob = e_widget_check_add(evas, _("Texture from Pixmap"), &(cfdata->texture_from_pixmap)); e_widget_framelist_object_append(of, ob); @@ -114,9 +118,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { - if (_comp_mod->conf->use_shadow != cfdata->use_shadow) + if ((_comp_mod->conf->use_shadow != cfdata->use_shadow) || + (cfdata->lock_fps != _comp_mod->conf->lock_fps)) { _comp_mod->conf->use_shadow = cfdata->use_shadow; + _comp_mod->conf->lock_fps = cfdata->lock_fps; e_mod_comp_shadow_set(); } if ((_comp_mod->conf->engine != cfdata->engine) || diff --git a/src/modules/comp/e_mod_main.c b/src/modules/comp/e_mod_main.c index 1474fc46e..e620631e9 100644 --- a/src/modules/comp/e_mod_main.c +++ b/src/modules/comp/e_mod_main.c @@ -34,6 +34,7 @@ e_modapi_init(E_Module *m) E_CONFIG_VAL(D, T, shadow_file, STR); E_CONFIG_VAL(D, T, engine, INT); E_CONFIG_VAL(D, T, texture_from_pixmap, UCHAR); + E_CONFIG_VAL(D, T, lock_fps, UCHAR); mod->conf = e_config_domain_load("module.comp", mod->conf_edd); if (!mod->conf) @@ -43,6 +44,7 @@ e_modapi_init(E_Module *m) mod->conf->shadow_file = NULL; mod->conf->engine = E_EVAS_ENGINE_SOFTWARE_X11; mod->conf->texture_from_pixmap = 0; + mod->conf->lock_fps = 1; } _comp_mod = mod; diff --git a/src/modules/comp/e_mod_main.h b/src/modules/comp/e_mod_main.h index d668d3519..aea5b212e 100644 --- a/src/modules/comp/e_mod_main.h +++ b/src/modules/comp/e_mod_main.h @@ -11,6 +11,7 @@ struct _Config const char *shadow_file; int engine; unsigned char texture_from_pixmap; + unsigned char lock_fps; }; struct _Mod