From: SooChan Lim Date: Tue, 22 Jun 2021 01:39:41 +0000 (+0900) Subject: tbm_module: add tbm_module_alloc_surface_data X-Git-Tag: accepted/tizen/unified/20210625.170433~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22a0354142175464cfe4e7fbce6dd3151042cb65;p=platform%2Fcore%2Fuifw%2Flibtbm.git tbm_module: add tbm_module_alloc_surface_data This allocates a tbm_backend_surface_data resource. Change-Id: I3548be16f63fa616feff4e740749f8ac1356a548 --- diff --git a/src/tbm_module.c b/src/tbm_module.c index c9b64f3..b752cd2 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -644,6 +644,41 @@ tbm_module_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_ return error; } +tbm_backend_surface_data * +tbm_module_alloc_surface_data(tbm_module *module, int width, int height, int format, int flags, tbm_error_e *error) +{ + tbm_backend_surface_data *surface_data = NULL; + + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module->type == TBM_MODULE_TYPE_HAL_TBM, NULL, *error, TBM_ERROR_INVALID_OPERATION); + + surface_data = calloc(1, sizeof(struct _tbm_backend_surface_data)); + if (!surface_data) { + TBM_ERR("memory allocation failed."); + *error = TBM_ERROR_OUT_OF_MEMORY; + return NULL; + } + + surface_data->hal_surface = hal_tbm_bufmgr_alloc_surface(module->hal_bufmgr, + (uint32_t)width, + (uint32_t)height, + (hal_tbm_format)format, + (hal_tbm_bo_memory_type)flags, + NULL, + 0, + (hal_tbm_error *)error); + if (!surface_data->hal_surface) { + TBM_ERR("hal_tbm_bufmgr_alloc_surface failed."); + *error = TBM_ERROR_INVALID_OPERATION; + free(surface_data); + return NULL; + } + + surface_data->module = module; + + return surface_data; +} + tbm_backend_bo_data * tbm_module_alloc_bo_data(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error) { @@ -1247,4 +1282,4 @@ tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_ } return ret; -} \ No newline at end of file +} diff --git a/src/tbm_module.h b/src/tbm_module.h index b85b855..df4c22f 100644 --- a/src/tbm_module.h +++ b/src/tbm_module.h @@ -81,6 +81,9 @@ int tbm_module_get_capabilities(tbm_module *module, tbm_error_e tbm_error_e tbm_module_bind_native_display(tbm_module *module, void *native_display); tbm_error_e tbm_module_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num); tbm_error_e tbm_module_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx); + +tbm_backend_surface_data *tbm_module_alloc_surface_data(tbm_module *module, int width, int height, int format, int flags, tbm_error_e *error); + tbm_backend_bo_data *tbm_module_alloc_bo_data(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error); tbm_backend_bo_data *tbm_module_alloc_bo_data_with_format(tbm_module *module, int format, int bo_idx, int width, int height, int bpp, tbm_bo_memory_type flags, tbm_error_e *error); tbm_backend_bo_data *tbm_module_import_bo_data_with_fd(tbm_module *module, tbm_bo bo, tbm_fd fd, tbm_error_e *error);