From 5523257c086e94f4659cd1b2bd78b79749b59778 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 15 Jun 2021 14:39:00 +0900 Subject: [PATCH] tbm_module: make tbm_module_bufmgr_get_supported_format encapsulate the bufmgr_get_supported_format with this function. Change-Id: Ia816a505b2a0bfa7cd01997c44f0b1317696761a --- src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 41 ++++++++++++++++++++++++++++++++++++++++ src/tbm_surface_internal.c | 47 +++++----------------------------------------- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 915cd1b..b231cab 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -355,6 +355,7 @@ void tbm_module_unload(tbm_module *module); int tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error); tbm_error_e tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display); +tbm_error_e tbm_module_bufmgr_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num); tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error); tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc_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); diff --git a/src/tbm_module.c b/src/tbm_module.c index ba9c836..0ba5dc0 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -552,6 +552,47 @@ tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display) return error; } +tbm_error_e +tbm_module_bufmgr_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num) +{ + tbm_error_e error = TBM_ERROR_NONE; + tbm_backend_bufmgr_func *bufmgr_func = NULL; + tbm_bufmgr_backend backend = NULL; + int ret = 0; + + TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + error = (tbm_error_e)hal_tbm_bufmgr_get_supported_formats(module->hal_bufmgr, formats, num); + break; + case TBM_MODULE_TYPE_TBM_BACKEND: + bufmgr_func = module->bufmgr_func; + TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_supported_formats, TBM_ERROR_NOT_SUPPORTED); + + error = bufmgr_func->bufmgr_get_supported_formats(module->bufmgr_data, formats, num); + break; + case TBM_MODULE_TYPE_BUFMGR_BACKEND: + TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5."); + backend = module->backend; + TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(backend->surface_supported_format, TBM_ERROR_NOT_SUPPORTED); + + ret = backend->surface_supported_format(formats, num); + if (!ret) + error = TBM_ERROR_INVALID_OPERATION; + + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + error = TBM_ERROR_INVALID_OPERATION; + break; + } + + return error; +} + tbm_backend_bo_data * tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error) { diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 3b88a08..3f292d7 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -1040,7 +1040,6 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats, uint32_t *num) { struct _tbm_bufmgr *bufmgr; - int ret = 0; bool bufmgr_initialized = false; tbm_error_e error; @@ -1063,46 +1062,10 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats, bufmgr = g_surface_bufmgr; - if (bufmgr->use_hal_tbm) { - error = (tbm_error_e)hal_tbm_bufmgr_get_supported_formats(bufmgr->hal_bufmgr, formats, num); - /* LCOV_EXCL_START */ - if (error == TBM_ERROR_NOT_SUPPORTED) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - goto fail; - } else if (error != TBM_ERROR_NONE) { - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - goto fail; - } - /* LCOV_EXCL_STOP */ - ret = 1; - } else if (bufmgr->backend_module_data) { - if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - goto fail; - } - - error = bufmgr->bufmgr_func->bufmgr_get_supported_formats(bufmgr->bufmgr_data, formats, num); - if (error != TBM_ERROR_NONE) { - /* LCOV_EXCL_START */ - TBM_ERR("Fail to surface_supported_format. error(%d)\n", error); - goto fail; - /* LCOV_EXCL_START */ - } - ret = 1; - } else { - if (!bufmgr->backend->surface_supported_format) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - goto fail; - } - - ret = bufmgr->backend->surface_supported_format(formats, num); - if (!ret) { - /* LCOV_EXCL_START */ - TBM_ERR("Fail to surface_supported_format.\n"); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - goto fail; - /* LCOV_EXCL_START */ - } + error = tbm_module_bufmgr_get_supported_formats(bufmgr->module, formats, num); + if (error != TBM_ERROR_NONE) { + _tbm_set_last_result(error); + goto fail; } TBM_TRACE_SURFACE_INTERNAL("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num); @@ -1114,7 +1077,7 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats, _tbm_surface_mutex_unlock(); - return ret; + return 1; /* LCOV_EXCL_START */ fail: -- 2.7.4