tbm_module: add tbm_module_bo_free and use it 15/260015/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 07:07:21 +0000 (16:07 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 17 Jun 2021 09:48:15 +0000 (18:48 +0900)
The tbm_module_bo_free calls it's backend function.

Change-Id: Ic0aa305f742ef543119d607061c8abe59cf1bae9

src/tbm_bo.c
src/tbm_bufmgr_int.h
src/tbm_module.c

index 39aac76..8b3fd81 100644 (file)
@@ -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);
 
index 7776b3c..d44a144 100644 (file)
@@ -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_ */
index a29b477..af83975 100644 (file)
@@ -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 */
+       }
+}