From: Changyeon Lee Date: Thu, 10 May 2018 06:48:35 +0000 (+0900) Subject: surface: added tbm_surface_internal_set/get_damage func X-Git-Tag: submit/tizen/20180514.053359~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=757968fc683975d882aadf1b45a54e214bbd4783;p=platform%2Fcore%2Fuifw%2Flibtbm.git surface: added tbm_surface_internal_set/get_damage func Change-Id: I25e77606b987e7761c0ad16ad6d6d5f70a09351d --- diff --git a/include/tbm_surface_internal.h b/include/tbm_surface_internal.h index 0ada9c0..9454a36 100644 --- a/include/tbm_surface_internal.h +++ b/include/tbm_surface_internal.h @@ -522,6 +522,28 @@ int tbm_surface_internal_capture_buffer(tbm_surface_h surface, const char *path, int tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride, const char *path, const char *name, const char *type); +/** + * @brief Set damage to surface + * @param[in] surface : a tbm surface + * @param[in] x : a x coordinate of damage + * @param[in] y : a y coordinate of damage + * @param[in] with : a width of damage rectangle + * @param[in] height : a height of damage rectangle + * @return 1 if success, otherwise 0. + */ +int tbm_surface_internal_set_damage(tbm_surface_h surface, int x, int y, int width, int height); + +/** + * @brief Get damage of surface + * @param[in] surface : a tbm surface + * @param[out] x : a x coordinate of damage + * @param[out] y : a y coordinate of damage + * @param[out] with : a width of damage rectangle + * @param[out] height : a height of damage rectangle + * @return 1 if success, otherwise 0. + */ +int tbm_surface_internal_get_damage(tbm_surface_h surface, int *x, int *y, int *width, int *height); + #ifdef __cplusplus } #endif diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index a75c696..f4cc290 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -234,6 +234,13 @@ struct _tbm_surface { struct list_head user_data_list; /* list of the user_date in surface */ struct list_head debug_data_list; /* list of debug data */ + + struct { + int x; + int y; + int width; + int height; + } damage; }; typedef struct { diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index c32b881..6fc9b55 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -2563,4 +2563,58 @@ tbm_surface_internal_capture_shm_buffer(void *ptr, int w, int h, int stride, return 1; } + +int +tbm_surface_internal_set_damage(tbm_surface_h surface, int x, int y, int width, int height) +{ + struct _tbm_surface *surf; + + _tbm_surface_mutex_lock(); + _tbm_set_last_result(TBM_ERROR_NONE); + + TBM_SURFACE_RETURN_VAL_IF_FAIL(width > 0, 0); + TBM_SURFACE_RETURN_VAL_IF_FAIL(height > 0, 0); + TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0); + + surf = (struct _tbm_surface *)surface; + + surf->damage.x = x; + surf->damage.y = y; + surf->damage.width = width; + surf->damage.height = height; + + TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) x(%d) y(%d) width(%d) height(%d)\n", + surface, x, y, width, height); + + _tbm_surface_mutex_unlock(); + + return 1; +} + +int +tbm_surface_internal_get_damage(tbm_surface_h surface, int *x, int *y, int *width, int *height) +{ + struct _tbm_surface *surf; + + _tbm_surface_mutex_lock(); + _tbm_set_last_result(TBM_ERROR_NONE); + + TBM_SURFACE_RETURN_VAL_IF_FAIL(width > 0, 0); + TBM_SURFACE_RETURN_VAL_IF_FAIL(height > 0, 0); + TBM_SURFACE_RETURN_VAL_IF_FAIL(_tbm_surface_internal_is_valid(surface), 0); + + surf = (struct _tbm_surface *)surface; + + *x = surf->damage.x; + *y = surf->damage.y; + *width = surf->damage.width; + *height = surf->damage.height; + + TBM_TRACE_SURFACE_INTERNAL("tbm_surface(%p) x(%d) y(%d) width(%d) height(%d)\n", + surface, *x, *y, *width, *height); + + _tbm_surface_mutex_unlock(); + + return 1; +} /*LCOV_EXCL_STOP*/