return TPL_ERROR_INVALID_PARAMETER;
}
- if (interval <= 0)
+ if (interval < 0)
return TPL_ERROR_NONE;
TPL_OBJECT_LOCK(surface);
- if (surface->backend.set_post_interval)
- ret = surface->backend.set_post_interval(surface, interval);
+ if (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;
+ if (ret == TPL_ERROR_NONE)
+ surface->post_interval = interval;
+ }
TPL_OBJECT_UNLOCK(surface);
}
/* TPL_WAIT_VBLANK = 1 */
- if (wayland_egl_display->tdm_client) {
+ if (wayland_egl_display->tdm_client && surface->post_interval > 0) {
int tdm_lock_res = pthread_mutex_lock(&wayland_egl_display->tdm_mutex);
tdm_err = tdm_client_vblank_wait(wayland_egl_surface->tdm_vblank,
surface->post_interval, /* interval */
tbm_bo_export(wayland_egl_buffer->bo));
TRACE_BEGIN("[WAIT_VBLANK]");
- if (wayland_egl_surface->vblank_done == TPL_FALSE)
+ if (wayland_egl_surface->vblank_done == TPL_FALSE && surface->post_interval > 0)
__tpl_wayland_egl_surface_wait_vblank(surface);
TRACE_END();
tpl_bool_t need_to_enqueue;
tpl_bool_t prerotation_capability;
tpl_bool_t vblank_done;
+ tpl_bool_t vblank_enable;
tpl_bool_t set_serial_is_used;
tpl_bool_t initialized_in_thread;
tpl_bool_t frontbuffer_activated;
wl_egl_surface->post_interval = surface->post_interval;
+ wl_egl_surface->vblank_enable = TPL_FALSE;
+
wl_egl_surface->commit_sync.fd = -1;
wl_egl_surface->presentation_sync.fd = -1;
vblank = NULL;
} else {
vblank->waiting_buffers = __tpl_list_alloc();
- vblank->wl_egl_surface = wl_egl_surface;
- tpl_gmutex_init(&vblank->mutex);
-
- __tpl_list_push_back(wl_egl_display->tdm.surface_vblanks,
- (void *)vblank);
-
- TPL_INFO("[VBLANK_INIT]",
- "wl_egl_surface(%p) tdm_client(%p) tdm_vblank(%p)",
- wl_egl_surface, wl_egl_display->tdm.tdm_client,
- vblank->tdm_vblank);
+ if (!vblank->waiting_buffers) {
+ tdm_client_vblank_destroy(vblank->tdm_vblank);
+ free(vblank);
+ vblank = NULL;
+ } else{
+ vblank->wl_egl_surface = wl_egl_surface;
+ tpl_gmutex_init(&vblank->mutex);
+
+ __tpl_list_push_back(wl_egl_display->tdm.surface_vblanks,
+ (void *)vblank);
+
+ TPL_INFO("[VBLANK_INIT]",
+ "wl_egl_surface(%p) tdm_client(%p) tdm_vblank(%p)",
+ wl_egl_surface, wl_egl_display->tdm.tdm_client,
+ vblank->tdm_vblank);
+ }
}
}
}
wl_egl_surface->vblank = vblank;
+ wl_egl_surface->vblank_enable = (vblank != NULL &&
+ wl_egl_surface->post_interval > 0);
+
#if TIZEN_FEATURE_ENABLE
if (wl_egl_display->tss) {
wl_egl_surface->tss_flusher =
"wl_egl_surface(%p) post_interval(%d -> %d)",
wl_egl_surface, wl_egl_surface->post_interval, post_interval);
+ tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
wl_egl_surface->post_interval = post_interval;
+ tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
return TPL_ERROR_NONE;
}
tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
- if (wl_egl_surface->vblank == NULL || wl_egl_surface->vblank_done)
+ if (!wl_egl_surface->vblank_enable || wl_egl_surface->vblank_done)
_thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer);
else {
tpl_gmutex_lock(&wl_egl_surface->vblank->mutex);
}
if (ready_to_commit) {
- if (wl_egl_surface->vblank == NULL || wl_egl_surface->vblank_done)
+ if (!wl_egl_surface->vblank_enable || wl_egl_surface->vblank_done)
ready_to_commit = TPL_TRUE;
else {
wl_egl_buffer->status = WAITING_VBLANK;
TPL_WARN("[TDM_ERROR_TIMEOUT] It will keep going. wl_egl_surface(%p)",
wl_egl_surface);
+ tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
wl_egl_surface->vblank_done = TPL_TRUE;
- tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) {
tpl_bool_t is_empty = TPL_TRUE;
do {
* flush all vblank waiting buffers of its wl_egl_surface.
* Otherwise, only one wl_egl_buffer will be commited per one vblank event.
*/
- if (error == TDM_ERROR_NONE) break;
+ if (error == TDM_ERROR_NONE && wl_egl_surface->post_interval > 0)
+ break;
} while (!is_empty);
+
+ wl_egl_surface->vblank_enable = (wl_egl_surface->post_interval > 0);
}
tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
}
wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface,
wl_egl_buffer->bo_name);
- if (wl_egl_surface->vblank != NULL &&
- _thread_surface_vblank_wait(wl_egl_surface) != TPL_ERROR_NONE)
- TPL_ERR("Failed to set wait vblank.");
+ if (wl_egl_surface->post_interval > 0 && wl_egl_surface->vblank != NULL) {
+ wl_egl_surface->vblank_enable = TPL_TRUE;
+ if (_thread_surface_vblank_wait(wl_egl_surface) != TPL_ERROR_NONE)
+ TPL_ERR("Failed to set wait vblank.");
+ }
tpl_gmutex_lock(&wl_egl_surface->commit_sync.mutex);
tpl_bool_t is_activated;
tpl_bool_t reset; /* TRUE if queue reseted by external */
tpl_bool_t vblank_done;
+ tpl_bool_t vblank_enable;
tpl_bool_t initialized_in_thread;
/* To make sure that tpl_gsource has been successfully finalized. */
/* tbm_surface_queue will be created at swapchain_create */
- wl_vk_surface->vblank = _thread_create_tdm_client_vblank(
- wl_vk_display->tdm.tdm_client);
- if (wl_vk_surface->vblank) {
- TPL_INFO("[VBLANK_INIT]",
- "wl_vk_surface(%p) tdm_client(%p) vblank(%p)",
- wl_vk_surface, wl_vk_display->tdm.tdm_client,
- wl_vk_surface->vblank);
+ if (wl_vk_display->use_wait_vblank) {
+ wl_vk_surface->vblank = _thread_create_tdm_client_vblank(
+ wl_vk_display->tdm.tdm_client);
+ if (wl_vk_surface->vblank) {
+ TPL_INFO("[VBLANK_INIT]",
+ "wl_vk_surface(%p) tdm_client(%p) vblank(%p)",
+ wl_vk_surface, wl_vk_display->tdm.tdm_client,
+ wl_vk_surface->vblank);
+
+ wl_vk_surface->vblank_waiting_buffers = __tpl_list_alloc();
+ if (!wl_vk_surface->vblank_waiting_buffers) {
+ tdm_client_vblank_destroy(wl_vk_surface->vblank);
+ wl_vk_surface->vblank = NULL;
+ }
+ }
}
#if TIZEN_FEATURE_ENABLE
}
}
#endif
- wl_vk_surface->vblank_waiting_buffers = __tpl_list_alloc();
+
+ wl_vk_surface->vblank_enable = (wl_vk_surface->vblank != NULL &&
+ wl_vk_surface->post_interval > 0);
}
static void
wl_vk_surface->render_done_cnt = 0;
wl_vk_surface->vblank = NULL;
+ wl_vk_surface->vblank_enable = TPL_FALSE;
#if TIZEN_FEATURE_ENABLE
wl_vk_surface->surface_sync = NULL;
#endif
"wl_vk_surface(%p) post_interval(%d -> %d)",
wl_vk_surface, wl_vk_surface->post_interval, post_interval);
+ tpl_gmutex_lock(&wl_vk_surface->surf_mutex);
wl_vk_surface->post_interval = post_interval;
+ tpl_gmutex_unlock(&wl_vk_surface->surf_mutex);
return TPL_ERROR_NONE;
}
}
}
- if (!wl_vk_display->use_wait_vblank || wl_vk_surface->vblank_done)
+ if (!wl_vk_surface->vblank_enable || wl_vk_surface->vblank_done)
ready_to_commit = TPL_TRUE;
else {
wl_vk_buffer->status = WAITING_VBLANK;
TPL_WARN("[TDM_ERROR_TIMEOUT] It will keep going. wl_vk_surface(%p)",
wl_vk_surface);
+ tpl_gmutex_lock(&wl_vk_surface->surf_mutex);
wl_vk_surface->vblank_done = TPL_TRUE;
- tpl_gmutex_lock(&wl_vk_surface->surf_mutex);
- wl_vk_buffer = (tpl_wl_vk_buffer_t *)__tpl_list_pop_front(
- wl_vk_surface->vblank_waiting_buffers,
- NULL);
- if (wl_vk_buffer)
- _thread_wl_surface_commit(wl_vk_surface, wl_vk_buffer);
+ if (wl_vk_surface->vblank && wl_vk_surface->vblank_waiting_buffers) {
+ tpl_bool_t is_empty = TPL_TRUE;
+ do {
+ tpl_wl_vk_buffer_t* wl_vk_buffer =(tpl_wl_vk_buffer_t *)
+ __tpl_list_pop_front(wl_vk_surface->vblank_waiting_buffers, NULL);
+ is_empty = __tpl_list_is_empty(wl_vk_surface->vblank_waiting_buffers);
+
+ if (!wl_vk_buffer) break;
+
+ _thread_wl_surface_commit(wl_vk_surface, wl_vk_buffer);
+
+ /* If tdm error such as TIMEOUT occured,
+ * flush all vblank waiting buffers of its wl_vk_surface.
+ * Otherwise, only one wl_vk_buffer will be commited per one vblank event.
+ */
+ if (error == TDM_ERROR_NONE && wl_vk_surface->post_interval > 0)
+ break;
+ } while (!is_empty);
+
+ wl_vk_surface->vblank_enable = (wl_vk_surface->post_interval > 0);
+ }
tpl_gmutex_unlock(&wl_vk_surface->surf_mutex);
}
TPL_WARN("Failed to create vblank. wl_vk_surface(%p)",
wl_vk_surface);
return TPL_ERROR_OUT_OF_MEMORY;
+ } else {
+ wl_vk_surface->vblank_waiting_buffers = __tpl_list_alloc();
+ if (!wl_vk_surface->vblank_waiting_buffers) {
+ tdm_client_vblank_destroy(wl_vk_surface->vblank);
+ wl_vk_surface->vblank = NULL;
+ }
}
}
wl_vk_buffer, wl_vk_buffer->wl_buffer, wl_vk_buffer->tbm_surface,
wl_vk_buffer->bo_name);
- if (wl_vk_display->use_wait_vblank &&
- _thread_surface_vblank_wait(wl_vk_surface) != TPL_ERROR_NONE)
- TPL_ERR("Failed to set wait vblank.");
+ if (wl_vk_surface->post_interval > 0 && wl_vk_surface->vblank != NULL) {
+ wl_vk_surface->vblank_enable = TPL_TRUE;
+ if (_thread_surface_vblank_wait(wl_vk_surface) != TPL_ERROR_NONE)
+ TPL_ERR("Failed to set wait vblank.");
+ }
}
tpl_bool_t