tbm_surface_internal: check the bufmgr capabililiy 96/260996/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 7 Jul 2021 04:53:56 +0000 (13:53 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 8 Jul 2021 06:50:24 +0000 (15:50 +0900)
check the bufmgr capability instead of calling the
tbm_module_support_surface_data

Change-Id: I41621f4315a21c9e8cb6ee6373beadf23d85350f

src/tbm_surface_internal.c

index f540387..c365f77 100644 (file)
@@ -658,7 +658,7 @@ _tbm_surface_internal_alloc(tbm_bufmgr bufmgr, int width, int height, int format
 }
 
 static tbm_error_e
-_tbm_surface_internal_set_data(struct _tbm_surface *surf, int flags, int is_surface_data)
+_tbm_surface_internal_set_data(struct _tbm_surface *surf, int flags, int can_share_surface)
 {
        tbm_error_e error;
        uint32_t size = 0, offset = 0, stride = 0, bo_size = 0;;
@@ -668,7 +668,7 @@ _tbm_surface_internal_set_data(struct _tbm_surface *surf, int flags, int is_surf
        int memory_types;
 
         // set data with surface
-       if (is_surface_data) {
+       if (can_share_surface) {
                // set infomation of planes
                for (i = 0; i < surf->info.num_planes; i++) {
                        error = tbm_surface_data_get_plane_data(surf->surface_data, i, &size, &offset, &stride, &bo_idx);
@@ -768,7 +768,7 @@ _tbm_surface_internal_set_data(struct _tbm_surface *surf, int flags, int is_surf
        return TBM_ERROR_NONE;
 
 failed:
-       if (is_surface_data) {
+       if (can_share_surface) {
                for (j = 0; j < num_bos; j++) {
                        if (bo_data_array[j]) {
                                free(bo_data_array[j]);
@@ -790,7 +790,7 @@ static struct _tbm_surface *
 _tbm_surface_internal_create_surface(tbm_bufmgr bufmgr, int width, int height, int format, int flags, tbm_error_e *error)
 {
        struct _tbm_surface *surf;
-       int is_surface_data = 0;
+       int can_share_surface = 0;
 
        surf = _tbm_surface_internal_alloc(bufmgr, width, height, format, error);
        if (!surf) {
@@ -800,8 +800,8 @@ _tbm_surface_internal_create_surface(tbm_bufmgr bufmgr, int width, int height, i
                /* LCOV_EXCL_STOP */
        }
 
-       is_surface_data = tbm_module_support_surface_data(bufmgr->module);
-       if (is_surface_data) {
+       can_share_surface = tbm_bufmgr_internal_support_capabilites(bufmgr, TBM_BUFMGR_CAPABILITY_SHARE_SURFACE);
+       if (can_share_surface) {
                // alloc surface_data
                surf->surface_data = tbm_module_alloc_surface_data(bufmgr->module, width, height, format, flags, error);
                if (!surf->surface_data) {
@@ -813,7 +813,7 @@ _tbm_surface_internal_create_surface(tbm_bufmgr bufmgr, int width, int height, i
        }
 
        // set the surface data
-       *error =  _tbm_surface_internal_set_data(surf, flags, is_surface_data);
+       *error =  _tbm_surface_internal_set_data(surf, flags, can_share_surface);
        if (*error != TBM_ERROR_NONE) {
                tbm_surface_data_free(surf->surface_data);
                surf->surface_data = NULL;
@@ -2890,7 +2890,7 @@ tbm_surface_internal_export(tbm_surface_h surface, tbm_error_e *error)
        TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_OPERATION);
 
        // this function supports when the module suppport surface_data.
-       TBM_SURFACE_RETURN_VAL_SET_ERR_NO_LOG_IF_FAIL(tbm_module_support_surface_data(bufmgr->module), NULL, error, TBM_ERROR_NOT_SUPPORTED);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_NO_LOG_IF_FAIL(tbm_bufmgr_internal_support_capabilites(bufmgr, TBM_BUFMGR_CAPABILITY_SHARE_SURFACE), NULL, error, TBM_ERROR_NOT_SUPPORTED);
 
        TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(_tbm_surface_internal_is_valid(surface), NULL, error, TBM_ERROR_INVALID_PARAMETER);
 
@@ -2918,7 +2918,7 @@ tbm_surface_internal_import(tbm_surface_info_s *surface_info, tbm_surface_buffer
        TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr != NULL, NULL, error, TBM_ERROR_INVALID_OPERATION);
 
        // this function supports when the module suppport surface_data.
-       TBM_SURFACE_RETURN_VAL_SET_ERR_NO_LOG_IF_FAIL(tbm_module_support_surface_data(bufmgr->module), NULL, error, TBM_ERROR_NOT_SUPPORTED);
+       TBM_SURFACE_RETURN_VAL_SET_ERR_NO_LOG_IF_FAIL(tbm_bufmgr_internal_support_capabilites(bufmgr, TBM_BUFMGR_CAPABILITY_SHARE_SURFACE), NULL, error, TBM_ERROR_NOT_SUPPORTED);
 
        TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info != NULL, NULL, error, TBM_ERROR_INVALID_PARAMETER);
        TBM_SURFACE_RETURN_VAL_SET_ERR_IF_FAIL(surface_info->width > 0, NULL, error, TBM_ERROR_INVALID_PARAMETER);