e_hwc_windows: init/deinit hwc_window member of target hwc window 19/271319/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 10 Feb 2022 06:59:24 +0000 (15:59 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Fri, 18 Feb 2022 02:15:48 +0000 (11:15 +0900)
fix leak of hwc_widnow member of target hwc window

Change-Id: I89ccc56e0b61cac942318141f5c4983c7fe29d09

src/bin/e_hwc_windows.c

index 44fd3ef9e9a93ac6b7641941ee85ca092d461617..0dc31d510baa58dd98f379a4d18600f46d67246e 100644 (file)
@@ -1732,7 +1732,7 @@ _e_hwc_windows_target_window_render_flush_post_cb(void *data, Evas *e EINA_UNUSE
 static void
 _e_hwc_windows_target_window_free(E_Hwc_Window_Target *target_hwc_window)
 {
-   E_Hwc_Window *target_window = (E_Hwc_Window *)target_hwc_window;
+   E_Hwc_Window *hwc_window = (E_Hwc_Window *)target_hwc_window;
 
    if (target_hwc_window->evas)
      {
@@ -1755,8 +1755,26 @@ _e_hwc_windows_target_window_free(E_Hwc_Window_Target *target_hwc_window)
    if (target_hwc_window->event_fd >= 0)
      close(target_hwc_window->event_fd);
 
-   if (target_window->queue && target_window->queue->tqueue)
-     tbm_surface_queue_destroy(target_window->queue->tqueue);
+   if (hwc_window->queue && hwc_window->queue->tqueue)
+     tbm_surface_queue_destroy(hwc_window->queue->tqueue);
+
+   e_presentation_time_container_finish(&hwc_window->presentation_container);
+   e_hwc_presentation_callback_list_finish(&hwc_window->pending_presentation_callbacks);
+   e_hwc_presentation_callback_list_finish(&hwc_window->presentation_callbacks);
+
+   if (hwc_window->queue_destroy_listener.notify)
+     {
+        wl_list_remove(&hwc_window->queue_destroy_listener.link);
+        hwc_window->queue_destroy_listener.notify = NULL;
+     }
+
+   e_hwc_window_queue_buffer_reference(&hwc_window->current.queue_buffer_ref, NULL);
+   e_hwc_window_queue_buffer_reference(&hwc_window->commit.queue_buffer_ref, NULL);
+   e_hwc_window_queue_buffer_reference(&hwc_window->display.queue_buffer_ref, NULL);
+
+   e_hwc_window_buffer_set(&hwc_window->current.buffer, NULL, NULL, 0);
+   e_hwc_window_buffer_set(&hwc_window->commit.buffer, NULL, NULL, 0);
+   e_hwc_window_buffer_set(&hwc_window->display.buffer, NULL, NULL, 0);
 
    EHWSINF("Free target window", NULL, NULL);
 
@@ -3615,6 +3633,7 @@ EINTERN E_Hwc_Window_Target *
 e_hwc_windows_target_window_new(E_Hwc *hwc, Eina_Bool is_root_target)
 {
    E_Hwc_Window_Target *target_hwc_window;
+   E_Hwc_Window *hwc_window;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc->thwc, NULL);
@@ -3625,11 +3644,17 @@ e_hwc_windows_target_window_new(E_Hwc *hwc, Eina_Bool is_root_target)
    target_hwc_window = E_OBJECT_ALLOC(E_Hwc_Window_Target, E_HWC_WINDOW_TYPE, _e_hwc_windows_target_window_free);
    EINA_SAFETY_ON_NULL_GOTO(target_hwc_window, fail);
 
-   ((E_Hwc_Window *)target_hwc_window)->is_root_target = is_root_target;
-   ((E_Hwc_Window *)target_hwc_window)->is_target = EINA_TRUE;
-   ((E_Hwc_Window *)target_hwc_window)->state = E_HWC_WINDOW_STATE_DEVICE;
-   ((E_Hwc_Window *)target_hwc_window)->accepted_state = E_HWC_WINDOW_STATE_DEVICE;
-   ((E_Hwc_Window *)target_hwc_window)->hwc = hwc;
+   hwc_window = (E_Hwc_Window *)target_hwc_window;
+
+   hwc_window->is_root_target = is_root_target;
+   hwc_window->is_target = EINA_TRUE;
+   hwc_window->state = E_HWC_WINDOW_STATE_DEVICE;
+   hwc_window->accepted_state = E_HWC_WINDOW_STATE_DEVICE;
+   hwc_window->hwc = hwc;
+
+   e_presentation_time_container_init(&hwc_window->presentation_container);
+   e_hwc_presentation_callback_list_init(&hwc_window->pending_presentation_callbacks);
+   e_hwc_presentation_callback_list_init(&hwc_window->presentation_callbacks);
 
    target_hwc_window->hwc = hwc;
    target_hwc_window->event_fd = -1;