From: SooChan Lim Date: Thu, 17 Jun 2021 08:08:48 +0000 (+0900) Subject: tbm_module: add tbm_module_bo_get_bo_handle and use it X-Git-Tag: submit/tizen/20210618.025159~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F260018%2F1;p=platform%2Fcore%2Fuifw%2Flibtbm.git tbm_module: add tbm_module_bo_get_bo_handle and use it The tbm_module_bo_get_bo_handle calls it's backend function Change-Id: I14f12650031bc1ca250de953724e8ac9f91e7664 --- diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 55c9581..2eb9213 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -521,35 +521,14 @@ tbm_bo_get_handle(tbm_bo bo, int device) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), (tbm_bo_handle) NULL); - if (bo->bufmgr->use_hal_tbm) { - hal_tbm_bo_handle hbo_handle; - hbo_handle = hal_tbm_bo_get_handle((hal_tbm_bo *)bo->bo_data, device, (hal_tbm_error *)&error); - if (hbo_handle.ptr == NULL) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) bo_handle(%p) error(%d)\n", bo, hbo_handle.ptr, error); - _tbm_set_last_result(error); - goto bo_handle_fail; - /* LCOV_EXCL_STOP */ - } - memcpy(&bo_handle.ptr, &hbo_handle.ptr, sizeof(tbm_bo_handle)); - } else if (bo->bufmgr->backend_module_data) { - bo_handle = bo->bufmgr->bo_func->bo_get_handle(bo->bo_data, device, &error); - if (bo_handle.ptr == NULL) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) bo_handle(%p) error(%d)\n", bo, bo_handle.ptr, error); - _tbm_set_last_result(error); - goto bo_handle_fail; - /* LCOV_EXCL_STOP */ - } - } else { - bo_handle = bo->bufmgr->backend->bo_get_handle(bo, device); - if (bo_handle.ptr == NULL) { - /* LCOV_EXCL_START */ - TBM_ERR("error: bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - goto bo_handle_fail; - /* LCOV_EXCL_STOP */ - } + bo_handle = tbm_module_bo_get_handle(bo->bufmgr->module, bo, bo->bo_data, device, &error); + if (bo_handle.ptr == NULL) { + /* LCOV_EXCL_START */ + TBM_ERR("error: bo(%p) bo_handle(%p) error(%d)\n", bo, bo_handle.ptr, error); + _tbm_set_last_result(error); + _tbm_bufmgr_mutex_unlock(); + return (tbm_bo_handle)NULL; + /* LCOV_EXCL_STOP */ } TBM_TRACE_BO("bo(%p) bo_handle(%p)\n", bo, bo_handle.ptr); @@ -557,10 +536,6 @@ tbm_bo_get_handle(tbm_bo bo, int device) _tbm_bufmgr_mutex_unlock(); return bo_handle; - -bo_handle_fail: - _tbm_bufmgr_mutex_unlock(); - return (tbm_bo_handle) NULL; } tbm_key diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index 1eebfc2..c77579f 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -370,8 +370,9 @@ 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); -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); +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); +tbm_bo_handle tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, tbm_error_e *error); #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_module.c b/src/tbm_module.c index 0bcbf7d..62e0441 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -931,3 +931,50 @@ tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_dat return memory_types; } + +tbm_bo_handle +tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, tbm_error_e *error) +{ + tbm_backend_bo_func *bo_func = NULL; + tbm_bufmgr_backend backend = NULL; + tbm_bo_handle bo_handle; + hal_tbm_bo_handle hbo_handle; + + TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + hbo_handle = hal_tbm_bo_get_handle((hal_tbm_bo *)bo_data, device, (hal_tbm_error *)error); + if (hbo_handle.ptr != NULL) + memcpy(&bo_handle.ptr, &hbo_handle.ptr, sizeof(tbm_bo_handle)); + break; +/* LCOV_EXCL_START */ + case TBM_MODULE_TYPE_TBM_BACKEND: + bo_func = module->bo_func; + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_get_handle, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED); + + bo_handle = bo_func->bo_get_handle(bo_data, device, 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, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_get_handle, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED); + + bo_handle = backend->bo_get_handle(bo, device); + if (!bo_handle.ptr) + *error = TBM_ERROR_INVALID_OPERATION; + else + *error = TBM_ERROR_NONE; + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + bo_handle.ptr = NULL; + *error = TBM_ERROR_INVALID_OPERATION; + break; +/* LCOV_EXCL_STOP */ + } + + return bo_handle; +} \ No newline at end of file