e_hwc_windows: add timer of waiting commit handler 84/240184/3
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 29 Jul 2020 08:52:00 +0000 (17:52 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 5 Aug 2020 09:48:07 +0000 (18:48 +0900)
add config of e_comp commit_handler_timer.use and
commit_handler_timer.interval

Change-Id: Ib90a43468dc9202ab8ca5b39219819ed47b62d7f

src/bin/e_comp.c
src/bin/e_comp.h
src/bin/e_comp_cfdata.c
src/bin/e_comp_cfdata.h
src/bin/e_hwc.h
src/bin/e_hwc_windows.c

index 2b54c37f9061b0429296691b064cfbcd2af82806..d96c478e1e3a31739e44b07180bd3a58c197cff3 100644 (file)
@@ -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);
index aa5d553a0deff26d1eed6ea7af94dbb41654fe05..a3c04079bf5dd652c904c5f3e4c9ec478313af88 100644 (file)
@@ -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
index e1ffa22f3dabdbf4401804a8b8ee6dfd787677ec..55f61fd9db523e192cc257677fc71b673e8c583d 100644 (file)
@@ -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;
 
index d79560184c008b0bdbdd1bd4af9c8f5e9af37bf2..670d68110fafa05a57dd2c403ddcc8016c6aac2a 100644 (file)
@@ -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
index 6716cca31b0cf9e51f0ea80a387058555dafe322..9b252c8ef9ff5815b53d72a5da0c10d3283d4c37 100644 (file)
@@ -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;
index 50eae424ced812690a8408b0800a6408d9e296f4..740a1bf49f07b4da4a2419b828c95b8b0949072f 100644 (file)
@@ -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;