Initialize last_enq_buffer to null when it committed. 75/270175/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Wed, 26 Jan 2022 06:26:31 +0000 (15:26 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Wed, 26 Jan 2022 06:58:14 +0000 (15:58 +0900)
 - If the last_enq_buffer of wl_egl_surface has been committed,
  it is not necessary to have this handle pointer.

Change-Id: I3153b3cc9cb133f1d51321dc7aaa92f57b1e5ed8
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 95b9af0..f439bd6 100755 (executable)
@@ -2445,11 +2445,12 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
        if (wl_egl_surface->reset == TPL_TRUE &&
                tbm_surface_internal_is_valid(wl_egl_surface->last_enq_buffer)) {
+               tbm_surface_h last_enq_buffer = wl_egl_surface->last_enq_buffer;
                tpl_wl_egl_buffer_t *enqueued_buffer =
-                       _get_wl_egl_buffer(wl_egl_surface->last_enq_buffer);
+                       _get_wl_egl_buffer(last_enq_buffer);
 
                if (enqueued_buffer) {
-                       tbm_surface_internal_ref(wl_egl_surface->last_enq_buffer);
+                       tbm_surface_internal_ref(last_enq_buffer);
                        tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
                        tpl_gmutex_lock(&enqueued_buffer->mutex);
                        while (enqueued_buffer->status >= ENQUEUED &&
@@ -2470,7 +2471,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
                        }
                        tpl_gmutex_unlock(&enqueued_buffer->mutex);
                        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
-                       tbm_surface_internal_unref(wl_egl_surface->last_enq_buffer);
+                       tbm_surface_internal_unref(last_enq_buffer);
                }
 
                wl_egl_surface->last_enq_buffer = NULL;
@@ -3426,6 +3427,8 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface,
 
        wl_egl_buffer->need_to_commit   = TPL_FALSE;
        wl_egl_buffer->status           = COMMITTED;
+       if (wl_egl_surface->last_enq_buffer == wl_egl_buffer->tbm_surface)
+               wl_egl_surface->last_enq_buffer = NULL;
 
        tpl_gcond_signal(&wl_egl_buffer->cond);