From 296451ab3b73fe1e1d1a363940657315cc072b4a Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 29 Jul 2020 17:52:00 +0900 Subject: [PATCH] e_hwc_windows: add timer of waiting commit handler add config of e_comp commit_handler_timer.use and commit_handler_timer.interval Change-Id: Ib90a43468dc9202ab8ca5b39219819ed47b62d7f --- src/bin/e_comp.c | 6 ++++ src/bin/e_comp.h | 6 ++++ src/bin/e_comp_cfdata.c | 4 +++ src/bin/e_comp_cfdata.h | 6 ++++ src/bin/e_hwc.h | 1 + src/bin/e_hwc_windows.c | 72 +++++++++++++++++++++++++++++++++-------- 6 files changed, 82 insertions(+), 13 deletions(-) diff --git a/src/bin/e_comp.c b/src/bin/e_comp.c index 2b54c37f90..d96c478e1e 100644 --- a/src/bin/e_comp.c +++ b/src/bin/e_comp.c @@ -466,6 +466,12 @@ e_comp_init(void) if (conf->canvas_render_delay_after_boot) e_comp->canvas_render_delayed = EINA_TRUE; + if ((conf->commit_handler_timer.use) && (conf->commit_handler_timer.interval)) + { + e_comp->commit_handler_timer.use = EINA_TRUE; + e_comp->commit_handler_timer.interval = conf->commit_handler_timer.interval; + } + e_comp_canvas_fake_layers_init(); E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_ON, _e_comp_screensaver_on, NULL); diff --git a/src/bin/e_comp.h b/src/bin/e_comp.h index aa5d553a0d..a3c04079bf 100644 --- a/src/bin/e_comp.h +++ b/src/bin/e_comp.h @@ -192,6 +192,12 @@ struct _E_Comp void (*func_memory_dump) (void); E_Comp_Image_Filter image_filter; + + struct + { + char use; // 0: none 1: use commit_handler timer + double interval; // time value the interval of commit_handler after tdm_commit in second (default : 0) + } commit_handler_timer; }; struct _E_Comp_Connected_Client_Info diff --git a/src/bin/e_comp_cfdata.c b/src/bin/e_comp_cfdata.c index e1ffa22f3d..55f61fd9db 100644 --- a/src/bin/e_comp_cfdata.c +++ b/src/bin/e_comp_cfdata.c @@ -90,6 +90,8 @@ e_comp_cfdata_edd_init(E_Config_DD **conf_edd, E_Config_DD **match_edd) E_CONFIG_VAL(D, T, input_log_enable, UCHAR); E_CONFIG_VAL(D, T, avoid_afill, UCHAR); E_CONFIG_VAL(D, T, canvas_render_delay_after_boot, UCHAR); + E_CONFIG_VAL(D, T, commit_handler_timer.use, UCHAR); + E_CONFIG_VAL(D, T, commit_handler_timer.interval, DOUBLE); } E_API E_Comp_Config * @@ -141,6 +143,8 @@ e_comp_cfdata_config_new(void) cfg->first_draw_delay = 0.15; cfg->skip_first_damage = 1; cfg->launch_file = NULL; + cfg->commit_handler_timer.use = 0; + cfg->commit_handler_timer.interval = 0; cfg->match.popups = NULL; diff --git a/src/bin/e_comp_cfdata.h b/src/bin/e_comp_cfdata.h index d79560184c..670d68110f 100644 --- a/src/bin/e_comp_cfdata.h +++ b/src/bin/e_comp_cfdata.h @@ -73,6 +73,12 @@ struct _E_Comp_Config Eina_Bool input_log_enable; unsigned char avoid_afill; // used for avoiding to fill the alpha channel. 0: use gl_tbm ee engine, 1: use gl_tbm_ES ee engine unsigned char canvas_render_delay_after_boot; // no canvas update before client's commit request, begin rendering after 1st commit + + struct + { + Eina_Bool use; // 0: none 1: use commit_handler timer + double interval; // time value the interval of commit_handler after tdm_commit in second (default : 0) + } commit_handler_timer; }; struct _E_Comp_Match diff --git a/src/bin/e_hwc.h b/src/bin/e_hwc.h index 6716cca31b..9b252c8ef9 100644 --- a/src/bin/e_hwc.h +++ b/src/bin/e_hwc.h @@ -143,6 +143,7 @@ struct _E_Hwc Eina_Bool tdm_hwc_fence; int commit_fence_fd; + Ecore_Timer *commit_handler_timer; }; E_API extern int E_EVENT_HWC_ACTIVE; diff --git a/src/bin/e_hwc_windows.c b/src/bin/e_hwc_windows.c index 50eae424ce..740a1bf49f 100644 --- a/src/bin/e_hwc_windows.c +++ b/src/bin/e_hwc_windows.c @@ -88,6 +88,7 @@ static uint64_t ehws_comp_buffer_info_key; static Eina_Bool _e_hwc_windows_target_window_queue_set(E_Hwc_Window_Target *target_hwc_window); static Eina_Bool _e_hwc_windows_pp_output_data_commit(E_Hwc *hwc, E_Hwc_Window_Commit_Data *data); static Eina_Bool _e_hwc_windows_pp_window_commit(E_Hwc *hwc, E_Hwc_Window *hwc_window); +static void _e_hwc_windows_wait_commit_set(E_Hwc *hwc, Eina_Bool set); static E_Comp_Wl_Buffer * _e_hwc_windows_comp_wl_buffer_get(E_Hwc_Window *hwc_window) @@ -373,7 +374,7 @@ _e_hwc_windows_commit_handler(tdm_hwc *thwc, unsigned int sequence, /* 'wait_commit' is mechanism to make 'fetch and commit' no more than one time per a frame; * a 'page flip' happened so it's time to allow to make 'fetch and commit' for the e_output */ - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); } static void @@ -1452,7 +1453,7 @@ _e_hwc_windows_pp_window_get(E_Hwc *hwc, tbm_surface_h tsurface) } static void -_e_hwc_windows_pp_output_commit_handler(tdm_output *toutput, unsigned int sequence, +_e_hwc_windows_pp_output_commit_handler(tdm_hwc *thwc, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) { @@ -1465,7 +1466,7 @@ _e_hwc_windows_pp_output_commit_handler(tdm_output *toutput, unsigned int sequen hwc = user_data; _e_hwc_windows_commit_data_release(hwc, sequence, tv_sec, tv_usec); - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); /* layer already resetted */ if (hwc->pp_output_commit_data) @@ -1480,7 +1481,7 @@ _e_hwc_windows_pp_output_commit_handler(tdm_output *toutput, unsigned int sequen tbm_surface_internal_unref(hwc->pp_tsurface); hwc->pp_tsurface = data->buffer.tsurface; - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); E_FREE(data); @@ -1566,7 +1567,7 @@ fail: E_FREE(data); _e_hwc_windows_commit_data_release(hwc, 0, 0, 0); - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); return EINA_FALSE; } @@ -1641,7 +1642,7 @@ _e_hwc_windows_pp_commit_handler(tdm_pp *pp, tbm_surface_h tsurface_src, tbm_sur hwc->tpp = NULL; } _e_hwc_windows_commit_data_release(hwc, 0, 0, 0); - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); goto done; } @@ -1651,7 +1652,7 @@ _e_hwc_windows_pp_commit_handler(tdm_pp *pp, tbm_surface_h tsurface_src, tbm_sur { tbm_surface_queue_release(hwc->pp_tqueue, tsurface_dst); _e_hwc_windows_commit_data_release(hwc, 0, 0, 0); - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); goto done; } @@ -1778,7 +1779,7 @@ _e_hwc_windows_pp_window_commit(E_Hwc *hwc, E_Hwc_Window *hwc_window) terror = tdm_pp_commit(hwc->tpp); EINA_SAFETY_ON_FALSE_GOTO(terror == TDM_ERROR_NONE, commit_fail); - hwc->wait_commit = EINA_TRUE; + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); hwc->pp_commit = EINA_TRUE; return EINA_TRUE; @@ -1850,9 +1851,12 @@ _e_hwc_windows_pp_commit(E_Hwc *hwc) return EINA_FALSE; } + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); + terror = tdm_hwc_commit(hwc->thwc, 0, _e_hwc_windows_commit_handler, hwc); if (terror != TDM_ERROR_NONE) { + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); EHWSERR("fail to tdm_hwc_commit", hwc); /* send tizen_hwc_commit feedback discarded */ e_comp_wl_tizen_hwc_discarded(); @@ -1873,7 +1877,7 @@ _e_hwc_windows_pp_commit(E_Hwc *hwc) NULL, hwc, commit_data->buffer.tsurface, hwc->pp_tqueue, commit_data->buffer_ref.buffer ? commit_data->buffer_ref.buffer->resource : NULL, commit_data); - hwc->wait_commit = EINA_TRUE; + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); return EINA_TRUE; } @@ -1888,6 +1892,48 @@ _e_hwc_windows_pp_commit(E_Hwc *hwc) return EINA_TRUE; } +static Eina_Bool +_e_hwc_windows_commit_handler_timeout(void *data) +{ + E_Hwc *hwc = (E_Hwc *)data; + + if (!hwc) return ECORE_CALLBACK_CANCEL; + + EHWSERR("Timeout wait commit", hwc); + + if (hwc->pp_output_commit_data) + _e_hwc_windows_pp_output_commit_handler(hwc->thwc, 0, 0, 0, hwc); + else + _e_hwc_windows_commit_handler(hwc->thwc, 0, 0, 0, hwc); + + hwc->wait_commit = EINA_FALSE; + hwc->commit_handler_timer = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +static void +_e_hwc_windows_wait_commit_set(E_Hwc *hwc, Eina_Bool set) +{ + if (hwc->wait_commit == set) return; + + if (e_comp->commit_handler_timer.use) + { + if (hwc->commit_handler_timer) + { + ecore_timer_del(hwc->commit_handler_timer); + hwc->commit_handler_timer = NULL; + } + + if (set) + hwc->commit_handler_timer = ecore_timer_add(e_comp->commit_handler_timer.interval, + _e_hwc_windows_commit_handler_timeout, + hwc); + } + + hwc->wait_commit = set; +} + static Eina_Bool _e_hwc_windows_device_states_available_check(E_Hwc *hwc) { @@ -3207,7 +3253,7 @@ _e_hwc_windows_external_pp_set(E_Hwc *hwc, tbm_surface_h src, tbm_surface_h dst, ret = tdm_pp_commit(hwc->tpp); EINA_SAFETY_ON_FALSE_GOTO(ret == TDM_ERROR_NONE, pp_fail); - hwc->wait_commit = EINA_TRUE; + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); hwc->pp_commit = EINA_TRUE; return EINA_TRUE; @@ -3543,7 +3589,7 @@ e_hwc_windows_commit(E_Hwc *hwc, E_Output_Display_Mode display_mode) EHWSTRACE("!!!!!!!! HWC Commit !!!!!!!!", NULL, hwc); _e_hwc_windows_update_fps(hwc); - hwc->wait_commit = EINA_TRUE; + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); error = tdm_hwc_commit(hwc->thwc, 0, _e_hwc_windows_commit_handler, hwc); if (error != TDM_ERROR_NONE) @@ -3578,7 +3624,7 @@ e_hwc_windows_commit(E_Hwc *hwc, E_Output_Display_Mode display_mode) return EINA_TRUE; fail: - hwc->wait_commit = EINA_FALSE; + _e_hwc_windows_wait_commit_set(hwc, EINA_FALSE); return EINA_FALSE; } @@ -3778,7 +3824,7 @@ e_hwc_windows_zoom_unset(E_Hwc *hwc) } if (hwc->pp_output_commit_data) - hwc->wait_commit = EINA_TRUE; + _e_hwc_windows_wait_commit_set(hwc, EINA_TRUE); hwc->pp_src_rect_prev.x = 0; hwc->pp_src_rect_prev.y = 0; -- 2.34.1