tbm_module: add tbm_bo_data structure and use it
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr.c
index 9fae74c..932bfb8 100644 (file)
@@ -195,42 +195,6 @@ _tbm_util_get_appname_from_pid(long pid, char *str)
        snprintf(str, sizeof(cmdline), "%s", cmdline);
 }
 
-static void
-_tbm_bufmgr_copy_module_data(tbm_bufmgr bufmgr, tbm_module *module)
-{
-       bufmgr->module_data = module->module_data;
-       bufmgr->backend = module->backend;
-
-       bufmgr->backend_module_data = module->backend_module_data;
-       bufmgr->bufmgr_data = module->bufmgr_data;
-       bufmgr->bufmgr_func = module->bufmgr_func;
-       bufmgr->bo_func = module->bo_func;
-
-       bufmgr->use_hal_tbm = module->use_hal_tbm;
-       bufmgr->auth_wl_socket_created = module->auth_wl_socket_created;
-       bufmgr->auth_fd = module->auth_fd;
-       bufmgr->hal_backend = module->hal_backend;
-       bufmgr->hal_bufmgr = module->hal_bufmgr;
-}
-
-static void
-_tbm_bufmgr_reset_modlue_data(tbm_bufmgr bufmgr)
-{
-       bufmgr->module_data = NULL;
-       bufmgr->backend = NULL;
-
-       bufmgr->backend_module_data = NULL;
-       bufmgr->bufmgr_data = NULL;
-       bufmgr->bufmgr_func = NULL;
-       bufmgr->bo_func = NULL;
-
-       bufmgr->use_hal_tbm = 0;
-       bufmgr->auth_wl_socket_created = 0;
-       bufmgr->auth_fd = -1;
-       bufmgr->hal_backend = NULL;
-       bufmgr->hal_bufmgr = NULL;
-}
-
 /* LCOV_EXCL_STOP */
 
 static tbm_bufmgr
@@ -309,11 +273,8 @@ _tbm_bufmgr_init(int fd, int server)
 
        }
 
-       // TODO: this is temporary. it will be removed after finishing refactoring the tbm_module.
-       _tbm_bufmgr_copy_module_data(gBufMgr, gBufMgr->module);
-
        /* check the essential capabilities of tbm_module */
-       gBufMgr->capabilities = tbm_module_bufmgr_get_capabilities(gBufMgr->module, &error);
+       gBufMgr->capabilities = tbm_module_get_capabilities(gBufMgr->module, &error);
        if (gBufMgr->capabilities == TBM_BUFMGR_CAPABILITY_NONE) {
                TBM_ERR("The capabilities of the backend module is TBM_BUFMGR_CAPABILITY_NONE.");
                TBM_ERR("TBM_BUFMGR_CAPABILITY_SHARE_FD is the essential capability.");
@@ -437,9 +398,6 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
 
        tbm_module_unload(bufmgr->module);
 
-       // TODO: this is temporary. it will be removed after finishing refactoring the tbm_module.
-       _tbm_bufmgr_reset_modlue_data(bufmgr);
-
        if (bufmgr->fd > 0)
                close(bufmgr->fd);
 
@@ -600,16 +558,9 @@ tbm_bufmgr_debug_tbm_info_get(tbm_bufmgr bufmgr)
                        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) {
-                               key = (tbm_key)hal_tbm_bo_export_key((hal_tbm_bo *)bo->bo_data, (hal_tbm_error *)&error);
-                       } else if (bufmgr->backend_module_data) {
-                               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 {
-                               key = bufmgr->backend->bo_export(bo);
-                       }
+                       key = tbm_module_bo_export_key(bufmgr->module, bo, bo->bo_data, &error);
+                       if (error != TBM_ERROR_NONE)
+                               TBM_WRN("fail to get the tdm_key of bo.");
                        TBM_SNRPRINTF(str, len, c, "%-3d %-11p   %-5d %-7d    %-6d    %-5u %-7d %-11p  %-4d\n",
                                  ++bo_cnt,
                                  bo,
@@ -816,7 +767,7 @@ tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display)
 
        TBM_BUFMGR_RETURN_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(bufmgr), 0);
 
-       error = tbm_module_bufmgr_bind_native_display(bufmgr->module, native_display);
+       error = tbm_module_bind_native_display(bufmgr->module, native_display);
        if (error != TBM_ERROR_NONE) {
                _tbm_set_last_result(error);
                _tbm_bufmgr_mutex_unlock();
@@ -895,9 +846,8 @@ tbm_bufmgr_internal_find_bo(tbm_bufmgr bufmgr, tbm_bo bo)
                return NULL;
 
        LIST_FOR_EACH_ENTRY(bo2, &bufmgr->bo_list, item_link) {
-               if (bo2->bo_data == bo->bo_data) {
+               if (tbm_module_compare_bo_data(bufmgr->module, bo2->bo_data, bo->bo_data))
                        return bo2;
-               }
        }
 
        return NULL;
@@ -907,7 +857,7 @@ tbm_bo
 tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags, tbm_error_e *error)
 {
        tbm_bo bo;
-       tbm_backend_bo_data *bo_data;
+       tbm_bo_data *bo_data;
 
        _tbm_bufmgr_check_bo_cnt(bufmgr);
 
@@ -920,16 +870,15 @@ tbm_bufmgr_internal_alloc_bo(tbm_bufmgr bufmgr, int size, int flags, tbm_error_e
                /* LCOV_EXCL_STOP */
        }
 
-       bo_data = tbm_module_bufmgr_bo_alloc(bufmgr->module, bo, size, flags, error);
+       bo_data = tbm_module_alloc_bo_data(bufmgr->module, bo, size, flags, error);
        if (!bo_data) {
                /* LCOV_EXCL_START */
-               TBM_ERR("tbm_module_bufmgr_bo_alloc failed. size:%d flags:%s error:%d", size, _tbm_flag_to_str(flags), *error);
+               TBM_ERR("tbm_module_alloc_bo_data failed. size:%d flags:%s error:%d", size, _tbm_flag_to_str(flags), *error);
                free(bo);
                return NULL;
                /* LCOV_EXCL_STOP */
        }
        bo->bo_data = bo_data;
-       bo->priv = (void *)bo_data; // TODO: this will be DEPRECATED.
 
        _tbm_bufmgr_initialize_bo(bufmgr, bo, flags);
 
@@ -961,7 +910,7 @@ tbm_bufmgr_internal_alloc_bo_with_format(tbm_bufmgr bufmgr, int format, int bo_i
                goto fail;
        }
 
-       bo->bo_data = tbm_module_bufmgr_bo_alloc_with_format(bufmgr->module, format, bo_idx, width, height, bpp, flags, error);
+       bo->bo_data = tbm_module_alloc_bo_data_with_format(bufmgr->module, format, bo_idx, width, height, bpp, flags, error);
        if (!bo->bo_data) {
                /* LCOV_EXCL_START */
                _tbm_set_last_result(*error);
@@ -984,7 +933,7 @@ fail:
 }
 
 tbm_bo
-tbm_bufmgr_internal_alloc_bo_with_bo_data(tbm_bufmgr bufmgr, tbm_backend_bo_data *bo_data, int flags)
+tbm_bufmgr_internal_alloc_bo_with_bo_data(tbm_bufmgr bufmgr, tbm_bo_data *bo_data, int flags)
 {
        tbm_bo bo, bo2 = NULL;
 
@@ -1006,7 +955,7 @@ tbm_bufmgr_internal_alloc_bo_with_bo_data(tbm_bufmgr bufmgr, tbm_backend_bo_data
                /* LCOV_EXCL_STOP */
        }
        bo->bo_data = bo_data;
-       bo->get_from_hal_surface = 1;
+       bo->get_from_surface_data = 1;
 
        // return an existed bo if the bo is already created with the same bo_data.
        bo2 = tbm_bufmgr_internal_find_bo(bufmgr, bo);
@@ -1043,10 +992,10 @@ tbm_bufmgr_internal_import_bo_with_key(tbm_bufmgr bufmgr, unsigned int key, tbm_
                /* LCOV_EXCL_STOP */
        }
 
-       bo->bo_data = tbm_module_bufmgr_bo_import_key(bufmgr->module, bo, key, error);
+       bo->bo_data = tbm_module_import_bo_data_with_key(bufmgr->module, bo, key, error);
        if (!bo->bo_data) {
                /* LCOV_EXCL_START */
-               TBM_ERR("tbm_module_bufmgr_bo_import_key failed. tbm_key:%d", key);
+               TBM_ERR("tbm_module_import_bo_data_with_key failed. tbm_key:%d", key);
                free(bo);
                return NULL;
                /* LCOV_EXCL_STOP */
@@ -1090,10 +1039,10 @@ tbm_bufmgr_internal_import_bo_with_fd(tbm_bufmgr bufmgr, tbm_fd fd, tbm_error_e
                /* LCOV_EXCL_STOP */
        }
 
-       bo->bo_data = tbm_module_bufmgr_bo_import_fd(bufmgr->module, bo, fd, error);
+       bo->bo_data = tbm_module_import_bo_data_with_fd(bufmgr->module, bo, fd, error);
        if (!bo->bo_data) {
                /* LCOV_EXCL_START */
-               TBM_ERR("tbm_module_bufmgr_bo_import_fd failed. tbm_fd:%d", fd);
+               TBM_ERR("tbm_module_import_bo_data_with_fd failed. tbm_fd:%d", fd);
                free(bo);
                return NULL;
                /* LCOV_EXCL_STOP */