Add a new API to get tbm surface 04/224004/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 5 Feb 2020 10:40:55 +0000 (19:40 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 5 Feb 2020 23:52:16 +0000 (08:52 +0900)
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 <h.jhun@samsung.com>
frame-broker/include/frame.h
frame-broker/src/frame.c

index 00b8c63..c0fe832 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <bundle.h>
 #include <frame_types.h>
+#include <tbm_surface.h>
 
 #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
index d965a11..8b14b8e 100644 (file)
@@ -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;
+}