From 174faf5146c03dacbebabddf25b9ca8d087b8f17 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 16:45:54 +0900 Subject: [PATCH] tbm_module: add tbm_module_bo_get_memory_types and use it The tbm_module_bo_get_memory_types calls it's backend function Change-Id: I1d56ab9485bc1cccf089c65cd66da87fae288823 --- src/tbm_bufmgr.c | 44 ++++++++------------------------------------ src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index be42dd6..9fae74c 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -1062,24 +1062,10 @@ tbm_bufmgr_internal_import_bo_with_key(tbm_bufmgr bufmgr, unsigned int key, tbm_ return bo2; } - // TODO: refactoring tbm_module_bo - if (bufmgr->use_hal_tbm) { - flags = (tbm_bo_memory_type)hal_tbm_bo_get_memory_types((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)error); - if (*error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the bo flags(memory_types)"); - flags = TBM_BO_DEFAULT; - } - } else if (bufmgr->backend_module_data) { - flags = bufmgr->bo_func->bo_get_memory_types(bo->bo_data, error); - if (error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the bo flags(memory_types)"); - flags = TBM_BO_DEFAULT; - } - } else { - if (bufmgr->backend->bo_get_flags) - flags = bufmgr->backend->bo_get_flags(bo); - else - flags = TBM_BO_DEFAULT; + flags = tbm_module_bo_get_memory_types(bufmgr->module, bo, bo->bo_data, error); + if (*error != TBM_ERROR_NONE) { + TBM_ERR("fail to get the bo flags(memory_types)"); + flags = TBM_BO_DEFAULT; } _tbm_bufmgr_initialize_bo(bufmgr, bo, flags); @@ -1123,24 +1109,10 @@ tbm_bufmgr_internal_import_bo_with_fd(tbm_bufmgr bufmgr, tbm_fd fd, tbm_error_e return bo2; } - // TODO: refactoring tbm_module_bo - if (bufmgr->use_hal_tbm) { - flags = (tbm_bo_memory_type)hal_tbm_bo_get_memory_types((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)error); - if (error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the bo flags(memory_types)"); - flags = TBM_BO_DEFAULT; - } - } else if (bufmgr->backend_module_data) { - flags = bufmgr->bo_func->bo_get_memory_types(bo->bo_data, error); - if (error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the bo flags(memory_types)"); - flags = TBM_BO_DEFAULT; - } - } else { - if (bufmgr->backend->bo_get_flags) - flags = bufmgr->backend->bo_get_flags(bo); - else - flags = TBM_BO_DEFAULT; + flags = tbm_module_bo_get_memory_types(bufmgr->module, bo, bo->bo_data, error); + if (*error != TBM_ERROR_NONE) { + TBM_ERR("fail to get the bo flags(memory_types)"); + flags = TBM_BO_DEFAULT; } _tbm_bufmgr_initialize_bo(bufmgr, bo, flags); diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 639cb43..1eebfc2 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -372,5 +372,6 @@ tbm_backend_bo_data *tbm_module_bufmgr_bo_import_key(tbm_module *module, tbm_bo void tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int get_from_hal_surface); int tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error); +int tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error); #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index 236db41..0bcbf7d 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -891,3 +891,43 @@ tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_da return size; } + +int +tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error) +{ + tbm_backend_bo_func *bo_func = NULL; + tbm_bufmgr_backend backend = NULL; + int memory_types = TBM_BO_DEFAULT; + + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + memory_types = (tbm_bo_memory_type)hal_tbm_bo_get_memory_types((hal_tbm_bo *)bo_data, (hal_tbm_error *)error); + break; +/* LCOV_EXCL_START */ + case TBM_MODULE_TYPE_TBM_BACKEND: + bo_func = module->bo_func; + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, 0, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_get_memory_types, 0, *error, TBM_ERROR_NOT_SUPPORTED); + + memory_types = bo_func->bo_get_memory_types(bo_data, error); + 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_SET_ERR_IF_FAIL(backend, 0, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_get_flags, 0, *error, TBM_ERROR_NOT_SUPPORTED); + + memory_types = backend->bo_get_flags(bo); + *error = TBM_ERROR_NONE; + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + *error = TBM_ERROR_INVALID_OPERATION; + break; +/* LCOV_EXCL_STOP */ + } + + return memory_types; +} -- 2.7.4