From: SooChan Lim Date: Tue, 13 Mar 2018 10:58:27 +0000 (+0900) Subject: surface_internal: calls the new backend_funcs X-Git-Tag: accepted/tizen/unified/20180316.062629~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72338133b9fc0dce5e79884f657e488f3f9bdddd;p=platform%2Fcore%2Fuifw%2Flibtbm.git surface_internal: calls the new backend_funcs Change-Id: Ic5500224146f4e604b07d1e15e21bef6a1f27070 --- diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index d4cdaf1..ca26e4c 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -300,27 +300,43 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface, TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0); struct _tbm_surface *surf = (struct _tbm_surface *)surface; - struct _tbm_bufmgr *mgr = surf->bufmgr; + struct _tbm_bufmgr *bufmgr = surf->bufmgr; int ret = 0; + tbm_error_e error; - TBM_RETURN_VAL_IF_FAIL(mgr != NULL, 0); + TBM_RETURN_VAL_IF_FAIL(bufmgr != NULL, 0); TBM_RETURN_VAL_IF_FAIL(surf->info.width > 0, 0); TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0); TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0); - if (!mgr->backend->surface_get_plane_data) - return 0; + if (bufmgr->backend_module_data) { + if (!bufmgr->bufmgr_func->bufmgr_get_plane_data) + return 0; - ret = mgr->backend->surface_get_plane_data(surf->info.width, - surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx); - if (!ret) { - /* LCOV_EXCL_START */ - TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface); - return 0; - /* LCOV_EXCL_STOP */ + error = bufmgr->bufmgr_func->bufmgr_get_plane_data(bufmgr->bufmgr_data, surf->info.format, plane_idx, + surf->info.width, surf->info.height, size, offset, pitch, bo_idx); + if (error != TBM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error); + return 0; + /* LCOV_EXCL_STOP */ + } + ret = 1; + } else { + if (!bufmgr->backend->surface_get_plane_data) + return 0; + + ret = bufmgr->backend->surface_get_plane_data(surf->info.width, + surf->info.height, surf->info.format, plane_idx, size, offset, pitch, bo_idx); + if (!ret) { + /* LCOV_EXCL_START */ + TBM_ERR("Fail to surface_get_plane_data. surface(%p)\n", surface); + return 0; + /* LCOV_EXCL_STOP */ + } } - return 1; + return ret; } static void @@ -418,6 +434,7 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats, struct _tbm_bufmgr *bufmgr; int ret = 0; bool bufmgr_initialized = false; + tbm_error_e error; _tbm_surface_mutex_lock(); @@ -429,15 +446,29 @@ tbm_surface_internal_query_supported_formats(uint32_t **formats, bufmgr = g_surface_bufmgr; - if (!bufmgr->backend->surface_supported_format) - goto fail; + if (bufmgr->backend_module_data) { + if (!bufmgr->bufmgr_func->bufmgr_get_supported_formats) + goto fail; - ret = bufmgr->backend->surface_supported_format(formats, num); - if (!ret) { - /* LCOV_EXCL_START */ - TBM_ERR("Fail to surface_supported_format.\n"); - goto fail; - /* LCOV_EXCL_START */ + error = bufmgr->bufmgr_func->bufmgr_get_supported_formats(bufmgr->bufmgr_data, formats, num); + if (error != TBM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TBM_ERR("Fail to surface_supported_format. error(%d)\n", error); + goto fail; + /* LCOV_EXCL_START */ + } + ret = 1; + } else { + if (!bufmgr->backend->surface_supported_format) + goto fail; + + ret = bufmgr->backend->surface_supported_format(formats, num); + if (!ret) { + /* LCOV_EXCL_START */ + TBM_ERR("Fail to surface_supported_format.\n"); + goto fail; + /* LCOV_EXCL_START */ + } } TBM_TRACE_SURFACE_INTERNAL("tbm_bufmgr(%p) format num(%u)\n", g_surface_bufmgr, *num); @@ -648,7 +679,7 @@ tbm_surface_internal_create_with_flags(int width, int height, TBM_RETURN_VAL_IF_FAIL(width > 0, NULL); TBM_RETURN_VAL_IF_FAIL(height > 0, NULL); - struct _tbm_bufmgr *mgr; + struct _tbm_bufmgr *bufmgr; struct _tbm_surface *surf = NULL; uint32_t size = 0; uint32_t offset = 0; @@ -657,6 +688,10 @@ tbm_surface_internal_create_with_flags(int width, int height, int bo_idx; int i, j; bool bufmgr_initialized = false; + tbm_bo bo = NULL; + void *bo_priv = NULL; + tbm_backend_bo_data *bo_data = NULL; + tbm_error_e error; _tbm_surface_mutex_lock(); @@ -666,8 +701,8 @@ tbm_surface_internal_create_with_flags(int width, int height, bufmgr_initialized = true; } - mgr = g_surface_bufmgr; - if (!TBM_BUFMGR_IS_VALID(mgr)) { + bufmgr = g_surface_bufmgr; + if (!TBM_BUFMGR_IS_VALID(bufmgr)) { TBM_ERR("The bufmgr is invalid\n"); goto check_valid_fail; } @@ -680,7 +715,7 @@ tbm_surface_internal_create_with_flags(int width, int height, /* LCOV_EXCL_STOP */ } - surf->bufmgr = mgr; + surf->bufmgr = bufmgr; surf->info.width = width; surf->info.height = height; surf->info.format = format; @@ -720,46 +755,84 @@ tbm_surface_internal_create_with_flags(int width, int height, bo_size += surf->info.planes[j].size; } - if (mgr->backend->surface_bo_alloc) { - /* LCOV_EXCL_START */ - tbm_bo bo = NULL; - void *bo_priv = NULL; + if (bufmgr->backend_module_data) { + if (bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format) { + /* LCOV_EXCL_START */ + bo = calloc(1, sizeof(struct _tbm_bo)); + if (!bo) { + TBM_ERR("fail to alloc bo struct\n"); + goto alloc_bo_fail; + } - bo = calloc(1, sizeof(struct _tbm_bo)); - if (!bo) { - TBM_ERR("fail to alloc bo struct\n"); - goto alloc_bo_fail; - } + bo->bufmgr = surf->bufmgr; - bo->bufmgr = surf->bufmgr; + pthread_mutex_lock(&surf->bufmgr->lock); - pthread_mutex_lock(&surf->bufmgr->lock); + bo_data = bufmgr->bufmgr_func->bufmgr_alloc_bo_with_format(bufmgr->bufmgr_data, format, i, + width, height, flags, &error); + if (!bo_data) { + TBM_ERR("fail to alloc bo priv. error(%d)\n", error); + free(bo); + pthread_mutex_unlock(&surf->bufmgr->lock); + goto alloc_bo_fail; + } + bo->bo_data = bo_data; + + bo->ref_cnt = 1; + bo->flags = flags; + LIST_INITHEAD(&bo->user_data_list); + + LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list); - bo_priv = mgr->backend->surface_bo_alloc(bo, width, height, format, flags, i); - if (!bo_priv) { - TBM_ERR("fail to alloc bo priv\n"); - free(bo); pthread_mutex_unlock(&surf->bufmgr->lock); - goto alloc_bo_fail; + + surf->bos[i] = bo; + /* LCOV_EXCL_STOP */ + } else { + surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags); + if (!surf->bos[i]) { + TBM_ERR("fail to alloc bo idx:%d\n", i); + goto alloc_bo_fail; + } } + } else { + if (bufmgr->backend->surface_bo_alloc) { + /* LCOV_EXCL_START */ + bo = calloc(1, sizeof(struct _tbm_bo)); + if (!bo) { + TBM_ERR("fail to alloc bo struct\n"); + goto alloc_bo_fail; + } - bo->ref_cnt = 1; - bo->flags = flags; - bo->priv = bo_priv; + bo->bufmgr = surf->bufmgr; - LIST_INITHEAD(&bo->user_data_list); + pthread_mutex_lock(&surf->bufmgr->lock); - LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list); + bo_priv = bufmgr->backend->surface_bo_alloc(bo, width, height, format, flags, i); + if (!bo_priv) { + TBM_ERR("fail to alloc bo priv\n"); + free(bo); + pthread_mutex_unlock(&surf->bufmgr->lock); + goto alloc_bo_fail; + } + bo->priv = bo_priv; - pthread_mutex_unlock(&surf->bufmgr->lock); + bo->ref_cnt = 1; + bo->flags = flags; + LIST_INITHEAD(&bo->user_data_list); - surf->bos[i] = bo; - /* LCOV_EXCL_STOP */ - } else { - surf->bos[i] = tbm_bo_alloc(mgr, bo_size, flags); - if (!surf->bos[i]) { - TBM_ERR("fail to alloc bo idx:%d\n", i); - goto alloc_bo_fail; + LIST_ADD(&bo->item_link, &surf->bufmgr->bo_list); + + pthread_mutex_unlock(&surf->bufmgr->lock); + + surf->bos[i] = bo; + /* LCOV_EXCL_STOP */ + } else { + surf->bos[i] = tbm_bo_alloc(bufmgr, bo_size, flags); + if (!surf->bos[i]) { + TBM_ERR("fail to alloc bo idx:%d\n", i); + goto alloc_bo_fail; + } } } @@ -772,7 +845,7 @@ tbm_surface_internal_create_with_flags(int width, int height, LIST_INITHEAD(&surf->user_data_list); LIST_INITHEAD(&surf->debug_data_list); - LIST_ADD(&surf->item_link, &mgr->surf_list); + LIST_ADD(&surf->item_link, &bufmgr->surf_list); _tbm_surface_mutex_unlock(); @@ -788,8 +861,8 @@ query_plane_data_fail: free(surf); alloc_surf_fail: check_valid_fail: - if (bufmgr_initialized && mgr) { - LIST_DELINIT(&mgr->surf_list); + if (bufmgr_initialized && bufmgr) { + LIST_DELINIT(&bufmgr->surf_list); _deinit_surface_bufmgr(); } _tbm_surface_mutex_unlock(); @@ -812,7 +885,7 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, TBM_RETURN_VAL_IF_FAIL(num > 0, NULL); TBM_RETURN_VAL_IF_FAIL(num == 1 || info->num_planes == num, NULL); - struct _tbm_bufmgr *mgr; + struct _tbm_bufmgr *bufmgr; struct _tbm_surface *surf = NULL; int i; bool bufmgr_initialized = false; @@ -825,8 +898,8 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, bufmgr_initialized = true; } - mgr = g_surface_bufmgr; - if (!TBM_BUFMGR_IS_VALID(mgr)) { + bufmgr = g_surface_bufmgr; + if (!TBM_BUFMGR_IS_VALID(bufmgr)) { TBM_ERR("fail to validate the Bufmgr.\n"); goto check_valid_fail; } @@ -839,7 +912,7 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, /* LCOV_EXCL_STOP */ } - surf->bufmgr = mgr; + surf->bufmgr = bufmgr; surf->info.width = info->width; surf->info.height = info->height; surf->info.format = info->format; @@ -899,7 +972,7 @@ tbm_surface_internal_create_with_bos(tbm_surface_info_s *info, LIST_INITHEAD(&surf->user_data_list); LIST_INITHEAD(&surf->debug_data_list); - LIST_ADD(&surf->item_link, &mgr->surf_list); + LIST_ADD(&surf->item_link, &bufmgr->surf_list); _tbm_surface_mutex_unlock(); @@ -914,8 +987,8 @@ check_bo_fail: free(surf); alloc_surf_fail: check_valid_fail: - if (bufmgr_initialized && mgr) { - LIST_DELINIT(&mgr->surf_list); + if (bufmgr_initialized && bufmgr) { + LIST_DELINIT(&bufmgr->surf_list); _deinit_surface_bufmgr(); } _tbm_surface_mutex_unlock();