tbm_bo : use hal_tbm_bufmgr_alloc_bo_with_format instead of hal_tbm_bufmgr_alloc_bo_w...
[platform/core/uifw/libtbm.git] / src / tbm_surface_internal.c
index df57c42..0618fe4 100644 (file)
@@ -630,6 +630,11 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats,
 
        if (!g_surface_bufmgr) {
                _init_surface_bufmgr();
+               if (!g_surface_bufmgr) {
+                       TBM_ERR("fail bufmgr initialization\n");
+                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+                       goto fail;
+               }
                LIST_INITHEAD(&g_surface_bufmgr->surf_list);
                bufmgr_initialized = true;
        }
@@ -770,6 +775,11 @@ tbm_surface_internal_create_with_flags(int width, int height,
 
        if (!g_surface_bufmgr) {
                _init_surface_bufmgr();
+               if (!g_surface_bufmgr) {
+                       TBM_ERR("fail bufmgr initialization\n");
+                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+                       goto check_valid_fail;
+               }
                LIST_INITHEAD(&g_surface_bufmgr->surf_list);
                bufmgr_initialized = true;
        }
@@ -777,6 +787,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
        bufmgr = g_surface_bufmgr;
        if (!TBM_BUFMGR_IS_VALID(bufmgr)) {
                TBM_ERR("The bufmgr is invalid\n");
+               _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
                goto check_valid_fail;
        }
 
@@ -839,21 +850,9 @@ tbm_surface_internal_create_with_flags(int width, int height,
                }
 
                if (bufmgr->use_hal_tbm) {
-                       surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, flags, &error);
+                       surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, surf->info.bpp/8, flags, &error);
                        if (error == TBM_ERROR_NOT_SUPPORTED) {
-                               if (flags & TBM_BO_TILED) {
-                                       surf->bos[i] = tbm_bo_alloc_with_tiled_format(bufmgr, width, height, surf->info.bpp/8, format, flags, i, &error);
-                                       if (error == TBM_ERROR_NOT_SUPPORTED) {
-                                               surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
-                                       } else if (error != TBM_ERROR_NONE) {
-                                               TBM_ERR("fail to alloc bo idx:%d\n", i);
-                                               goto alloc_bo_fail;
-                                       }
-                               } else {
-                                       surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags);
-                               }
-
-                               if (!surf->bos[i]) {
+                               if (error != TBM_ERROR_NONE) {
                                        TBM_ERR("fail to alloc bo idx:%d\n", i);
                                        goto alloc_bo_fail;
                                }
@@ -864,7 +863,7 @@ tbm_surface_internal_create_with_flags(int width, int height,
                } else if (bufmgr->backend_module_data) {
                        if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format) {
                                /* LCOV_EXCL_START */
-                               surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, flags, &error);
+                               surf->bos[i] = tbm_bo_alloc_with_format(bufmgr, format, i, width, height, surf->info.bpp/8, flags, &error);
                                if (!surf->bos[i]) {
                                        TBM_ERR("fail to tbm_bo_alloc_with_format idx:%d\n", i);
                                        goto alloc_bo_fail;
@@ -965,6 +964,11 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info,
 
        if (!g_surface_bufmgr) {
                _init_surface_bufmgr();
+               if (!g_surface_bufmgr) {
+                       TBM_ERR("fail bufmgr initialization\n");
+                       _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION);
+                       goto check_valid_fail;
+               }
                LIST_INITHEAD(&g_surface_bufmgr->surf_list);
                bufmgr_initialized = true;
        }