tpl_wayland_egl_thread: Changed twe_surface_add() to give tpl_handle_t instead of... 65/161965/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 28 Sep 2017 03:13:01 +0000 (12:13 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Tue, 28 Nov 2017 10:29:24 +0000 (19:29 +0900)
 - If twe_display is a vulkan display, the twe_surface creation process is modified to be different.
 - In case of vulkan, tbm_surface_queue should be created at swapchain create and be passed to twe_surface.

Change-Id: I0b40d74c54da0c3faed54700f68fdbbd2046b665
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c
src/tpl_wayland_egl_thread.h

index 688781c..9cb4735 100644 (file)
@@ -1528,8 +1528,10 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source,
                buf_info->rotated = TPL_FALSE;
        }
 
-       wl_egl_window->attached_width = buf_info->width;
-       wl_egl_window->attached_height = buf_info->height;
+       if (wl_egl_window) {
+               wl_egl_window->attached_width = buf_info->width;
+               wl_egl_window->attached_height = buf_info->height;
+       }
 
        wl_surface_attach(wl_surface, (void *)buf_info->wl_buffer,
                                          buf_info->dx, buf_info->dy);
@@ -1769,10 +1771,11 @@ _twe_surface_create_vblank(tdm_client *tdm_client)
 static tbm_surface_queue_h
 _twe_surface_create_tbm_queue(twe_wl_surf_source *source,
                                                          struct wayland_tbm_client *wl_tbm_client,
-                                                         struct wl_egl_window* wl_egl_window,
+                                                         tpl_handle_t native_handle,
                                                          int format)
 {
        tbm_surface_queue_h tbm_queue = NULL;
+       struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle;
 
        if (!wl_tbm_client || !wl_egl_window) {
                TPL_ERR("Invalid parameters. wl_tbm_client(%p) wl_egl_window(%p)",
@@ -1924,10 +1927,6 @@ _twe_thread_wl_surf_source_destroy(void *source)
                surf_source->wl_egl_window->private = NULL;
                surf_source->wl_egl_window = NULL;
                surf_source->surf = NULL;
-       } else {
-               TPL_LOG_T("WL_EGL",
-                                 "twe_surface(%p) native window is already destroyed",
-                                 surf_source);
        }
 
        TPL_OBJECT_UNLOCK(&disp_source->obj);
@@ -1943,7 +1942,7 @@ _twe_thread_wl_surf_source_destroy(void *source)
 twe_surface_h
 twe_surface_add(twe_thread* thread,
                                twe_display_h twe_display,
-                               struct wl_egl_window *wl_egl_window,
+                               tpl_handle_t native_handle,
                                int format)
 {
        twe_thread_context *ctx = thread->ctx;
@@ -1951,7 +1950,6 @@ twe_surface_add(twe_thread* thread,
        twe_wl_disp_source *disp_source = (twe_wl_disp_source *)twe_display;
        GIOChannel *event_channel = NULL;
        gboolean is_destroyed = FALSE;
-       struct wl_surface *surface = wl_egl_window->surface;
        tbm_surface_queue_h tbm_queue = NULL;
 
        if (!twe_display ||
@@ -1976,25 +1974,22 @@ twe_surface_add(twe_thread* thread,
                return NULL;
        }
 
-       if (!(tbm_queue = _twe_surface_create_tbm_queue(source,
+       if (!disp_source->is_vulkan_dpy &&
+               !(tbm_queue = _twe_surface_create_tbm_queue(source,
                                                                                                        disp_source->wl_tbm_client,
-                                                                                                       wl_egl_window,
+                                                                                                       native_handle,
                                                                                                        format))) {
                TPL_ERR("Failed to create tbm_surface_queue.");
                g_source_unref(&source->gsource);
                return NULL;
        }
 
-    /* TODO : surface source will be listed in twe_wl_disp_source */
-
        source->tag = g_source_add_unix_fd(&source->gsource,
                                                                           source->event_fd,
                                                                           G_IO_IN);
-       source->surf = surface;
-       source->wl_egl_window = wl_egl_window;
        source->tbm_queue = tbm_queue;
        source->disp_source = (twe_wl_disp_source *)twe_display;
-       source->latest_transform = wl_egl_window->transform;
+       source->latest_transform = 0;
        source->rotation = 0;
        source->rotation_capability = TPL_FALSE;
        source->vblank = NULL;
@@ -2007,27 +2002,40 @@ twe_surface_add(twe_thread* thread,
        source->format = format;
 
        __tpl_object_init(&source->obj, TPL_OBJECT_SURFACE, NULL);
-       _twe_surface_buffer_flusher_init(source);
 
-       wl_egl_window->private = (void *)source;
-       wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback;
-       wl_egl_window->resize_callback = (void *)__cb_resize_callback;
-       wl_egl_window->rotate_callback = (void *)__cb_rotate_callback;
-       wl_egl_window->get_rotation_capability = (void *)
+       if (!disp_source->is_vulkan_dpy) {
+               struct wl_egl_window *wl_egl_window =
+                       (struct wl_egl_window *)native_handle;
+
+               wl_egl_window->private = (void *)source;
+               wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback;
+               wl_egl_window->resize_callback = (void *)__cb_resize_callback;
+               wl_egl_window->rotate_callback = (void *)__cb_rotate_callback;
+               wl_egl_window->get_rotation_capability = (void *)
                        __cb_get_rotation_capability;
 
+               source->wl_egl_window = wl_egl_window;
+               source->surf = wl_egl_window->surface;
+               source->latest_transform = wl_egl_window->transform;
+
+               _twe_surface_buffer_flusher_init(source);
+       } else {
+               struct wl_surface *wl_surf = (struct wl_surface *)native_handle;
+               source->wl_egl_window = NULL;
+               source->surf = wl_surf;
+       }
+
        source->surf_del_source = _twe_del_source_init(ctx, source);
        if (source->surf_del_source) {
                source->surf_del_source->destroy_target_source_func
                        = _twe_thread_wl_surf_source_destroy;
        }
 
-       g_source_set_callback(&source->gsource, NULL, surface, NULL);
        g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
 
        TPL_LOG_T("WL_EGL",
-                         "gsource(%p) wl_egl_window(%p) wl_surface(%p) event_fd(%d)",
-                         source, wl_egl_window, surface, source->event_fd);
+                         "gsource(%p) native_handle(%p) wl_surface(%p) event_fd(%d)",
+                         source, native_handle, source->surf, source->event_fd);
 
        return (twe_surface_h)source;
 }
index e7b311c..57dd497 100644 (file)
@@ -42,7 +42,7 @@ twe_display_get_present_mode(twe_display_h display,
 twe_surface_h
 twe_surface_add(twe_thread* thread,
                                twe_display_h twe_display,
-                               struct wl_egl_window *wl_egl_window,
+                               tpl_handle_t native_handle,
                                int format);
 
 tpl_result_t