e_hwc_window: handle invalid case of releasing the usable queue buffer 57/286357/1 accepted/tizen/7.0/unified/20230106.165617
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 4 Jan 2023 09:03:07 +0000 (18:03 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 4 Jan 2023 10:59:06 +0000 (19:59 +0900)
if client attach general buffer after the queue buffer is attached,
the usable queue buffer is released and client can not get the queue buffer
for next frame.
it is invalid sequence of client rendering but we should handle this case.
add checking the usable queue buffer is relased and unset queue of ec.

Change-Id: I31ae261974fb3b4d76bf40cfcfbb02d22dd6b36d

src/bin/e_hwc_window_queue.c

index 7eac7bed90f8168f45fbd5805aa42c07616ed90a..57c21aa2c5436f9978d74a983a8a8f9e36a0b214 100644 (file)
@@ -684,6 +684,23 @@ _e_hwc_window_queue_buffers_retrieve_done(E_Hwc_Window_Queue *queue)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_e_hwc_window_queue_buffers_hand_over_validate(E_Hwc_Window_Queue *queue, E_Hwc_Window *hwc_window)
+{
+   E_Hwc_Window_Queue_Buffer *queue_buffer;
+   Eina_List *l;
+
+   EINA_LIST_FOREACH(queue->buffers, l, queue_buffer)
+     {
+        if (!queue_buffer->usable) continue;
+
+        if (queue_buffer->released)
+          return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
 static void
 _e_hwc_window_queue_cb_dequeueable(tbm_surface_queue_h surface_queue, void *data)
 {
@@ -710,6 +727,15 @@ _e_hwc_window_queue_cb_dequeueable(tbm_surface_queue_h surface_queue, void *data
              e_hwc_window_queue_user_unset(queue, queue->user);
           }
      }
+   else if (queue->state == E_HWC_WINDOW_QUEUE_STATE_SET_WAITING_BUFFER)
+     {
+        if (!_e_hwc_window_queue_buffers_hand_over_validate(queue, queue->user))
+          {
+             EHWQERR("fail to queue_buffers_hand_over_validate SET_WAITING_BUFFER",
+                     (queue->user ? queue->user->ec : NULL), queue->hwc, queue);
+             e_hwc_window_queue_user_unset(queue, queue->user);
+          }
+     }
 }
 
 static void