tpl_surface: set post_interval in tdm_client_vblank_wait 58/217258/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 6 Aug 2019 10:53:07 +0000 (19:53 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 8 Nov 2019 04:30:10 +0000 (13:30 +0900)
Change-Id: Ib936a993439f0bb3ab4c2d5049204305da013142

src/tpl_internal.h [changed mode: 0644->0755]
src/tpl_surface.c [changed mode: 0644->0755]
src/tpl_wayland_egl.c [changed mode: 0644->0755]
src/tpl_wayland_egl_thread.c [changed mode: 0644->0755]
src/tpl_wayland_egl_thread.h [changed mode: 0644->0755]
src/tpl_wl_egl_thread.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 6dff22f..ba161c9
@@ -110,6 +110,7 @@ struct _tpl_surface_backend {
        tpl_result_t (*destroy_swapchain)(tpl_surface_t *surface);
        tpl_result_t (*set_rotation_capability)(tpl_surface_t *surface,
                                                                                        tpl_bool_t set);
+       tpl_result_t (*set_post_interval)(tpl_surface_t *surface, int post_interval);
 };
 
 struct _tpl_object {
old mode 100644 (file)
new mode 100755 (executable)
index 8c14e82..994aec3
@@ -243,16 +243,29 @@ tpl_surface_validate(tpl_surface_t *surface)
 tpl_result_t
 tpl_surface_set_post_interval(tpl_surface_t *surface, int interval)
 {
+       tpl_result_t ret = TPL_ERROR_NONE;
+
        if (!surface || (surface->type != TPL_SURFACE_TYPE_WINDOW)) {
                TPL_ERR("Invalid surface!");
                return TPL_ERROR_INVALID_PARAMETER;
        }
 
+       if (interval <= 0)
+               return TPL_ERROR_NONE;
+
        TPL_OBJECT_LOCK(surface);
-       surface->post_interval = interval;
+
+       if (surface->backend.set_post_interval)
+               ret = surface->backend.set_post_interval(surface, interval);
+
+       if (ret == TPL_ERROR_NONE)
+               surface->post_interval = interval;
+
        TPL_OBJECT_UNLOCK(surface);
 
-       return TPL_ERROR_NONE;
+       TPL_LOG_F("tpl_surface_t(%p) post_interval(%d)", surface, surface->post_interval);
+
+       return ret;
 }
 
 int
@@ -269,6 +282,8 @@ tpl_surface_get_post_interval(tpl_surface_t *surface)
        interval = surface->post_interval;
        TPL_OBJECT_UNLOCK(surface);
 
+       TPL_LOG_F("tpl_surface_t(%p) post_interval(%d)", surface, interval);
+
        return interval;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 71f90c7..69b34de
@@ -962,7 +962,7 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface,
        if (wayland_egl_display->tdm_client) {
                int tdm_lock_res = pthread_mutex_lock(&wayland_egl_display->tdm_mutex);
                tdm_err = tdm_client_vblank_wait(wayland_egl_surface->tdm_vblank,
-                                                                                1, /* interval */
+                                                                                surface->post_interval, /* interval */
                                                                                 __cb_tdm_client_wait_vblank, /* handler */
                                                                                 surface->backend.data); /* user_data */
 
old mode 100644 (file)
new mode 100755 (executable)
index 99b36b2..13a6a14
@@ -134,6 +134,8 @@ struct _twe_wl_surf_source {
        GMutex sub_thread_mutex;
        GCond sub_thread_cond;
        int draw_done_count;
+
+       int post_interval;
 };
 
 struct _twe_wl_buffer_info {
@@ -1739,7 +1741,7 @@ _twe_surface_wait_vblank(twe_wl_surf_source *surf_source)
        }
 
        tdm_err = tdm_client_vblank_wait(surf_source->vblank,
-                       1, /* TODO: interval */
+                       surf_source->post_interval, /* TODO: interval */
                        __cb_tdm_client_wait_vblank,
                        (void *)surf_source);
 
@@ -2498,6 +2500,8 @@ twe_surface_add(twe_thread* thread,
        source->set_serial_is_used = TPL_FALSE;
        source->serial = 0;
 
+       source->post_interval = 1;
+
        if (!disp_source->is_vulkan_dpy) {
                struct wl_egl_window *wl_egl_window =
                        (struct wl_egl_window *)native_handle;
@@ -3371,3 +3375,20 @@ twe_get_native_buffer_from_pixmap(tpl_handle_t pixmap)
        return tbm_surface;
 }
 
+tpl_result_t
+twe_surface_set_post_interval(twe_surface_h twe_surface, int post_interval)
+{
+       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
+
+       if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+               TPL_ERR("Invalid parameter. surf_source(%p)", surf_source);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       surf_source->post_interval = post_interval;
+
+       TPL_LOG_T(BACKEND, "surf_source(%p) post_interval(%d)",
+                         surf_source, surf_source->post_interval);
+
+       return TPL_ERROR_NONE;
+}
old mode 100644 (file)
new mode 100755 (executable)
index 6cb9116..067def1
@@ -110,3 +110,5 @@ twe_get_native_window_info(tpl_handle_t window, int *width, int *height, tbm_for
 tbm_surface_h
 twe_get_native_buffer_from_pixmap(tpl_handle_t pixmap);
 
+tpl_result_t
+twe_surface_set_post_interval(twe_surface_h twe_surface, int post_interval);
old mode 100644 (file)
new mode 100755 (executable)
index 4ebe168..980c599
@@ -476,6 +476,36 @@ __tpl_wl_egl_surface_set_rotation_capability(tpl_surface_t *surface,
        return TPL_ERROR_NONE;
 }
 
+static tpl_result_t
+__tpl_wl_egl_surface_set_post_interval(tpl_surface_t *surface,
+               int post_interval)
+{
+       tpl_wayland_egl_surface_t *wayland_egl_surface = NULL;
+
+       if (!surface) {
+               TPL_ERR("Invalid parameter. tpl_surface(%p)", surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       wayland_egl_surface = (tpl_wayland_egl_surface_t *)surface->backend.data;
+       if (!wayland_egl_surface) {
+               TPL_ERR("Invalid parameter. wayland_egl_surface(%p)",
+                               wayland_egl_surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!wayland_egl_surface->twe_surface) {
+               TPL_ERR("Invalid parameter. wayland_egl_surface(%p) twe_surface(%p)",
+                               wayland_egl_surface, wayland_egl_surface->twe_surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       twe_surface_set_post_interval(wayland_egl_surface->twe_surface,
+                                                                 post_interval);
+
+       return TPL_ERROR_NONE;
+}
+
 static tpl_result_t
 __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface,
                tbm_surface_h tbm_surface,
@@ -805,5 +835,7 @@ __tpl_surface_init_backend_wl_egl_thread(tpl_surface_backend_t *backend)
        backend->enqueue_buffer = __tpl_wl_egl_surface_enqueue_buffer;
        backend->set_rotation_capability =
                __tpl_wl_egl_surface_set_rotation_capability;
+       backend->set_post_interval =
+               __tpl_wl_egl_surface_set_post_interval;
 }