From 1c03dd4474f269b51f60d5a22b4c2056ef51b5b1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 15 Jun 2021 17:46:19 +0900 Subject: [PATCH] tbm_module: make tbm_module_bufmgr_get_plane_data encapsulate the bufmgr_get_plane_data with this function. Change-Id: I8eb465b3a72e1831c0e46ca14e020fdc4af5e971 --- src/tbm_bufmgr_int.h | 1 + src/tbm_module.c | 43 ++++++++++++++++++++++++++++++++++++++ src/tbm_surface_internal.c | 52 +++++----------------------------------------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index b231cab..2021f3b 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -356,6 +356,7 @@ void tbm_module_unload(tbm_module *module); int tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error); tbm_error_e tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display); tbm_error_e tbm_module_bufmgr_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num); +tbm_error_e tbm_module_bufmgr_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h, uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx); 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 *tbm_module_bufmgr_bo_alloc_with_format(tbm_module *module, int format, int bo_idx, int width, int height, int bpp, tbm_bo_memory_type flags, tbm_error_e *error); diff --git a/src/tbm_module.c b/src/tbm_module.c index 96beb2f..6c9fd87 100644 --- a/src/tbm_module.c +++ b/src/tbm_module.c @@ -601,6 +601,49 @@ tbm_module_bufmgr_get_supported_formats(tbm_module *module, uint32_t **formats, return error; } +tbm_error_e +tbm_module_bufmgr_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h, + uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx) +{ + tbm_error_e error = TBM_ERROR_NONE; + tbm_backend_bufmgr_func *bufmgr_func = NULL; + tbm_bufmgr_backend backend = NULL; + int ret = 0; + + TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER); + + switch (module->type) { + case TBM_MODULE_TYPE_HAL_TBM: + error = (tbm_error_e)hal_tbm_bufmgr_get_plane_data(module->hal_bufmgr, format, plane_idx, w, h, size, offset, pitch, bo_idx); + break; +/* LCOV_EXCL_START */ + case TBM_MODULE_TYPE_TBM_BACKEND: + bufmgr_func = module->bufmgr_func; + TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_plane_data, TBM_ERROR_NOT_SUPPORTED); + + error = bufmgr_func->bufmgr_get_plane_data(module->bufmgr_data, format, plane_idx, w, h, size, offset, pitch, bo_idx); + 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_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION); + TBM_RETURN_VAL_IF_FAIL(backend->surface_get_plane_data, TBM_ERROR_NOT_SUPPORTED); + + ret = backend->surface_get_plane_data(w, h, format, plane_idx, size, offset, pitch, bo_idx); + if (!ret) + error = TBM_ERROR_INVALID_OPERATION; + break; + default: + TBM_ERR("Wrong module type:%d", module->type); + error = TBM_ERROR_INVALID_OPERATION; + break; +/* LCOV_EXCL_STOP */ + } + + return error; +} + tbm_backend_bo_data * tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error) { diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 3f292d7..b85363b 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -320,7 +320,6 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface, struct _tbm_surface *surf = (struct _tbm_surface *)surface; struct _tbm_bufmgr *bufmgr = surf->bufmgr; - int ret = 0; tbm_error_e error; TBM_RETURN_VAL_IF_FAIL(bufmgr != NULL, 0); @@ -328,54 +327,13 @@ _tbm_surface_internal_query_plane_data(tbm_surface_h surface, TBM_RETURN_VAL_IF_FAIL(surf->info.height > 0, 0); TBM_RETURN_VAL_IF_FAIL(surf->info.format > 0, 0); - if (bufmgr->use_hal_tbm) { - error = (tbm_error_e)hal_tbm_bufmgr_get_plane_data(bufmgr->hal_bufmgr, (hal_tbm_format)surf->info.format, - plane_idx, surf->info.width, surf->info.height, size, offset, pitch, bo_idx); - /* LCOV_EXCL_START */ - if (error == TBM_ERROR_NOT_SUPPORTED) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - return 0; - } else if (error != TBM_ERROR_NONE) { - TBM_ERR("Fail to surface_get_plane_data. surface(%p) error(%d)\n", surface, error); - _tbm_set_last_result(error); - return 0; - } - /* LCOV_EXCL_STOP */ - ret = 1; - } else if (bufmgr->backend_module_data) { - if (!bufmgr->bufmgr_func->bufmgr_get_plane_data) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - return 0; - } - - 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); - _tbm_set_last_result(error); - return 0; - /* LCOV_EXCL_STOP */ - } - ret = 1; - } else { - if (!bufmgr->backend->surface_get_plane_data) { - _tbm_set_last_result(TBM_ERROR_NOT_SUPPORTED); - 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); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - return 0; - /* LCOV_EXCL_STOP */ - } + error = tbm_module_bufmgr_get_plane_data(bufmgr->module, surf->info.format, plane_idx, surf->info.width, surf->info.height, size, offset, pitch, bo_idx); + if (error != TBM_ERROR_NONE) { + _tbm_set_last_result(error); + return 0; } - return ret; + return 1; } static void -- 2.7.4