tbm_bo_alloc(tbm_bufmgr bufmgr, int size, int flags)
{
tbm_bo bo;
- void *bo_priv;
tbm_backend_bo_data *bo_data;
tbm_error_e error;
_tbm_util_check_bo_cnt(bufmgr);
- if (bufmgr->use_hal_tbm) {
- bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_alloc_bo(bufmgr->hal_bufmgr, size, flags, (hal_tbm_error *)&error);
+ bo_data = tbm_module_bufmgr_bo_alloc(bufmgr->module, bo, size, flags, &error);
+ if (!bo_data || error != TBM_ERROR_NONE) {
/* LCOV_EXCL_START */
- if (!bo_data) {
- _tbm_set_last_result(error);
- goto alloc_fail;
- }
+ TBM_ERR("tbm_module_bufmgr_bo_alloc failed. error:%d", error);
+ _tbm_set_last_result(error);
+ goto alloc_fail;
/* LCOV_EXCL_STOP */
- bo->bo_data = bo_data;
- } else if (bufmgr->backend_module_data) {
- bo_data = bufmgr->bufmgr_func->bufmgr_alloc_bo(bufmgr->bufmgr_data, (unsigned int)size, flags, &error);
- if (!bo_data) {
- /* LCOV_EXCL_START */
- _tbm_set_last_result(error);
- goto alloc_fail;
- /* LCOV_EXCL_STOP */
- }
- bo->bo_data = bo_data;
- } else {
- bo_priv = bufmgr->backend->bo_alloc(bo, size, flags);
- if (!bo_priv) {
- /* LCOV_EXCL_START */
- _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
- goto alloc_fail;
- /* LCOV_EXCL_STOP */
- }
- bo->priv = bo_priv;
}
+ bo->bo_data = bo_data;
+ bo->priv = (void *)bo_data; // TODO: this will be DEPRECATED.
_tbm_bo_init(bufmgr, bo, flags);
tbm_module *tbm_module_load(int fd);
void tbm_module_unload(tbm_module *module);
-int tbm_module_bufmgr_get_capabilities(tbm_module *module);
+int tbm_module_bufmgr_get_capabilities(tbm_module *module);
+tbm_backend_bo_data *tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error);
#endif /* _TBM_BUFMGR_INT_H_ */
return capabilities;
}
+
+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 *bo_data = NULL;
+ tbm_backend_bufmgr_func *bufmgr_func = NULL;
+ tbm_bufmgr_backend backend = NULL;
+
+ TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
+
+ switch (module->type) {
+ case TBM_MODULE_TYPE_HAL_TBM:
+ bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_alloc_bo(module->hal_bufmgr, size, flags, (hal_tbm_error *)error);
+ break;
+ case TBM_MODULE_TYPE_TBM_BACKEND:
+ bufmgr_func = module->bufmgr_func;
+ TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, NULL, *error, TBM_ERROR_INVALID_OPERATION);
+ TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_alloc_bo, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
+
+ bo_data = module->bufmgr_func->bufmgr_alloc_bo(module->bufmgr_data, (unsigned int)size, flags, error);
+ break;
+ case TBM_MODULE_TYPE_BUFMGR_BACKEND:
+ TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 7.0.");
+ backend = module->backend;
+ TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, NULL, *error, TBM_ERROR_INVALID_OPERATION);
+ TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_alloc, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
+
+ bo_data = (void *)module->backend->bo_alloc(bo, size, flags);
+ *error = TBM_ERROR_NONE;
+ break;
+ default:
+ TBM_ERR("Wrong module type:%d", module->type);
+ *error = TBM_ERROR_INVALID_OPERATION;
+ break;
+ }
+
+ return bo_data;
+}