From f4e6e86e1e927c3c69a25f31a48b1c1f1dc33513 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Thu, 27 Apr 2017 16:25:14 +0900 Subject: [PATCH] tpl_wayland_egl_thread: Added twe_surface_set_damage_region. - NEW API : twe_surface_set_damage_region(tbm_surface_h, int num_rects, const int* rects) - I expect it to be called before tbm_surface_queue_enqueue() inside tpl_surface_enqueue_buffer(). - The input parameter tbm_surface_h must be a dequeued buffer from tbm_surface_queue. - Operation : * Get twe_wl_buffer_info from tbm_surface user_data. * If buf_info->rects already exists, free this old one and re allocate new rects. Change-Id: Ib9e552dab4450caad3aa9c1e941f9190abe79252 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl_thread.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ src/tpl_wayland_egl_thread.h | 4 +++ 2 files changed, 69 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index eee1b5c..c1bc32a 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -83,6 +83,9 @@ struct _twe_wl_buffer_info { int dx, dy; int width, height; int rotation; + /* for damage region */ + int num_rects; + int *rects; twe_wl_surf_source *surf_source; }; @@ -795,6 +798,11 @@ twe_surface_set_buffer(twe_surface_h twe_surface, tbm_surface_h tbm_surface) buf_info->dx = wl_egl_window->dx; buf_info->dy = wl_egl_window->dy; + if (buf_info->rects) { + free(buf_info->rects); + buf_info->rects = NULL; + buf_info->num_rects = 0; + } return TPL_ERROR_NONE; } else { buf_info = (twe_wl_buffer_info *)calloc(1, sizeof(twe_wl_buffer_info)); @@ -816,6 +824,14 @@ twe_surface_set_buffer(twe_surface_h twe_surface, tbm_surface_h tbm_surface) return TPL_ERROR_INVALID_OPERATION; } + buf_info->rotation = wl_egl_window->rotation; + buf_info->dx = wl_egl_window->dx; + buf_info->dy = wl_egl_window->dy; + buf_info->width = wl_egl_window->width; + buf_info->height = wl_egl_window->height; + buf_info->num_rects = 0; + buf_info->rects = NULL; + wl_buffer_add_listener((void *)buf_info->wl_buffer, &wl_buffer_release_listener, tbm_surface); wl_display_flush(source->disp_source->disp); @@ -834,9 +850,58 @@ twe_surface_set_buffer(twe_surface_h twe_surface, tbm_surface_h tbm_surface) return TPL_ERROR_INVALID_OPERATION; } + TPL_LOG_T("WL_EGL", + "[NEW_BUF] buf_info(%p) tbm_surface(%p) bo(%d) (%dx%d) rot(%d)", + buf_info, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + buf_info->width, buf_info->height, buf_info->rotation); + return TPL_ERROR_NONE; } +tpl_result_t +twe_surface_set_damage_region(tbm_surface_h tbm_surface, + int num_rects, + const int *rects) +{ + twe_wl_buffer_info *buf_info = NULL; + + if (!tbm_surface || !tbm_surface_internal_is_valid(tbm_surface)) { + TPL_ERR("Invalid parameter. tbm_surface(%p)", tbm_surface); + return TPL_ERROR_INVALID_PARAMETER; + } + + if (num_rects == 0 || rects == NULL) { + return TPL_ERROR_NONE; + } + + 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 TPL_ERROR_INVALID_OPERATION; + } + + /* Destroy old region if there are old region info. */ + if (buf_info->rects != NULL) { + free(buf_info->rects); + buf_info->rects = NULL; + buf_info->num_rects = 0; + } + + buf_info->rects = (int *)calloc(1, (sizeof(int) * 4 * num_rects)); + buf_info->num_rects = num_rects; + + if (!buf_info->rects) { + TPL_ERR("Failed to allocate memory fo damage rects info."); + return TPL_ERROR_INVALID_OPERATION; + } + + memcpy((char *)buf_info->rects, (char *)rects, sizeof(int) * 4 * num_rects); + + return TPL_ERROR_NONE; +} #ifdef WORKER_TEST_ONLY static void reg_global(void *data, diff --git a/src/tpl_wayland_egl_thread.h b/src/tpl_wayland_egl_thread.h index 337d80d..1173aa2 100644 --- a/src/tpl_wayland_egl_thread.h +++ b/src/tpl_wayland_egl_thread.h @@ -43,3 +43,7 @@ twe_surface_set_rotation_capablity(twe_surface_h twe_surface, tpl_bool_t set); tpl_result_t twe_surface_set_buffer(twe_surface_h twe_surface, tbm_surface_h tbm_surface); +tpl_result_t +twe_surface_set_damage_region(tbm_surface_h tbm_surface, + int num_rects, const int *rects); + -- 2.7.4