tpl_surface: Added a new frontend API to set the number of desired buffers. 48/183248/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Wed, 4 Jul 2018 00:16:56 +0000 (09:16 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Wed, 4 Jul 2018 02:36:25 +0000 (02:36 +0000)
 - New API below.

tpl_surface_t *
 tpl_surface_create_with_num_buffers(tpl_display_t *display,
                                     tpl_handle_t handle,
     tpl_surface_type_t type,
                                     tbm_format format,
     int num_buffers);

 Create a TPL surface for the given native surface(handle) with the number of desired buffers.
 This API is the same as tpl_surface_create() except that it can specify the number of buffers.

Change-Id: I1b0808da436906cd0a14568cd796f184b4343746
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl.h
src/tpl_internal.h
src/tpl_surface.c
src/tpl_wayland_egl.c
src/tpl_wayland_egl_thread.c
src/tpl_wayland_egl_thread.h
src/tpl_wl_egl_thread.c
src/tpl_wl_vk_thread.c

index 27a3ba9..3c6b70b 100644 (file)
--- a/src/tpl.h
+++ b/src/tpl.h
@@ -391,10 +391,31 @@ tpl_display_get_backend_type(tpl_handle_t native_dpy);
  * @param format Pixel format of the surface.
  * @return Created surface on success, NULL otherwise.
  */
+
 tpl_surface_t *
 tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
                                   tpl_surface_type_t type, tbm_format format);
 
+
+/**
+ * Create a TPL surface for the given native surface(handle)
+ * with the number of desired buffers.
+ * This API is the same as tpl_surface_create() except that
+ * it can specify the number of buffers.
+ *
+ * @param display display used for surface creation.
+ * @param handle Handle to the native surface.
+ * @param type Type of the surface (Window or Pixmap).
+ * @param format Pixel format of the surface.
+ * @param num_buffers The numbuer of desired buffers.
+ * @return Created surface on success, NULL otherwise.
+ * */
+tpl_surface_t *
+tpl_surface_create_with_num_buffers(tpl_display_t *display, tpl_handle_t handle,
+                                                                       tpl_surface_type_t type, tbm_format format,
+                                                                       int num_buffers);
+
+
 /**
  * Get TPL surface object for the given native surface.
  *
index d8f037d..4d1d45d 100644 (file)
@@ -48,6 +48,9 @@
 #define TPL_OBJECT_TYPE_CHECK(x, tp)                           do {if ((TPL_OBJECT(x)->type) != (tpl_object_type_t)(tp)) { TPL_ERR("Object type check failed"); return;} } while (0)
 #define TPL_OBJECT_TYPE_CHECK_RETURN(x, tp, ret)       do {if ((TPL_OBJECT(x)->type) != (tpl_object_type_t)(tp)) { TPL_ERR("Object type check failed"); return ret;} } while (0)
 
+#define TPL_SURFACE_MIN_BUFFER_COUNT   2
+#define TPL_SURFACE_DEFAULT_BUFFER_COUNT       3
+
 typedef struct _tpl_runtime    tpl_runtime_t;
 typedef struct _tpl_display_backend    tpl_display_backend_t;
 typedef struct _tpl_surface_backend    tpl_surface_backend_t;
@@ -139,6 +142,7 @@ struct _tpl_surface {
        int rotation;
        int post_interval;
        int dump_count;
+       int num_buffers;
        tpl_bool_t rotation_capability;
        tpl_surface_backend_t backend;
 
index 437ec02..9c281ac 100644 (file)
@@ -19,12 +19,12 @@ __tpl_surface_free(void *data)
        free(data);
 }
 
-tpl_surface_t *
-tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
-                                  tpl_surface_type_t type, tbm_format format)
+static tpl_surface_t *
+__tpl_surface_internal_create(tpl_display_t *display, tpl_handle_t handle,
+                                                         tpl_surface_type_t type, tbm_format format,
+                                                         int num_buffers)
 {
        tpl_surface_t *surface = NULL;
-       tpl_result_t ret = TPL_ERROR_NONE;
 
        if (!display) {
                TPL_ERR("Display is NULL!");
@@ -36,6 +36,11 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
                return NULL;
        }
 
+       if (num_buffers < TPL_SURFACE_MIN_BUFFER_COUNT) {
+               TPL_ERR("num_buffers(%d) must be >= 2", num_buffers);
+               return NULL;
+       }
+
        surface = (tpl_surface_t *) calloc(1, sizeof(tpl_surface_t));
        if (!surface) {
                TPL_ERR("Failed to allocate memory for surface!");
@@ -57,6 +62,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
        surface->post_interval = 1;
 
        surface->dump_count = 0;
+       surface->num_buffers = num_buffers;
 
        /* Intialize backend. */
        __tpl_surface_init_backend(surface, display->backend.type);
@@ -74,6 +80,7 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
         * for supporting oldSwapchain.
         */
        if (tpl_surface_get(display, handle) == NULL) {
+               tpl_result_t ret = TPL_ERROR_NONE;
                /* Add it to the runtime. */
                ret = __tpl_runtime_add_surface(surface);
                if (ret != TPL_ERROR_NONE) {
@@ -83,8 +90,41 @@ tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
                }
        }
 
-       TPL_LOG_F("tpl_display_t(%p) tpl_surface_t(%p) native_handle(%p) format(%d)",
-                         display, surface, handle, format);
+       return surface;
+}
+
+tpl_surface_t *
+tpl_surface_create(tpl_display_t *display, tpl_handle_t handle,
+                                  tpl_surface_type_t type, tbm_format format)
+{
+       tpl_surface_t *surface = NULL;
+
+       surface = __tpl_surface_internal_create(display, handle,
+                                                                                       type, format,
+                                                                                       TPL_SURFACE_DEFAULT_BUFFER_COUNT);
+       if (surface) {
+               TPL_LOG_F("tpl_display_t(%p) tpl_surface_t(%p) native_handle(%p) format(%d) num_buffers(%d)",
+                                 display, surface, handle, format, TPL_SURFACE_DEFAULT_BUFFER_COUNT);
+       } else
+               TPL_ERR("Failed to create tpl_surface with native window(%p)", handle);
+       return surface;
+}
+
+tpl_surface_t *
+tpl_surface_create_with_num_buffers(tpl_display_t *display, tpl_handle_t handle,
+                                                                       tpl_surface_type_t type, tbm_format format,
+                                                                       int num_buffers)
+{
+       tpl_surface_t *surface = NULL;
+
+       surface = __tpl_surface_internal_create(display, handle,
+                                                                                       type, format,
+                                                                                       num_buffers);
+       if (surface) {
+               TPL_LOG_F("tpl_display_t(%p) tpl_surface_t(%p) native_handle(%p) format(%d)",
+                                 display, surface, handle, format, num_buffers);
+       } else
+               TPL_ERR("Failed to create tpl_surface with native window(%p)", handle);
        return surface;
 }
 
index cf5ddf9..b2e5fbb 100644 (file)
@@ -21,9 +21,6 @@
 #include <tdm_client.h>
 #include <tizen-surface-client-protocol.h>
 
-/* In wayland, application and compositor create its own drawing buffers. Recommend size is more than 2. */
-#define CLIENT_QUEUE_SIZE 3
-
 typedef struct _tpl_wayland_egl_display tpl_wayland_egl_display_t;
 typedef struct _tpl_wayland_egl_surface tpl_wayland_egl_surface_t;
 typedef struct _tpl_wayland_egl_buffer tpl_wayland_egl_buffer_t;
@@ -527,14 +524,14 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
                wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue(
                                                                                         wayland_egl_display->wl_tbm_client,
                                                                                         wl_egl_window->surface,
-                                                                                        CLIENT_QUEUE_SIZE,
+                                                                                        surface->num_buffers,
                                                                                         wl_egl_window->width,
                                                                                         wl_egl_window->height,
                                                                                         surface->format);
        } else
                /*Why wl_surface is NULL ?*/
                wayland_egl_surface->tbm_queue = tbm_surface_queue_sequence_create(
-                                                                                        CLIENT_QUEUE_SIZE,
+                                                                                        surface->num_buffers,
                                                                                         wl_egl_window->width,
                                                                                         wl_egl_window->height,
                                                                                         surface->format,
@@ -1677,14 +1674,9 @@ static void __cb_tizen_surface_shm_flusher_flush_callback(void *data,
                        tbm_surface_queue_error_e tsq_err;
                        tbm_surface_h tbm_surface =
                                __tpl_list_pop_front(wayland_egl_surface->attached_buffers, NULL);
-                       tpl_wayland_egl_buffer_t *wayland_egl_buffer =
-                               __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface);
-                       if (wayland_egl_buffer) {
-                               /* This buffer does not need to processed at release_callback.
-                                * It will be invalid buffer */
-                               wayland_egl_buffer->need_to_release = TPL_FALSE;
-                       }
-
+                       TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE_CB] BO_NAME:%d",
+                                                       tbm_bo_export(tbm_surface_internal_get_bo(
+                                                               tbm_surface, 0)));
                        tbm_surface_internal_unref(tbm_surface);
                        tsq_err = tbm_surface_queue_release(wayland_egl_surface->tbm_queue, tbm_surface);
                        if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE)
index 14814bf..7a091aa 100644 (file)
@@ -2081,7 +2081,7 @@ static tbm_surface_queue_h
 _twe_surface_create_tbm_queue(twe_wl_surf_source *source,
                                                          struct wayland_tbm_client *wl_tbm_client,
                                                          tpl_handle_t native_handle,
-                                                         int format)
+                                                         int format, int num_buffers)
 {
        tbm_surface_queue_h tbm_queue = NULL;
        struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle;
@@ -2095,7 +2095,7 @@ _twe_surface_create_tbm_queue(twe_wl_surf_source *source,
        tbm_queue = wayland_tbm_client_create_surface_queue(
                                        wl_tbm_client,
                                        wl_egl_window->surface,
-                                       CLIENT_QUEUE_SIZE,
+                                       num_buffers,
                                        wl_egl_window->width,
                                        wl_egl_window->height,
                                        format);
@@ -2303,7 +2303,7 @@ twe_surface_h
 twe_surface_add(twe_thread* thread,
                                twe_display_h twe_display,
                                tpl_handle_t native_handle,
-                               int format)
+                               int format, int num_buffers)
 {
        twe_thread_context *ctx = thread->ctx;
        twe_wl_surf_source *source = NULL;
@@ -2336,7 +2336,7 @@ twe_surface_add(twe_thread* thread,
                !(tbm_queue = _twe_surface_create_tbm_queue(source,
                                                                                                        disp_source->wl_tbm_client,
                                                                                                        native_handle,
-                                                                                                       format))) {
+                                                                                                       format, num_buffers))) {
                TPL_ERR("Failed to create tbm_surface_queue.");
                g_source_unref(&source->gsource);
                return NULL;
index bd32f1d..4f7ba97 100644 (file)
@@ -43,7 +43,7 @@ twe_surface_h
 twe_surface_add(twe_thread* thread,
                                twe_display_h twe_display,
                                tpl_handle_t native_handle,
-                               int format);
+                               int format, int num_buffers);
 
 tpl_result_t
 twe_surface_del(twe_surface_h twe_surface);
index e4fa659..e9e463b 100644 (file)
@@ -349,7 +349,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface)
        twe_surface = twe_surface_add(wayland_egl_display->wl_egl_thread,
                                                                  wayland_egl_display->twe_display,
                                                                  surface->native_handle,
-                                                                 surface->format);
+                                                                 surface->format, surface->num_buffers);
        if (!twe_surface) {
                TPL_ERR("Failed to add native_window(%p) to thread(%p)",
                                surface->native_handle, wayland_egl_display->wl_egl_thread);
index 8e68f8d..09716c6 100644 (file)
@@ -276,7 +276,7 @@ __tpl_wl_vk_wsi_surface_init(tpl_surface_t *surface)
        twe_surface = twe_surface_add(wayland_vk_wsi_display->wl_thread,
                                                                  wayland_vk_wsi_display->twe_display,
                                                                  surface->native_handle,
-                                                                 surface->format);
+                                                                 surface->format, surface->num_buffers);
        if (!twe_surface) {
                TPL_ERR("Failed to add native_surface(%p) to thread(%p)",
                                surface->native_handle, wayland_vk_wsi_display->wl_thread);