}
}
+static void
+_twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source,
+ tbm_surface_h tbm_surface)
+{
+ twe_wl_buffer_info *buf_info = NULL;
+ struct wl_surface *wl_surface = surf_source->surf;
+ struct wl_egl_window *wl_egl_window = surf_source->wl_egl_window;
+
+ tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO,
+ (void **)&buf_info);
+ if (!buf_info) {
+ TPL_ERR("Failed to get twe_wl_buffer_info from tbm_surface(%p)",
+ tbm_surface);
+ return;
+ }
+
+ wl_egl_window->attached_width = buf_info->width;
+ wl_egl_window->attached_height = buf_info->height;
+
+ wl_surface_attach(wl_surface, (struct wl_buffer *)buf_info->wl_buffer,
+ buf_info->dx, buf_info->dy);
+
+ if (buf_info->num_rects < 1 || buf_info->rects == NULL) {
+ wl_surface_damage_buffer(wl_surface,
+ buf_info->dx, buf_info->dy,
+ buf_info->width, buf_info->height);
+ } else {
+ int i;
+ for (i = 0; i < buf_info->num_rects; i++) {
+ int inverted_y =
+ buf_info->height - (buf_info->rects[i * 4 + 1] +
+ buf_info->rects[i * 4 + 3]);
+ wl_surface_damage_buffer(wl_surface,
+ buf_info->rects[i * 4 + 0],
+ inverted_y,
+ buf_info->rects[i * 4 + 2],
+ buf_info->rects[i * 4 + 3]);
+ }
+ }
+
+ wl_surface_commit(wl_surface);
+
+ TPL_LOG_T("WL_EGL", "[COMMIT] wl_buffer(%p) tbm_surface(%p) bo(%d)",
+ buf_info->wl_buffer, tbm_surface,
+ tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
+}
+
+static void
+_twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source)
+{
+ tbm_surface_h tbm_surface = NULL;
+ tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_NONE;
+
+ if (!tbm_surface_queue_can_acquire(surf_source->tbm_queue, 0)) {
+ TPL_ERR("Received acquirable event, but nothing to commit.");
+ return;
+ }
+
+ tsq_err = tbm_surface_queue_acquire(surf_source->tbm_queue, &tbm_surface);
+ if (!tbm_surface || tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) {
+ TPL_ERR("Failed to acquire from tbm_queue(%p)",
+ surf_source->tbm_queue);
+ return;
+ }
+
+ tbm_surface_internal_ref(tbm_surface);
+
+ TPL_LOG_T("WL_EGL", "[ACQ] tbm_surface(%p) bo(%d)",
+ tbm_surface,
+ tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
+
+ _twe_thread_wl_surface_commit(surf_source, tbm_surface);
+}
+
static gboolean
_twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer date)
{
if (s != sizeof(uint64_t))
TPL_ERR("Failed to read from event_fd(%d)",
wl_surf_source->event_fd);
+
+ _twe_thread_wl_surface_acquire_and_commit(wl_surf_source);
}
return G_SOURCE_CONTINUE;
twe_wl_buffer_info *buf_info = NULL;
tbm_surface_h tbm_surface = (tbm_surface_h)data;
- TPL_LOG_T("WL_EGL", "[RELEASE_CB] wl_buffer(%p) tbm_surface(%p)",
- wl_buffer, tbm_surface);
-
if (tbm_surface_internal_is_valid(tbm_surface)) {
tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO,
(void **)&buf_info);
if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE)
TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err);
+ TPL_LOG_T("WL_EGL", "[REL] wl_buffer(%p) tbm_surface(%p) bo(%d)",
+ buf_info->wl_buffer, tbm_surface,
+ tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
tbm_surface_internal_unref(tbm_surface);
}