e_hwc_windows: add the restriction of hwc 13/306013/4
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 23 Jan 2024 04:58:29 +0000 (13:58 +0900)
committerchangyeon lee <cyeon.lee@samsung.com>
Mon, 19 Feb 2024 05:51:39 +0000 (05:51 +0000)
Previously, the device_state_available of hwc_window was updated in every idle time
if wait_commit is false.
For reducing usage of cpu, this patch makes the device_state_available is removed and
the restriction of hwc is added and updated when condition of the restriction is
changed.

Change-Id: Ieab8e2e70c7b93be4e6d02092a4a801234ceb947

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

index 244419c9ebb7fdada73462c12aa8a87dba7545ed..ba716c8024ad87b8d9f2541908c729834fe015b3 100644 (file)
@@ -698,9 +698,15 @@ e_hwc_deactive_set(E_Hwc *hwc, Eina_Bool set)
    hwc->hwc_deactive = set;
 
    if (set)
-     ecore_event_add(E_EVENT_HWC_DEACTIVE, NULL, NULL, NULL);
+     {
+        e_hwc_windows_restriction_set(hwc, E_HWC_WINS_RESTRICTION_DEACTIVE);
+        ecore_event_add(E_EVENT_HWC_DEACTIVE, NULL, NULL, NULL);
+     }
    else
-     ecore_event_add(E_EVENT_HWC_ACTIVE, NULL, NULL, NULL);
+     {
+        e_hwc_windows_restriction_unset(hwc, E_HWC_WINS_RESTRICTION_DEACTIVE);
+        ecore_event_add(E_EVENT_HWC_ACTIVE, NULL, NULL, NULL);
+     }
 
    EHINF("e_hwc_deactive_set : %d", hwc, set);
 }
index 761bd22709872e0ef7d324cfea9d30c6d1d8bf82..51afe873dec7a989b459066bc1655d95fbf678f4 100644 (file)
@@ -143,7 +143,6 @@ struct _E_Hwc
    Eina_Bool            wait_commit;
    Eina_List           *visible_windows;
    int                  num_visible_windows;
-   Eina_Bool            device_state_available;
    Eina_Bool            re_evaluate;
    Eina_Bool            property_changed;
 
@@ -214,6 +213,8 @@ struct _E_Hwc
    } output_available;
 
    Eina_Bool            comp_override;
+
+   unsigned int         restriction;
 };
 
 E_API extern int E_EVENT_HWC_ACTIVE;
index a6b76453a98bb6a13b7a549ed6d0ed040b02d711..1a996e25885072b22486fa80714bdccf39d9a2d7 100644 (file)
@@ -61,6 +61,7 @@ struct _E_Hwc_Windows_Comp_Info
 
 static Eina_Bool ehws_trace = EINA_FALSE;
 static Eina_Bool ehws_dump_enable = EINA_FALSE;
+static Eina_List *hwc_windows_event_hdlrs = NULL;
 
 static int E_EVENT_HWC_WINDOWS_COMP_INFO_FREE = -1;
 
@@ -1818,12 +1819,6 @@ _e_hwc_windows_wait_commit_set(E_Hwc *hwc, Eina_Bool set)
    hwc->wait_commit = set;
 }
 
-static Eina_Bool
-_e_hwc_windows_device_states_available_check(E_Hwc *hwc)
-{
-   return hwc->device_state_available;
-}
-
 static void
 _e_hwc_windows_status_print(E_Hwc *hwc, Eina_Bool with_target)
 {
@@ -1831,8 +1826,8 @@ _e_hwc_windows_status_print(E_Hwc *hwc, Eina_Bool with_target)
    const Eina_List *l;
    E_Hwc_Window *hwc_window;
 
-   EHWSTRACE(" Device state available : %d", NULL, hwc,
-             _e_hwc_windows_device_states_available_check(hwc));
+   EHWSTRACE(" Restriction : 0x%x", NULL, hwc,
+             e_hwc_windows_restriction_get(hwc));
 
    EINA_LIST_FOREACH(visible_windows, l, hwc_window)
      {
@@ -2081,7 +2076,7 @@ _e_hwc_windows_visible_windows_states_update(E_Hwc *hwc)
    visible_windows = hwc->visible_windows;
 
    /* check if e20 forces to set that all window has TDM_HWC_WIN_COMPOSITION_CLIENT types */
-   if (_e_hwc_windows_device_states_available_check(hwc))
+   if (!e_hwc_windows_restriction_get(hwc))
      {
         /* check clients are able to use hwc */
         EINA_LIST_FOREACH(visible_windows, l, hwc_window)
@@ -2215,47 +2210,6 @@ _e_hwc_windows_visible_windows_update(E_Hwc *hwc)
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_e_hwc_windows_device_state_available_update(E_Hwc *hwc)
-{
-   Eina_Bool available = EINA_TRUE;
-
-   /* make the full_gl_composite when the zoom is enabled */
-   if (hwc->pp_set)
-     {
-        available = EINA_FALSE;
-        goto finish;
-     }
-
-   /* make the full_gl_composite when the mirror mode is enabled */
-   if (eina_list_count(hwc->mirror_dst_hwc))
-     {
-        available = EINA_FALSE;
-        goto finish;
-     }
-
-   /* full composite is forced to be set */
-   if (e_hwc_deactive_get(hwc))
-     {
-        available = EINA_FALSE;
-        goto finish;
-     }
-
-   /* hwc_window manager required full GLES composition */
-   if (e_comp->nocomp_override > 0)
-     {
-        available = EINA_FALSE;
-        goto finish;
-     }
-
-finish:
-   if (hwc->device_state_available == available) return EINA_FALSE;
-
-   hwc->device_state_available = available;
-
-   return EINA_TRUE;
-}
-
 static void
 _e_hwc_windows_pp_hwc_window_update(E_Hwc *hwc)
 {
@@ -2320,10 +2274,6 @@ _e_hwc_windows_changes_update(E_Hwc *hwc)
    if (_e_hwc_windows_visible_windows_update(hwc))
      update_changes = EINA_TRUE;
 
-  /* update the the visible windows */
-   if (_e_hwc_windows_device_state_available_update(hwc))
-     update_changes = EINA_TRUE;
-
    EINA_LIST_FOREACH_SAFE(hwc->hwc_windows, l, ll, hwc_window)
      {
         if (e_hwc_window_is_target(hwc_window)) continue;
@@ -2800,6 +2750,39 @@ _e_hwc_windows_pp_update(E_Hwc *hwc)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_e_hwc_windows_cb_desk_geometry_change(void *data, int type, void *event)
+{
+   E_Event_Desk_Geometry_Change *ev;
+   E_Desk *desk;
+   E_Zone *zone;
+   E_Output *output;
+   E_Hwc *hwc;
+
+   ev = event;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
+
+   desk = ev->desk;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(desk, ECORE_CALLBACK_PASS_ON);
+
+   zone = desk->zone;
+   if (!zone) return ECORE_CALLBACK_PASS_ON;
+
+   output = e_output_find(zone->output_id);
+   if (!output) return ECORE_CALLBACK_PASS_ON;
+
+   hwc = output->hwc;
+   if (!hwc) return ECORE_CALLBACK_PASS_ON;
+
+   if ((desk->geom.x != zone->x) || (desk->geom.y != zone->y) ||
+       (desk->geom.w != zone->w) || (desk->geom.h != zone->h))
+     e_hwc_windows_restriction_set(hwc, E_HWC_WINS_RESTRICTION_DESK_GEOMETRY);
+   else
+     e_hwc_windows_restriction_unset(hwc, E_HWC_WINS_RESTRICTION_DESK_GEOMETRY);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 EINTERN Eina_Bool
 e_hwc_windows_init(void)
 {
@@ -2816,12 +2799,17 @@ e_hwc_windows_init(void)
         return EINA_FALSE;
      }
 
+   E_LIST_HANDLER_APPEND(hwc_windows_event_hdlrs, E_EVENT_DESK_GEOMETRY_CHANGE,
+                         _e_hwc_windows_cb_desk_geometry_change, NULL);
+
    return EINA_TRUE;
 }
 
 EINTERN void
 e_hwc_windows_deinit(void)
 {
+   E_FREE_LIST(hwc_windows_event_hdlrs, ecore_event_handler_del);
+
    e_hwc_window_queue_deinit();
    e_hwc_window_deinit();
 }
@@ -3479,6 +3467,8 @@ e_hwc_windows_pp_set(E_Hwc *hwc, Eina_Rectangle *src_rect, Eina_Rectangle *dst_r
 
    hwc->pp_set = EINA_TRUE;
 
+   e_hwc_windows_restriction_set(hwc, E_HWC_WINS_RESTRICTION_PP_SET);
+
    return EINA_TRUE;
 
 fail:
@@ -3508,6 +3498,8 @@ e_hwc_windows_pp_unset(E_Hwc *hwc)
    hwc->pp_hwc_window = NULL;
    hwc->pp_set = EINA_FALSE;
 
+   e_hwc_windows_restriction_unset(hwc, E_HWC_WINS_RESTRICTION_PP_SET);
+
    if (hwc->pp_tqueue)
      {
         EHWSINF("PP Destroy pp_tqueue:%p", NULL, hwc, hwc->pp_tqueue);
@@ -4016,6 +4008,8 @@ e_hwc_windows_mirror_set(E_Hwc *hwc, E_Hwc *src_hwc)
    /* add mirror_dst list to the src_hwc */
    src_hwc->mirror_dst_hwc = eina_list_append(src_hwc->mirror_dst_hwc, hwc);
 
+   e_hwc_windows_restriction_set(hwc, E_HWC_WINS_RESTRICTION_MIRROR);
+
    EHWSINF("e_hwc_windows_mirror_set src_hwc:%p", NULL, hwc, src_hwc);
 
    return EINA_TRUE;
@@ -4037,6 +4031,8 @@ e_hwc_windows_mirror_unset(E_Hwc *hwc)
 
    /* remove mirror_dst list at the src_hwc */
    src_hwc->mirror_dst_hwc = eina_list_remove(src_hwc->mirror_dst_hwc, hwc);
+   if (!src_hwc->mirror_dst_hwc)
+     e_hwc_windows_restriction_unset(hwc, E_HWC_WINS_RESTRICTION_MIRROR);
 
    if (hwc->zoom_enabled)
      {
@@ -4144,4 +4140,41 @@ e_hwc_windows_comp_override_set(E_Hwc *hwc, Eina_Bool set)
    if (hwc->comp_override == set) return;
 
    hwc->comp_override = set;
+
+   if (set)
+     e_hwc_windows_restriction_set(hwc, E_HWC_WINS_RESTRICTION_COMP_OVERRIDE);
+   else
+     e_hwc_windows_restriction_unset(hwc, E_HWC_WINS_RESTRICTION_COMP_OVERRIDE);
+}
+
+EINTERN void
+e_hwc_windows_restriction_set(E_Hwc *hwc, E_Hwc_Windows_Restriction restriction)
+{
+   EINA_SAFETY_ON_NULL_RETURN(hwc);
+
+   if (hwc->restriction & restriction) return;
+
+   hwc->restriction |= restriction;
+
+   EHWSTRACE("restriction set:0x%x", NULL, hwc, restriction);
+}
+
+EINTERN void
+e_hwc_windows_restriction_unset(E_Hwc *hwc, E_Hwc_Windows_Restriction restriction)
+{
+   EINA_SAFETY_ON_NULL_RETURN(hwc);
+
+   if (!(hwc->restriction & restriction)) return;
+
+   hwc->restriction &= ~restriction;
+
+   EHWSTRACE("restriction set:0x%x", NULL, hwc, restriction);
+}
+
+EINTERN unsigned int
+e_hwc_windows_restriction_get(E_Hwc *hwc)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, 0);
+
+   return hwc->restriction;
 }
index bd8c79e7b8fcd45bf483214d8d7cc254d76f407e..7c6b52b00f93fc45ed3b1f1792a95860b48f5203 100644 (file)
@@ -6,6 +6,16 @@ typedef struct _E_Hwc_Windows_Commit_Data  E_Hwc_Windows_Commit_Data;
 #ifndef E_HWC_WINDOWS_H
 #define E_HWC_WINDOWS_H
 
+typedef enum _E_Hwc_Windows_Restriction
+{
+   E_HWC_WINS_RESTRICTION_NONE = 0,
+   E_HWC_WINS_RESTRICTION_PP_SET = (1 << 0),
+   E_HWC_WINS_RESTRICTION_MIRROR = (1 << 1),
+   E_HWC_WINS_RESTRICTION_DEACTIVE = (1 << 2),
+   E_HWC_WINS_RESTRICTION_COMP_OVERRIDE = (1 << 3),
+   E_HWC_WINS_RESTRICTION_DESK_GEOMETRY = (1 << 4),
+} E_Hwc_Windows_Restriction;
+
 typedef enum
 {
    E_HWC_WINS_DEBUG_CMD_NONE,
@@ -71,5 +81,9 @@ EINTERN void                 e_hwc_windows_presentation_time_feedback_and_callba
 
 EINTERN void                 e_hwc_windows_comp_override_set(E_Hwc *hwc, Eina_Bool set);
 
+EINTERN void                 e_hwc_windows_restriction_set(E_Hwc *hwc, E_Hwc_Windows_Restriction restriction);
+EINTERN void                 e_hwc_windows_restriction_unset(E_Hwc *hwc, E_Hwc_Windows_Restriction restriction);
+EINTERN unsigned int         e_hwc_windows_restriction_get(E_Hwc *hwc);
+
 #endif
 #endif