Added internal function to check buffer is validate 85/276085/3
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 9 Jun 2022 09:43:49 +0000 (18:43 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Wed, 10 Aug 2022 05:00:43 +0000 (14:00 +0900)
 - It can be modified flexibly.
 - For now, this function can check if given tbm_surface_h
  is managed by wl_egl_surface.

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

index 2ad01c23d5b9f7fc74cb53912280841d6c50b51e..e94fe160b8afa81700ee355f6f16be067d330239 100755 (executable)
@@ -252,6 +252,8 @@ static int
 _get_tbm_surface_bo_name(tbm_surface_h tbm_surface);
 static void
 _print_buffer_lists(tpl_wl_egl_surface_t *wl_egl_surface);
+static tpl_bool_t
+_check_buffer_validate(tpl_wl_egl_surface_t *wl_egl_surface, tbm_surface_h tbm_surface);
 static void
 __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer);
 static tpl_wl_egl_buffer_t *
@@ -3639,3 +3641,31 @@ _print_buffer_lists(tpl_wl_egl_surface_t *wl_egl_surface)
        }
        tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex);
 }
+
+static tpl_bool_t
+_check_buffer_validate(tpl_wl_egl_surface_t *wl_egl_surface, tbm_surface_h tbm_surface)
+{
+       int idx = 0;
+       tpl_bool_t ret = TPL_FALSE;
+
+       /* silent return */
+       if (!wl_egl_surface || !tbm_surface)
+               return ret;
+
+       tpl_gmutex_lock(&wl_egl_surface->buffers_mutex);
+       for (idx = 0; idx < BUFFER_ARRAY_SIZE; idx++) {
+               tpl_wl_egl_buffer_t *wl_egl_buffer = wl_egl_surface->buffers[idx];
+               if (wl_egl_buffer && wl_egl_buffer->tbm_surface == tbm_surface) {
+                       ret = TPL_TRUE;
+                       break;
+               }
+       }
+
+       if (ret == TPL_FALSE || idx == BUFFER_ARRAY_SIZE) {
+               TPL_ERR("tbm_surface(%p) is not owned by wl_egl_surface(%p)",
+                               tbm_surface, wl_egl_surface);
+       }
+       tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex);
+
+       return ret;
+}