From b3f8484225c3945c6d0aa783609df5baaa6a58cd Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 16:30:08 +0900 Subject: [PATCH] tbm_module: add tbm_module_bo_get_size and use it The tbm_module_bo_get_size calls it's backend function. Change-Id: I8b06b99e565b673de3a192537658b1bb0e63e1dd --- src/tbm_bo.c | 50 ++++++-------------------------------------------- src/tbm_bufmgr.c | 24 +++++++----------------- src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 61 deletions(-) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 8b3fd81..55c9581 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -762,20 +762,8 @@ tbm_bo_size(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0); - if (bo->bufmgr->use_hal_tbm) { - size = hal_tbm_bo_get_size((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error); - if (error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of the bo_data(%d).", error); - _tbm_set_last_result(TBM_ERROR_NONE); - } - } else if (bo->bufmgr->backend_module_data) { - size = bo->bufmgr->bo_func->bo_get_size(bo->bo_data, &error); - if (error != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of the bo_data(%d).", error); - _tbm_set_last_result(TBM_ERROR_NONE); - } - } else - size = bo->bufmgr->backend->bo_size(bo); + size = tbm_module_bo_get_size(bo->bufmgr->module, bo, bo->bo_data, &error); + _tbm_set_last_result(error); TBM_TRACE_BO("bo(%p) size(%d)\n", bo, size); @@ -826,36 +814,10 @@ tbm_bo_swap(tbm_bo bo1, tbm_bo bo2) TBM_TRACE_BO("before: bo1(%p) bo2(%p)\n", bo1, bo2); - if (bo1->bufmgr->use_hal_tbm) { - size1 = hal_tbm_bo_get_size((hal_tbm_bo *)bo1->bo_data, (hal_tbm_error *)&error1); - if (error1 != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of bo1.(%d)", error1); - _tbm_set_last_result(error1); - goto fail; - } - size2 = hal_tbm_bo_get_size((hal_tbm_bo *)bo2->bo_data, (hal_tbm_error *)&error2); - if (error2 != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of bo1.(%d)", error2); - _tbm_set_last_result(error2); - goto fail; - } - } else if (bo1->bufmgr->backend_module_data) { - size1 = bo1->bufmgr->bo_func->bo_get_size(bo1->bo_data, &error1); - if (error1 != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of bo1.(%d)", error1); - _tbm_set_last_result(error1); - goto fail; - } - size2 = bo2->bufmgr->bo_func->bo_get_size(bo2->bo_data, &error2); - if (error2 != TBM_ERROR_NONE) { - TBM_ERR("fail to get the size of bo2.(%d)", error2); - _tbm_set_last_result(error2); - goto fail; - } - } else { - size1 = bo1->bufmgr->backend->bo_size(bo1); - size2 = bo2->bufmgr->backend->bo_size(bo2); - } + size1 = tbm_module_bo_get_size(bo1->bufmgr->module, bo1, bo1->bo_data, &error1); + _tbm_set_last_result(error1); + size2 = tbm_module_bo_get_size(bo2->bufmgr->module, bo2, bo2->bo_data, &error2); + _tbm_set_last_result(error2); if (size1 != size2) { TBM_ERR("error: bo1 size(%d) and bo2 size(%d) is different.", size1, size2); diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 45d0478..be42dd6 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -574,16 +574,9 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr) TBM_SNRPRINTF(str, len, c, "%s\n", data); for (i = 0; i < surf->num_bos; i++) { - if (bufmgr->use_hal_tbm) { - size = hal_tbm_bo_get_size((hal_tbm_bo *)surf->bos[i]->bo_data, (hal_tbm_error *)&error); - if (error != TBM_ERROR_NONE) - TBM_WRN("fail to get the size of bo."); - } else if (bufmgr->backend_module_data) { - size = bufmgr->bo_func->bo_get_size(surf->bos[i]->bo_data, &error); - if (error != TBM_ERROR_NONE) - TBM_WRN("fail to get the size of bo."); - } else - size = bufmgr->backend->bo_size(surf->bos[i]); + size = tbm_module_bo_get_size(bufmgr->module, surf->bos[i], surf->bos[i]->bo_data, &error); + if (error != TBM_ERROR_NONE) + TBM_WRN("fail to get the size of bo."); TBM_SNRPRINTF(str, len, c, " bo:%-12p %-26d%-10d\n", surf->bos[i], surf->bos[i]->ref_cnt, @@ -604,20 +597,17 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr) tbm_key key = 0; LIST_FOR_EACH_ENTRY(bo, &bufmgr->bo_list, item_link) { + size = tbm_module_bo_get_size(bufmgr->module, bo, bo->bo_data, &error); + if (error != TBM_ERROR_NONE) + TBM_WRN("fail to get the size of bo."); + if (bo->bufmgr->use_hal_tbm) { - size = hal_tbm_bo_get_size((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error); - if (error != TBM_ERROR_NONE) - TBM_WRN("fail to get the size of bo."); key = (tbm_key)hal_tbm_bo_export_key((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error); } else if (bufmgr->backend_module_data) { - size = bufmgr->bo_func->bo_get_size(bo->bo_data, &error); - if (error != TBM_ERROR_NONE) - TBM_WRN("fail to get the size of bo."); key = bufmgr->bo_func->bo_export_key(bo->bo_data, &error); if (error != TBM_ERROR_NONE) TBM_WRN("fail to get the tdm_key of bo."); } else { - size = bufmgr->backend->bo_size(bo); key = bufmgr->backend->bo_export(bo); } TBM_SNRPRINTF(str, len, c, "%-3d %-11p %-5d %-7d %-6d %-5u %-7d %-11p %-4d\n", diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index d44a144..639cb43 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -371,5 +371,6 @@ tbm_backend_bo_data *tbm_module_bufmgr_bo_import_fd(tbm_module *module, tbm_bo b tbm_backend_bo_data *tbm_module_bufmgr_bo_import_key(tbm_module *module, tbm_bo bo, tbm_key key, tbm_error_e *error); 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); #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index af83975..236db41 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -848,3 +848,46 @@ tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, /* LCOV_EXCL_STOP */ } } + +int +tbm_module_bo_get_size(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 size = 0; + + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + size = hal_tbm_bo_get_size((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_size, 0, *error, TBM_ERROR_NOT_SUPPORTED); + + size = bo_func->bo_get_size(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_size, 0, *error, TBM_ERROR_NOT_SUPPORTED); + + size = backend->bo_size(bo); + if (size == 0) + *error = TBM_ERROR_INVALID_OPERATION; + else + *error = TBM_ERROR_NONE; + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + *error = TBM_ERROR_INVALID_OPERATION; + break; +/* LCOV_EXCL_STOP */ + } + + return size; +} -- 2.7.4