- 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>
* @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.
*
#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;
int rotation;
int post_interval;
int dump_count;
+ int num_buffers;
tpl_bool_t rotation_capability;
tpl_surface_backend_t backend;
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!");
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!");
surface->post_interval = 1;
surface->dump_count = 0;
+ surface->num_buffers = num_buffers;
/* Intialize backend. */
__tpl_surface_init_backend(surface, display->backend.type);
* 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) {
}
}
- 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;
}
#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;
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,
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)
_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;
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);
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;
!(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;
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);
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);
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);