tpl_wayland_egl_thread: Registered wl_egl_window resize callback. 72/134972/3
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 25 Apr 2017 10:24:07 +0000 (19:24 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 21 Jun 2017 07:04:25 +0000 (16:04 +0900)
Change-Id: I15dbf11f280bab7e37fa699914f522b2fee6ba65
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 98d8acf..ef38f00 100644 (file)
@@ -67,7 +67,7 @@ struct _twe_wl_surf_source {
        int event_fd;
        struct wl_surface *surf;
        struct wl_egl_window *wl_egl_window;
-       tbm_surface_queue_h tbm_surface_queue;
+       tbm_surface_queue_h tbm_queue;
        twe_wl_disp_source *disp_source;
 };
 
@@ -416,6 +416,32 @@ static GSourceFuncs _twe_wl_surface_funcs = {
 };
 
 static void
+__cb_client_window_resize_callback(struct wl_egl_window *wl_egl_window,
+                                                                  void *private)
+{
+       TPL_ASSERT(private);
+       TPL_ASSERT(wl_egl_window);
+
+       twe_wl_surf_source *source = (twe_wl_surf_source *)private;
+       int cur_w, cur_h, req_w, req_h, format;
+
+       format = tbm_surface_queue_get_format(source->tbm_queue);
+       cur_w = tbm_surface_queue_get_width(source->tbm_queue);
+       cur_h = tbm_surface_queue_get_height(source->tbm_queue);
+       req_w = wl_egl_window->width;
+       req_h = wl_egl_window->height;
+
+       TPL_LOG_T("WL_EGL", "[RESIZE_CB] wl_egl_window(%p) (%dx%d) -> (%dx%d)",
+                       wl_egl_window, cur_w, cur_h, req_w, req_h);
+
+       if (tbm_surface_queue_reset(source->tbm_queue, req_w, req_h, format)
+                       != TBM_SURFACE_QUEUE_ERROR_NONE) {
+               TPL_ERR("Failed to reset tbm_surface_queue(%p)", source->tbm_queue);
+               return;
+       }
+}
+
+static void
 __cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h tbm_queue,
                                                                          void *data)
 {
@@ -469,13 +495,13 @@ twe_surface_get_tbm_queue(twe_surface_h twe_surface)
                return NULL;
        }
 
-       if (!source->tbm_surface_queue) {
+       if (!source->tbm_queue) {
                TPL_ERR("Invalid parameters. twe_surface(%p) tbm_surface_queue(%p)",
-                               source, source->tbm_surface_queue);
+                               source, source->tbm_queue);
                return NULL;
        }
 
-       return source->tbm_surface_queue;
+       return source->tbm_queue;
 }
 
 
@@ -527,9 +553,12 @@ twe_surface_add(twe_thread* thread,
                                                                           G_IO_IN);
        source->surf = surface;
        source->wl_egl_window = wl_egl_window;
-       source->tbm_surface_queue = tbm_queue;
+       source->tbm_queue = tbm_queue;
        source->disp_source = (twe_wl_disp_source *)twe_display;
 
+       wl_egl_window->private = (void *)source;
+       wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback;
+
        g_source_set_callback(&source->gsource, NULL, surface, NULL);
        g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop));
        g_source_unref(&source->gsource);
@@ -566,9 +595,9 @@ twe_surface_del(twe_surface_h twe_surface)
        TPL_LOG_T("WL_EGL", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)",
                          surf_source, surf_source->wl_egl_window, surf_source->surf);
 
-       if (surf_source->tbm_surface_queue) {
-               tbm_surface_queue_destroy(surf_source->tbm_surface_queue);
-               surf_source->tbm_surface_queue = NULL;
+       if (surf_source->tbm_queue) {
+               tbm_surface_queue_destroy(surf_source->tbm_queue);
+               surf_source->tbm_queue = NULL;
        }
 
        /* TODO : surf_source will be removed from surfaces list in disp_source */