From d6cb1af23262d050c63cc6b00cf50ed752771eb1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 17 Jun 2021 16:07:21 +0900 Subject: [PATCH] tbm_module: add tbm_module_bo_free and use it The tbm_module_bo_free calls it's backend function. Change-Id: Ic0aa305f742ef543119d607061c8abe59cf1bae9 --- src/tbm_bo.c | 17 +---------------- src/tbm_bufmgr_int.h | 2 ++ src/tbm_module.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 39aac76..8b3fd81 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -1076,22 +1076,7 @@ _tbm_bo_free(tbm_bo bo) bo->lock_cnt--; } - /* call the bo_free */ - if (bo->bufmgr->use_hal_tbm) { - // call hal_tbm_bo_free when bo is created by tbm_bo_alloc api. - if (!bo->get_from_hal_surface) { - bo->get_from_hal_surface = 0; - - hal_tbm_bo_free(bo->bo_data); - bo->bo_data = NULL; - } - } else if (bo->bufmgr->backend_module_data) { - bo->bufmgr->bo_func->bo_free(bo->bo_data); - bo->bo_data = NULL; - } else { - bo->bufmgr->backend->bo_free(bo); - bo->priv = NULL; - } + tbm_module_bo_free(bo->bufmgr->module, bo, bo->bo_data, bo->get_from_hal_surface); _tbm_bo_deinit(bo); diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 7776b3c..d44a144 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -370,4 +370,6 @@ tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc_with_format(tbm_module *module, tbm_backend_bo_data *tbm_module_bufmgr_bo_import_fd(tbm_module *module, tbm_bo bo, tbm_fd fd, tbm_error_e *error); 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); + #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index a29b477..af83975 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -809,3 +809,42 @@ tbm_module_bufmgr_bo_import_key(tbm_module *module, tbm_bo bo, tbm_key key, tbm_ return bo_data; } + +void +tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int get_from_hal_surface) +{ + tbm_backend_bo_func *bo_func = NULL; + tbm_bufmgr_backend backend = NULL; + + TBM_RETURN_IF_FAIL(module); + TBM_RETURN_IF_FAIL(bo); + TBM_RETURN_IF_FAIL(bo_data); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + // call hal_tbm_bo_free when bo is created by tbm_bo_alloc api. + if (get_from_hal_surface) + hal_tbm_bo_free(bo_data); + break; +/* LCOV_EXCL_START */ + case TBM_MODULE_TYPE_TBM_BACKEND: + bo_func = module->bo_func; + TBM_RETURN_IF_FAIL(bo_func); + TBM_RETURN_IF_FAIL(bo_func->bo_free); + + bo_func->bo_free(bo_data); + 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_IF_FAIL(backend); + TBM_RETURN_IF_FAIL(backend->bo_free); + + backend->bo_free(bo); + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + break; +/* LCOV_EXCL_STOP */ + } +} -- 2.7.4