wl_egl: implement set_pre_commit_callback 57/311457/3
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 21 May 2024 10:10:31 +0000 (19:10 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 28 Jun 2024 00:42:27 +0000 (09:42 +0900)
Change-Id: I223fd84d00c9e951d04d4149d3851c6c57c38610
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 1a7b9d5a4df52f3fb1c15220c96f00aedacaf795..ebb010f7410e585f1612a70df289815fb43b941b 100755 (executable)
@@ -250,6 +250,8 @@ struct _tpl_wl_egl_buffer {
         * presentation feedback from display server */
        int32_t                       presentation_sync_fd;
 
+       struct pre_commit_cb          pre_commit_cb;
+
        tpl_gsource                  *waiting_source;
 
        tpl_gmutex                    mutex;
@@ -2654,6 +2656,9 @@ _wl_egl_buffer_init(tpl_wl_egl_buffer_t *wl_egl_buffer,
                wl_egl_buffer->rects                = NULL;
                wl_egl_buffer->num_rects            = 0;
        }
+
+       wl_egl_buffer->pre_commit_cb.func = NULL;
+       wl_egl_buffer->pre_commit_cb.data = NULL;
 }
 
 static tpl_wl_egl_buffer_t *
@@ -3042,6 +3047,7 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface,
        tpl_wl_egl_buffer_t *wl_egl_buffer      = NULL;
        tbm_surface_queue_error_e tsq_err       = TBM_SURFACE_QUEUE_ERROR_NONE;
        int bo_name                             = -1;
+       struct tizen_private *tizen_private = wl_egl_tizen_get_tizen_private(wl_egl_surface->wl_egl_window);
 
        if (!tbm_surface_internal_is_valid(tbm_surface)) {
                TPL_ERR("Failed to enqueue tbm_surface(%p) Invalid value.",
@@ -3120,6 +3126,16 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface,
                wl_egl_surface->serial_updated = TPL_FALSE;
        }
 
+       if (tizen_private && tizen_private->pre_commit_cb.func) {
+               wl_egl_buffer->pre_commit_cb.func = tizen_private->pre_commit_cb.func;
+               wl_egl_buffer->pre_commit_cb.data = tizen_private->pre_commit_cb.data;
+
+               if (tizen_private->pre_commit_cb.option == ONCE) {
+                       tizen_private->pre_commit_cb.func = NULL;
+                       tizen_private->pre_commit_cb.data = NULL;
+               }
+       }
+
        tpl_gmutex_lock(&wl_egl_surface->presentation_sync.mutex);
        if (wl_egl_surface->presentation_sync.fd != -1) {
                wl_egl_buffer->presentation_sync_fd  = wl_egl_surface->presentation_sync.fd;
@@ -3754,6 +3770,17 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface,
                wl_egl_window->attached_height = wl_egl_buffer->height;
        }
 
+       if (wl_egl_buffer->pre_commit_cb.func) {
+               TPL_INFO("[CALL_PRE_COMMIT_CB]", "wl_egl_window(%p) func(%p) data(%p)",
+                                wl_egl_window, wl_egl_buffer->pre_commit_cb.func,
+                                wl_egl_buffer->pre_commit_cb.data);
+
+               wl_egl_buffer->pre_commit_cb.func(wl_egl_buffer->pre_commit_cb.data);
+
+               wl_egl_buffer->pre_commit_cb.func = NULL;
+               wl_egl_buffer->pre_commit_cb.data = NULL;
+       }
+
        wl_surface_attach(wl_surface, (void *)wl_egl_buffer->wl_buffer,
                                          wl_egl_buffer->dx, wl_egl_buffer->dy);
 
@@ -3999,6 +4026,11 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer)
                wl_egl_buffer->num_rects = 0;
        }
 
+       if (wl_egl_buffer->pre_commit_cb.func) {
+               wl_egl_buffer->pre_commit_cb.func = NULL;
+               wl_egl_buffer->pre_commit_cb.data = NULL;
+       }
+
        wl_egl_buffer->wl_egl_surface = NULL;
        wl_egl_buffer->tbm_surface = NULL;
        wl_egl_buffer->bo_name = -1;