e_hwc_window: Send the event to wl_tbm_queue which received the activate event 57/264857/4
authorChangyeon Lee <cyeon.lee@samsung.com>
Fri, 1 Oct 2021 05:42:15 +0000 (14:42 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 6 Oct 2021 03:10:03 +0000 (12:10 +0900)
if wl_surface has multiple wl_tbm_queue, it is possible that
the deactivate/usable/export event is sent to wl_tbm_queue which does not
recevied the activate event.

Fix the problem scenario
1. Create wl_tbm_queue1 with wl_surface1
2. Send the activate event to wl_tbm_queue1
3. Create wl_tbm_queue2 with wl_surface2
4. Send the deactivate/usable/export event to wl_tbm_queue2

this patch has dependency with wayland-tbm patch
server: Add wayland_tbm_server_client_queue_set_destroy_cb

Change-Id: I7b1a7c1c361407d106ef04ddb48c14b2e60efbe6

src/bin/e_hwc_window.c
src/bin/e_hwc_window.h
src/bin/e_hwc_window_queue.c

index fd6cb407b55ca57a84fc8a0ef714dbf2386a35aa..36c822523951549fbab021506a1585afb9738ea1 100644 (file)
@@ -610,6 +610,11 @@ _e_hwc_window_free(E_Hwc_Window *hwc_window)
    if (hwc_window->thwc_window)
      tdm_hwc_window_destroy(hwc_window->thwc_window);
 
+   if (hwc_window->cqueue)
+     wayland_tbm_server_client_queue_set_destroy_cb(hwc_window->cqueue,
+                                                    NULL,
+                                                    NULL);
+
    EHWINF("Free", NULL, hwc_window->hwc, hwc_window);
 
 done:
@@ -1832,6 +1837,14 @@ e_hwc_window_commit_data_release(E_Hwc_Window *hwc_window, E_Hwc_Window_Commit_D
    return EINA_TRUE;
 }
 
+static void
+_e_hwc_window_cqueue_destroy_cb(struct wayland_tbm_client_queue *cqueue, void *data)
+{
+   E_Hwc_Window *hwc_window = (E_Hwc_Window *)data;
+
+   hwc_window->cqueue = NULL;
+}
+
 EINTERN Eina_Bool
 e_hwc_window_activate(E_Hwc_Window *hwc_window, E_Hwc_Window_Queue *queue)
 {
@@ -1857,8 +1870,14 @@ e_hwc_window_activate(E_Hwc_Window *hwc_window, E_Hwc_Window_Queue *queue)
 
    cqueue = _get_wayland_tbm_client_queue(hwc_window->ec);
    if (cqueue)
-     wayland_tbm_server_client_queue_activate(cqueue, 0, queue_size,
-                                              queue_width, queue_height, flush);
+     {
+        wayland_tbm_server_client_queue_activate(cqueue, 0, queue_size,
+                                                 queue_width, queue_height, flush);
+        wayland_tbm_server_client_queue_set_destroy_cb(cqueue,
+                                                       _e_hwc_window_cqueue_destroy_cb,
+                                                       hwc_window);
+        hwc_window->cqueue = cqueue;
+     }
 
    EHWINF("Activate -- ehwq:%p {%s}",
           hwc_window->ec, hwc_window->hwc, hwc_window, queue,
@@ -1872,8 +1891,6 @@ e_hwc_window_activate(E_Hwc_Window *hwc_window, E_Hwc_Window_Queue *queue)
 EINTERN Eina_Bool
 e_hwc_window_deactivate(E_Hwc_Window *hwc_window)
 {
-   struct wayland_tbm_client_queue * cqueue = NULL;
-
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window->ec, EINA_FALSE);
 
@@ -1882,9 +1899,14 @@ e_hwc_window_deactivate(E_Hwc_Window *hwc_window)
 
    if (e_hwc_window_is_cursor(hwc_window)) return EINA_TRUE;
 
-   cqueue = _get_wayland_tbm_client_queue(hwc_window->ec);
-   if (cqueue)
-     wayland_tbm_server_client_queue_deactivate(cqueue);
+   if (hwc_window->cqueue)
+     {
+        wayland_tbm_server_client_queue_deactivate(hwc_window->cqueue);
+        wayland_tbm_server_client_queue_set_destroy_cb(hwc_window->cqueue,
+                                                       NULL,
+                                                       NULL);
+        hwc_window->cqueue = NULL;
+     }
 
    EHWINF("Deactivate -- {%s}",
           hwc_window->ec, hwc_window->hwc, hwc_window,
index b8b80ab4e816ce37efdc28233552c5fee05b4898..0859b626f1fb5a36da2a8f3ab544b9d21d44d960 100644 (file)
@@ -158,6 +158,8 @@ struct _E_Hwc_Window
 
    E_Hwc_Presentation_Callback_List pending_presentation_callbacks;
    E_Hwc_Presentation_Callback_List presentation_callbacks;
+
+   struct wayland_tbm_client_queue *cqueue;
 };
 
 struct _E_Hwc_Window_Target
index 2a680f21dd3256e80f283ce8fd924a34954f52f3..b36f88db6c5be8ea13e3d889333640a30d71e3d9 100644 (file)
@@ -494,7 +494,6 @@ _e_hwc_window_queue_exported_buffer_detach_cb(struct wayland_tbm_client_queue *c
 static Eina_Bool
 _e_hwc_window_queue_buffer_export(E_Hwc_Window_Queue *queue, E_Hwc_Window_Queue_Buffer *queue_buffer)
 {
-   struct wayland_tbm_client_queue * cqueue = NULL;
    struct wl_resource *wl_buffer = NULL;
    E_Hwc_Window *user = NULL;
 
@@ -504,13 +503,12 @@ _e_hwc_window_queue_buffer_export(E_Hwc_Window_Queue *queue, E_Hwc_Window_Queue_
    user = queue->user;
    EINA_SAFETY_ON_NULL_RETURN_VAL(user, EINA_FALSE);
 
-   cqueue = _user_cqueue_get(user->ec);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(cqueue, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(user->cqueue, EINA_FALSE);
 
    if (queue_buffer->exported) return EINA_TRUE;
 
    /* export the tbm_surface(wl_buffer) to the client_queue */
-   wl_buffer = wayland_tbm_server_client_queue_export_buffer2(cqueue, queue_buffer->tsurface,
+   wl_buffer = wayland_tbm_server_client_queue_export_buffer2(user->cqueue, queue_buffer->tsurface,
                                                               E_HWC_WINDOW_QUEUE_BUFFER_FLAGS,
                                                               _e_hwc_window_queue_exported_buffer_detach_cb,
                                                               NULL,
@@ -534,7 +532,6 @@ _e_hwc_window_queue_buffer_send(E_Hwc_Window_Queue *queue)
 {
    E_Hwc_Window_Queue_Buffer *queue_buffer = NULL;
    E_Hwc_Window *hwc_window = NULL;
-   struct wayland_tbm_client_queue * cqueue = NULL;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(queue, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(queue->tqueue, EINA_FALSE);
@@ -544,8 +541,7 @@ _e_hwc_window_queue_buffer_send(E_Hwc_Window_Queue *queue)
    hwc_window = queue->user;
    EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
 
-   cqueue = _user_cqueue_get(hwc_window->ec);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(cqueue, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window->cqueue, EINA_FALSE);
 
    queue_buffer = e_hwc_window_queue_buffer_dequeue(queue);
    EINA_SAFETY_ON_NULL_RETURN_VAL(queue_buffer, EINA_FALSE);
@@ -561,7 +557,7 @@ _e_hwc_window_queue_buffer_send(E_Hwc_Window_Queue *queue)
      }
 
    /* send the buffer_usable to the wl_tbm client */
-   wayland_tbm_server_client_queue_send_buffer_usable(cqueue, queue_buffer->exported_wl_buffer);
+   wayland_tbm_server_client_queue_send_buffer_usable(hwc_window->cqueue, queue_buffer->exported_wl_buffer);
    queue_buffer->usable = EINA_TRUE;
 
    EHWQINF("USA ts:%p tq:%p wl_buffer:%p ehw:%p",
@@ -962,7 +958,6 @@ _e_hwc_window_queue_set(E_Hwc_Window_Queue *queue)
 static void
 _e_hwc_window_queue_prepare_unset(E_Hwc_Window_Queue *queue)
 {
-   struct wayland_tbm_client_queue *cqueue = NULL;
    E_Hwc_Window *hwc_window = queue->user;
    tbm_surface_h tsurface;
    E_Hwc_Window_Queue_Buffer *queue_buffer;
@@ -976,9 +971,8 @@ _e_hwc_window_queue_prepare_unset(E_Hwc_Window_Queue *queue)
 
    if (!hwc_window || !hwc_window->ec) return;
 
-   cqueue = _user_cqueue_get(hwc_window->ec);
-   if (cqueue)
-     wayland_tbm_server_client_queue_set_wait_usable_cb(cqueue, NULL, NULL);
+   if (hwc_window->cqueue)
+     wayland_tbm_server_client_queue_set_wait_usable_cb(hwc_window->cqueue, NULL, NULL);
 
    if ((!_comp_wl_buffer_get(hwc_window->ec)) &&
        (!evas_object_visible_get(hwc_window->ec->frame)) &&