e_comp_screen: call the init/deinit functions once during the lifetime 28/210328/3
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 18 Jul 2019 02:28:52 +0000 (11:28 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 18 Jul 2019 07:23:49 +0000 (07:23 +0000)
modify the code that the e20 call the init/deinit functions below only onetime.
When these functions call multiple times, it brings the serious bugs.
- e_hwc_planes_init/deinit
- e_hwc_windows_init/deinit
   - e_hwc_window_init/deinit
   - e_hwc_window_queue_init/deinit

Change-Id: I7b204b85dc395a8ec9d2b432f03f331ed50e8b01

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

index ce9d91f9e06030ad78674f2fb4c1b7f91f9f744a..f87236e6615ecdc8f46cf3c5cd6f2bdd70adfd99 100644 (file)
@@ -651,6 +651,8 @@ _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
         e_output_del(output);
      }
 
+   e_hwc_windows_deinit();
+   e_hwc_planes_deinit();
    e_output_shutdown();
 }
 
@@ -703,6 +705,18 @@ _e_comp_screen_init_outputs(E_Comp_Screen *e_comp_screen)
 
    ELOGF("COMP_SCREEN","num_outputs = %i", NULL, e_comp_screen->num_outputs);
 
+   if (!e_hwc_planes_init())
+     {
+        ERR("e_hwc_planes_init failed");
+        goto fail;
+     }
+
+   if (!e_hwc_windows_init())
+     {
+        ERR("e_hwc_windows_init failed");
+        goto fail;
+     }
+
    for (i = 0; i < num_outputs; i++)
      {
         TRACE_DS_BEGIN(OUTPUT:NEW);
index 0ea48edcc40d102dda586dddee15281aea105f23..0a86b72b625b2cd3b1cdff188aed97f9a0899222 100644 (file)
@@ -322,22 +322,33 @@ EINTERN E_Hwc *
 e_hwc_new(E_Output *output)
 {
    E_Hwc *hwc = NULL;
+   tdm_hwc_capability hwc_caps = 0;
    tdm_error error;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(output, NULL);
 
    hwc = E_NEW(E_Hwc, 1);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, NULL);
-
    hwc->output = output;
 
+   /*
+    * E20 has two hwc policy options.
+    * 1. One is the E_HWC_POLICY_PLANES.
+    *   - E20 decides the hwc policy with the E_Planes associated with the tdm_layers.
+    *   - E20 manages how to set the surface(buffer) of the ec to the E_Plane.
+    * 2. Another is the E_HWC_POLICY_WIDNOWS.
+    *   - The tdm-backend decides the hwc policy with the E_Hwc_Windows associated with the tdm_hwc_window.
+    *   - E20 asks to verify the composition types of the E_Hwc_Window of the ec.
+    */
    if (!output->tdm_hwc)
      {
         hwc->hwc_policy = E_HWC_POLICY_PLANES;
+        EHINF("Use the HWC PLANES Policy.", hwc);
      }
    else
      {
         hwc->hwc_policy = E_HWC_POLICY_WINDOWS;
+        EHINF("Use the HWC WINDOWS Policy.", hwc);
 
         hwc->thwc = tdm_output_get_hwc(output->toutput, &error);
         if (!hwc->thwc)
@@ -345,57 +356,41 @@ e_hwc_new(E_Output *output)
              EHERR("tdm_output_get_hwc failed", hwc);
              goto fail;
           }
+
+        error = tdm_hwc_get_capabilities(hwc->thwc, &hwc_caps);
+        if (error != TDM_ERROR_NONE)
+          {
+             EHERR("fail to tdm_hwc_get_capabilities", hwc);
+             return EINA_FALSE;
+          }
+
+        /* hwc video capabilities */
+        if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_STREAM)
+          hwc->tdm_hwc_video_stream = EINA_TRUE;
+        if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_SCALE)
+          hwc->tdm_hwc_video_scale = EINA_TRUE;
+        if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_TRANSFORM)
+          hwc->tdm_hwc_video_transform = EINA_TRUE;
+        if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_SCANOUT)
+          hwc->tdm_hwc_video_scanout = EINA_TRUE;
      }
 
+   /* initialize the ecore_evas in each hwc */
    if (!_e_hwc_ee_init(hwc))
      {
         EHERR("_e_hwc_ee_init failed", hwc);
         goto fail;
      }
 
-   /*
-    * E20 has two hwc policy options.
-    * 1. One is the E_HWC_POLICY_PLANES.
-    *   - E20 decides the hwc policy with the E_Planes associated with the tdm_layers.
-    *   - E20 manages how to set the surface(buffer) of the ec to the E_Plane.
-    * 2. Another is the E_HWC_POLICY_WIDNOWS.
-    *   - The tdm-backend decides the hwc policy with the E_Hwc_Windows associated with the tdm_hwc_window.
-    *   - E20 asks to verify the composition types of the E_Hwc_Window of the ec.
-    */
-   if (hwc->hwc_policy == E_HWC_POLICY_PLANES)
+   if (e_hwc_policy_get(hwc) == E_HWC_POLICY_WINDOWS)
      {
-        if (!e_hwc_planes_init())
+        /* create the target_window to the hwc */
+        hwc->target_hwc_window = e_hwc_windows_target_window_new(hwc);
+        if (!hwc->target_hwc_window)
           {
-             EHERR("e_hwc_windows_init failed", hwc);
+             EHERR("e_hwc_windows_target_window_new failed", hwc);
              goto fail;
           }
-
-        EHINF("Use the HWC PLANES Policy.", hwc);
-     }
-   else
-     {
-        if (!e_hwc_window_queue_init())
-          {
-             EHERR("E_Hwc_Window_Queue init failed", hwc);
-             goto fail;
-          }
-
-        if (!e_hwc_window_init())
-          {
-             EHERR("E_Hwc_Window init failed", hwc);
-             goto fail;
-          }
-
-        if (!e_hwc_windows_init(hwc))
-          {
-             EHERR("e_hwc_windows_init failed", hwc);
-             goto fail;
-          }
-
-        /* turn on sw compositor at the start */
-        ecore_event_add(E_EVENT_COMPOSITOR_ENABLE, NULL, NULL, NULL);
-
-        EHINF("Use the HWC WINDOWS Policy.", hwc);
      }
 
    return hwc;
@@ -411,17 +406,14 @@ e_hwc_del(E_Hwc *hwc)
 {
    if (!hwc) return;
 
-   _e_hwc_ee_deinit(hwc);
-
-   if (hwc->hwc_policy == E_HWC_POLICY_PLANES)
-      e_hwc_planes_deinit();
-   else
+   if (e_hwc_policy_get(hwc) == E_HWC_POLICY_WINDOWS)
      {
-        e_hwc_windows_deinit(hwc);
-        e_hwc_window_deinit();
-        e_hwc_window_queue_deinit();
+        e_hwc_windows_target_window_del(hwc->target_hwc_window);
+        hwc->target_hwc_window = NULL;
      }
 
+   _e_hwc_ee_deinit(hwc);
+
    E_FREE(hwc);
 }
 
index 5dc452e6e82363dc61ba58db4a606ffa45c674a1..d44625bcda1efa0df42e585057974e01a0ab3cf9 100644 (file)
@@ -2174,58 +2174,29 @@ _e_hwc_windos_pp_pending_window_check(E_Hwc *hwc)
 }
 
 EINTERN Eina_Bool
-e_hwc_windows_init(E_Hwc *hwc)
+e_hwc_windows_init(void)
 {
-   tdm_error error;
-   tdm_hwc_capability hwc_caps = 0;
-   E_Hwc_Window_Target *target_hwc_window;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc->thwc, EINA_FALSE);
-
-   if (e_hwc_policy_get(hwc) == E_HWC_POLICY_PLANES)
-     return EINA_FALSE;
-
-   target_hwc_window = _e_hwc_windows_target_window_new(hwc);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(target_hwc_window, EINA_FALSE);
-   target_hwc_window->hwc = hwc;
-
-   error = tdm_hwc_get_capabilities(hwc->thwc, &hwc_caps);
-   if (error != TDM_ERROR_NONE)
+   if (!e_hwc_window_init())
      {
-        EHWSERR("fail to tdm_hwc_get_capabilities", hwc);
+        ERR("E_Hwc_Window init failed");
         return EINA_FALSE;
      }
 
-   /* hwc video capabilities */
-   if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_STREAM)
-     hwc->tdm_hwc_video_stream = EINA_TRUE;
-   if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_SCALE)
-     hwc->tdm_hwc_video_scale = EINA_TRUE;
-   if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_TRANSFORM)
-     hwc->tdm_hwc_video_transform = EINA_TRUE;
-   if (hwc_caps & TDM_HWC_CAPABILITY_VIDEO_SCANOUT)
-     hwc->tdm_hwc_video_scanout = EINA_TRUE;
-
-   /* set the target_window to the hwc */
-   hwc->target_hwc_window = target_hwc_window;
-
-   hwc->hwc_windows = eina_list_append(hwc->hwc_windows, target_hwc_window);
+   if (!e_hwc_window_queue_init())
+     {
+        ERR("E_Hwc_Window_Queue init failed");
+        e_hwc_window_deinit();
+        return EINA_FALSE;
+     }
 
    return EINA_TRUE;
 }
 
 EINTERN void
-e_hwc_windows_deinit(E_Hwc *hwc)
+e_hwc_windows_deinit(void)
 {
-   EINA_SAFETY_ON_NULL_RETURN(hwc);
-
-   if (e_hwc_policy_get(hwc) == E_HWC_POLICY_PLANES)
-     return;
-
-   hwc->hwc_windows = eina_list_remove(hwc->hwc_windows, hwc->target_hwc_window);
-   e_object_del(E_OBJECT(hwc->target_hwc_window));
-   hwc->target_hwc_window = NULL;
+   e_hwc_window_queue_deinit();
+   e_hwc_window_deinit();
 }
 
 EINTERN Eina_Bool
index a692816e9e75301e2f252e644a99f0f75114da1e..85be4710f375409564df78ee9c48e65e18f2cd99 100644 (file)
@@ -16,8 +16,8 @@ typedef enum
    E_HWC_WINS_DEBUG_CMD_QUEUE,
 } E_Hwc_Wins_Debug_Cmd;
 
-EINTERN Eina_Bool            e_hwc_windows_init(E_Hwc *hwc);
-EINTERN void                 e_hwc_windows_deinit(E_Hwc *hwc);
+EINTERN Eina_Bool            e_hwc_windows_init(void);
+EINTERN void                 e_hwc_windows_deinit(void);
 EINTERN Eina_Bool            e_hwc_windows_render(E_Hwc *hwc);
 EINTERN Eina_Bool            e_hwc_windows_commit(E_Hwc *hwc);
 EINTERN E_Hwc_Window_Target *e_hwc_windows_target_window_new(E_Hwc *hwc);