From: Hwankyu Jhun Date: Wed, 5 Feb 2020 10:40:55 +0000 (+0900) Subject: Add a new API to get tbm surface X-Git-Tag: submit/tizen/20200209.233938~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1a3ed6c7ae5f32471cee38a431c4afa47d72e8f;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Add a new API to get tbm surface Adds: - frame_native_buffer_get_tbm_surface() Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/screen-connector/+/223998/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/widget-viewer/+/224004/ Change-Id: I4d8f17f57093e734ee216e44fa92307046318629 Signed-off-by: Hwankyu Jhun --- diff --git a/frame-broker/include/frame.h b/frame-broker/include/frame.h index 00b8c636..c0fe832b 100644 --- a/frame-broker/include/frame.h +++ b/frame-broker/include/frame.h @@ -21,6 +21,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -270,6 +271,21 @@ int frame_native_buffer_get_height(frame_native_buffer_h handle, int frame_native_buffer_get_bpp(frame_native_buffer_h handle, uint32_t *bpp); +/** + * @brief Gets the Tizen buffer surface handle of the native buffer. + * @since_tizen 5.5 + * + * @param[in] handle The native buffer handle + * @param[out] tbm_surface The Tizen buffer surface + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #FRAME_BROKER_ERROR_NONE Successful + * @retval #FRAME_BROKER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int frame_native_buffer_get_tbm_surface(frame_native_buffer_h handle, + tbm_surface_h *tbm_surface); + #ifdef __cplusplus } #endif diff --git a/frame-broker/src/frame.c b/frame-broker/src/frame.c index d965a115..8b14b8e6 100644 --- a/frame-broker/src/frame.c +++ b/frame-broker/src/frame.c @@ -112,6 +112,7 @@ int frame_destroy(frame_h handle) API int frame_get_native_buffer(frame_h handle, frame_native_buffer_h *buffer) { tbm_surface_info_s *surface_info = NULL; + tbm_surface_h tbm_surface = NULL; frame_type_e type; int ret; @@ -133,7 +134,14 @@ API int frame_get_native_buffer(frame_h handle, frame_native_buffer_h *buffer) return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - *buffer = (frame_native_buffer_h)surface_info; + ret = screen_connector_launcher_service_image_get_tbm_surface( + handle->image, &tbm_surface); + if (ret != 0) { + _E("Failed to get tbm surface. error(%d)", ret); + return FRAME_BROKER_ERROR_INVALID_PARAMETER; + } + + *buffer = (frame_native_buffer_h)handle->image; return ret; } @@ -292,14 +300,16 @@ API int frame_get_extra_data(frame_h handle, bundle **extra_data) API int frame_native_buffer_get_raw(frame_native_buffer_h handle, void **raw) { - tbm_surface_info_s *info; + screen_connector_launcher_service_image_h image = handle; + tbm_surface_info_s *info = NULL; if (!handle || !raw) { _E("Invalid parameter"); return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - info = (tbm_surface_info_s *)handle; + screen_connector_launcher_service_image_get_tbm_surface_info(image, + &info); *raw = info->planes[0].ptr; return FRAME_BROKER_ERROR_NONE; @@ -308,14 +318,16 @@ API int frame_native_buffer_get_raw(frame_native_buffer_h handle, API int frame_native_buffer_get_width(frame_native_buffer_h handle, uint32_t *width) { - tbm_surface_info_s *info; + screen_connector_launcher_service_image_h image = handle; + tbm_surface_info_s *info = NULL; if (!handle || !width) { _E("Invalid parameter"); return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - info = (tbm_surface_info_s *)handle; + screen_connector_launcher_service_image_get_tbm_surface_info(image, + &info); *width = info->width; return FRAME_BROKER_ERROR_NONE; @@ -324,14 +336,16 @@ API int frame_native_buffer_get_width(frame_native_buffer_h handle, API int frame_native_buffer_get_height(frame_native_buffer_h handle, uint32_t *height) { - tbm_surface_info_s *info; + screen_connector_launcher_service_image_h image = handle; + tbm_surface_info_s *info = NULL; if (!handle || !height) { _E("Invalid parameter"); return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - info = (tbm_surface_info_s *)handle; + screen_connector_launcher_service_image_get_tbm_surface_info(image, + &info); *height = info->height; return FRAME_BROKER_ERROR_NONE; @@ -340,15 +354,35 @@ API int frame_native_buffer_get_height(frame_native_buffer_h handle, API int frame_native_buffer_get_bpp(frame_native_buffer_h handle, uint32_t *bpp) { - tbm_surface_info_s *info; + screen_connector_launcher_service_image_h image = handle; + tbm_surface_info_s *info = NULL; if (!handle || !bpp) { _E("Invalid parameter"); return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - info = (tbm_surface_info_s *)handle; + screen_connector_launcher_service_image_get_tbm_surface_info(image, + &info); *bpp = info->bpp; return FRAME_BROKER_ERROR_NONE; } + +API int frame_native_buffer_get_tbm_surface(frame_native_buffer_h handle, + tbm_surface_h *tbm_surface) +{ + screen_connector_launcher_service_image_h image = handle; + tbm_surface_h surface = NULL; + + if (!handle || !tbm_surface) { + _E("Invalid parameter"); + return FRAME_BROKER_ERROR_INVALID_PARAMETER; + } + + screen_connector_launcher_service_image_get_tbm_surface(image, + &surface); + *tbm_surface = surface; + + return FRAME_BROKER_ERROR_NONE; +}