int rotation;
void *cb_data;
int format;
+ struct {
+ int width, height;
+ int buffer_count;
+ int present_mode;
+ } swapchain_properties;
tpl_surface_cb_func_t rotate_cb;
tpl_bool_t rotation_capability;
tpl_object_t obj; /* for mutex lock */
}
tpl_result_t
+twe_surface_create_swapchain(twe_surface_h twe_surface,
+ int width, int height, int format,
+ int buffer_count, int present_mode)
+{
+ twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
+ twe_wl_disp_source *disp_source = NULL;
+
+ if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+ TPL_ERR("twe_surface(%p) is invalid.", twe_surface);
+ return TPL_ERROR_INVALID_PARAMETER;
+ }
+
+ disp_source = surf_source->disp_source;
+
+ TPL_ASSERT(disp_source);
+
+ if ((buffer_count < disp_source->surface_capabilities.min_buffer)
+ || (buffer_count > disp_source->surface_capabilities.max_buffer)) {
+ TPL_ERR("Invalid buffer_count(%d)! min_buffer(%d) max_buffer(%d)",
+ buffer_count,
+ disp_source->surface_capabilities.min_buffer,
+ disp_source->surface_capabilities.max_buffer);
+ return TPL_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((present_mode & disp_source->surface_capabilities.present_modes) == 0) {
+ /* server not supported current mode check client mode */
+ switch (present_mode) {
+ case TPL_DISPLAY_PRESENT_MODE_FIFO:
+ case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED:
+ case TPL_DISPLAY_PRESENT_MODE_MAILBOX:
+ case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE:
+ break;
+ default:
+ TPL_ERR("Unsupported present mode: %d", present_mode);
+ return TPL_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */
+ present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX;
+
+ surf_source->tbm_queue = tbm_surface_queue_create(buffer_count,
+ width,
+ height,
+ TBM_FORMAT_ARGB8888,
+ 0);
+ if (!surf_source->tbm_queue) {
+ TPL_ERR("TBM surface queue creation failed!");
+ return TPL_ERROR_OUT_OF_MEMORY;
+ }
+
+ surf_source->format = format;
+ surf_source->swapchain_properties.width = width;
+ surf_source->swapchain_properties.height = height;
+ surf_source->swapchain_properties.present_mode = present_mode;
+ surf_source->swapchain_properties.buffer_count = buffer_count;
+
+ TPL_LOG_T("WL_VK", "[SWAPCHAIN_CREATE][1/2] twe_surface(%p) tbm_queue(%p)",
+ twe_surface, surf_source->tbm_queue);
+ TPL_LOG_T("WL_VK",
+ "[SWAPCHAIN_CREATE][2/2] w(%d) h(%d) f(%d) p(%d) b_cnt(%d)",
+ width, height, present_mode, buffer_count);
+
+ return TPL_ERROR_NONE;
+}
+
+tpl_result_t
+twe_surface_destroy_swapchain(twe_surface_h twe_surface)
+{
+ twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
+
+ if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+ TPL_ERR("twe_surface(%p) is invalid.", twe_surface);
+ return TPL_ERROR_INVALID_PARAMETER;
+ }
+
+ TPL_LOG_T("WL_VK", "[SWAPCHAIN_DESTROY] twe_surface(%p) tbm_queue(%p)",
+ twe_surface, surf_source->tbm_queue);
+
+ if (surf_source->tbm_queue) {
+ tbm_surface_queue_destroy(surf_source->tbm_queue);
+ surf_source->tbm_queue = NULL;
+ }
+
+ return TPL_ERROR_NONE;
+}
+
+
+tpl_result_t
twe_surface_set_rotate_callback(twe_surface_h twe_surface,
void *data, tpl_surface_cb_func_t rotate_cb)
{