video: Do not initialize hwc backend with the same zone 11/292111/2
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 25 Apr 2023 08:43:42 +0000 (17:43 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Thu, 27 Apr 2023 08:28:04 +0000 (08:28 +0000)
When an E_EVENT_CLIENT_ZONE_SET event issues, it has to check the given
zone to see if it is the same as previous zone to prevent from
initializing hwc backend again unnecessarily.

Change-Id: I0b792bac6368414269c791587da0e5661dc5cbf2

src/bin/video/e_client_video.c

index 1faa6b2..1be58fc 100644 (file)
@@ -24,6 +24,7 @@ struct _E_Client_Video
    E_Video_Comp_Iface *iface;
 
    E_Client *ec;
+   E_Zone *zone;
 
    Eina_List *event_handlers;
 
@@ -79,30 +80,30 @@ _e_client_video_cb_hwc_render_fail(E_Client_Video *ecv)
 }
 
 static Eina_Bool
-_e_client_video_comp_iface_init(E_Client_Video *ecv, E_Client *ec)
+_e_client_video_comp_iface_init(E_Client_Video *ecv)
 {
    E_Video_Comp_Iface *iface = NULL;
    E_Hwc_Policy hwc_pol;
 
-   hwc_pol = e_zone_video_hwc_policy_get(ec->zone);
+   hwc_pol = e_zone_video_hwc_policy_get(ecv->zone);
 
-   if ((e_config->eom_enable == EINA_TRUE) && (e_eom_is_ec_external(ec)) &&
+   if ((e_config->eom_enable == EINA_TRUE) && (e_eom_is_ec_external(ecv->ec)) &&
        (hwc_pol == E_HWC_POLICY_PLANES))
      {
-        VIN("Try to intialize external interface", ec);
+        VIN("Try to intialize external interface", ecv->ec);
         iface = e_video_external_iface_create(ecv);
         goto end;
      }
 
    if (e_video_debug_display_primary_plane_value_get())
      {
-        VIN("Select SW Compositing mode according to configuration", ec);
+        VIN("Select SW Compositing mode according to configuration", ecv->ec);
         goto end;
      }
 
    if (hwc_pol != E_HWC_POLICY_NONE)
      {
-        VIN("Initialize the interface of the client_video for HWC mode", ec);
+        VIN("Initialize the interface of the client_video for HWC mode", ecv->ec);
         iface = e_video_hwc_iface_create(ecv);
         if (iface)
           e_video_hwc_render_fail_callback_set(iface, _e_client_video_cb_hwc_render_fail);
@@ -114,7 +115,7 @@ end:
         iface = e_video_fallback_iface_create(ecv);
         if (!iface)
           {
-             VER("Failed to create 'E_Video_Comp_Iface'", ec);
+             VER("Failed to create 'E_Video_Comp_Iface'", ecv->ec);
              return EINA_FALSE;
           }
      }
@@ -146,6 +147,27 @@ _e_client_video_del(E_Client_Video *ecv)
 }
 
 static Eina_Bool
+_e_client_video_cb_zone_del(void *data, int type EINA_UNUSED, void *event)
+{
+   E_Client_Video *ecv;
+   E_Event_Zone_Del *ev;
+
+   ecv = data;
+   ev = event;
+
+   if (ecv->zone != ev->zone)
+     goto end;
+
+   VIN("Zone(%p) deleted.", ecv->ec, ecv->zone);
+
+   _e_client_video_comp_iface_deinit(ecv);
+
+   ecv->zone = NULL;
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
 _e_client_video_cb_ec_zone_set(void *data, int type EINA_UNUSED, void *event)
 {
    E_Client_Video *ecv;
@@ -158,9 +180,16 @@ _e_client_video_cb_ec_zone_set(void *data, int type EINA_UNUSED, void *event)
    if (ecv->ec != ev->ec)
      goto end;
 
+   if (ecv->zone == ev->zone)
+     goto end;
+
+   VIN("Zone changed: old(%p) new(%p)", ecv->ec, ecv->zone, ev->zone);
+
+   ecv->zone = ev->zone;
+
    _e_client_video_comp_iface_deinit(ecv);
 
-   res = _e_client_video_comp_iface_init(ecv, ev->ec);
+   res = _e_client_video_comp_iface_init(ecv);
    if (!res)
      {
         VER("Failed to initialize the composition interface for video", ev->ec);
@@ -336,14 +365,17 @@ _e_client_video_init(E_Client_Video *ecv, E_Client *ec)
    Eina_Bool res;
 
    ecv->ec = ec;
+   ecv->zone = ec->zone;
 
-   res = _e_client_video_comp_iface_init(ecv, ec);
+   res = _e_client_video_comp_iface_init(ecv);
    if (!res)
      {
         VER("Failed to initialize the composition interface for video", ec);
         return EINA_FALSE;
      }
 
+   E_LIST_HANDLER_APPEND(ecv->event_handlers, E_EVENT_ZONE_DEL,
+                         _e_client_video_cb_zone_del, ecv);
    E_LIST_HANDLER_APPEND(ecv->event_handlers, E_EVENT_CLIENT_ZONE_SET,
                          _e_client_video_cb_ec_zone_set, ecv);
    E_LIST_HANDLER_APPEND(ecv->event_handlers, E_EVENT_CLIENT_VISIBILITY_CHANGE,