From: Joonbum Ko Date: Tue, 21 May 2024 10:05:50 +0000 (+0900) Subject: wayland-egl-tizen: add new API to set pre_commit callback. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4c51c80b87f58ba66b527482a52f65386bd9c67;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git wayland-egl-tizen: add new API to set pre_commit callback. Set pre-commit callback with data to wl_egl_window. The registered callback function will be called with the data immedately before the frame's wl_surface_commit. The callback registered before calling eglSwapBuffers will be called at the time the swap requested buffer is attached. * Important * - Since the callback may be called from a separate thread that performs wl_surface_commit, protection is required if there is a critical section inside the callback function. - To avoid poor performance or complicated lifecycle issues, it is recommended that the behavior inside the callback function be concise. - This API should be called from one thread. - If it is called multiple times in a frame, the previously registered ones are overwritten. * Callback Options * - ONCE : The registered callback and data are stored in the buffer requested for swap when calling eglSwapBuffers and then initialized. The callback function is called only once when the buffer requested for swap is committed, and is not called after that. - CONTINUOUS : Once the callback and data are registered, the callback function is called continuously until it is released. To release the callback, simply pass NULL to func. Change-Id: Ic08c6dd1aeafe88d4059760f6bbffbd9d0da8c05 Signed-off-by: Joonbum Ko --- diff --git a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h index 1d7f834..b0ef23e 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h @@ -30,6 +30,7 @@ struct tizen_private { int (*create_commit_sync_fd)(struct wl_egl_window *, void *); int (*create_presentation_sync_fd)(struct wl_egl_window *, void *); int (*merge_sync_fds)(void *, int, int); + void (*set_pre_commit_callback)(struct wl_egl_window *, pre_commit_cb_func_t , void *, callback_option); }; #ifdef __cplusplus diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.c b/src/wayland-egl-tizen/wayland-egl-tizen.c index 737a324..1d6502a 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.c +++ b/src/wayland-egl-tizen/wayland-egl-tizen.c @@ -218,4 +218,15 @@ wl_egl_window_tizen_merge_sync_fds(struct wl_egl_window *egl_window, return private->merge_sync_fds(egl_window->driver_private, sync_fd1, sync_fd2); return -1; -} \ No newline at end of file +} + +void +wl_egl_window_tizen_set_pre_commit_callback(struct wl_egl_window *egl_window, + pre_commit_cb_func_t func, void *data, + callback_option option) +{ + struct tizen_private *private = _wl_egl_tizen_get_tizen_private(egl_window); + + if (private && private->set_pre_commit_callback) + private->set_pre_commit_callback(egl_window->driver_private, func, data, option); +} diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.h b/src/wayland-egl-tizen/wayland-egl-tizen.h index 2cb0d25..cdab123 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen.h @@ -47,6 +47,13 @@ typedef enum { WL_EGL_WINDOW_TIZEN_ROTATION_270 = 270 } wl_egl_window_tizen_rotation; +typedef void (*pre_commit_cb_func_t)(void *data); + +typedef enum { + ONCE, + CONTINUOUS, +} callback_option; + void wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, int rotation); @@ -166,6 +173,44 @@ int wl_egl_window_tizen_merge_sync_fds(struct wl_egl_window *egl_window, int sync_fd1, int sync_fd2); +/** + * Set pre-commit callback with data to wl_egl_window. + * + * The registered callback function will be called with the data + * immedately before the frame's wl_surface_commit. + * The callback registered before calling eglSwapBuffers will be called + * at the time the swap requested buffer is attached. + * + * Important * + * - Since the callback may be called from a separate thread that performs + * wl_surface_commit, protection is required if there is a critical section + * inside the callback function. + * - To avoid poor performance or complicated lifecycle issues, + * it is recommended that the behavior inside the callback function be concise. + * - This API should be called from one thread. + * - If it is called multiple times in a frame, the previously registered ones + * are overwritten. + * + * Callback Options * + * - ONCE : The registered callback and data are stored in the buffer requested + * for swap when calling eglSwapBuffers and then initialized. + * The callback function is called only once when the buffer requested + * for swap is committed, and is not called after that. + * - CONTINUOUS : Once the callback and data are registered, the callback function + * is called continuously until it is released. + * To release the callback, simply pass NULL to func. + * + * @param egl_window handle to wl_egl_window to which the callback is to be registered. + * @param option callback_option to determine the lifecycle of func. + * @param func callback function that will be called just before wl_surface_commit. + * @param data data to be passed to the callback function. +*/ +void +wl_egl_window_tizen_set_pre_commit_callback(struct wl_egl_window *egl_window, + pre_commit_cb_func_t func, + void *data, + callback_option option); + #ifdef __cplusplus } #endif