From 5ff66970b894d41cda5a0e9da194c22cecf52c8b Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 18 Feb 2025 15:17:41 +0900 Subject: [PATCH] tbm_surface: Clean up code Change-Id: I8542a7e9ea1da1da361be98be1c477f85678c574 --- src/tbm_surface.c | 55 ++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/tbm_surface.c b/src/tbm_surface.c index cf43a4e..917b405 100644 --- a/src/tbm_surface.c +++ b/src/tbm_surface.c @@ -35,6 +35,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tbm_bufmgr_int.h" #include "tbm_surface_internal.h" +void +_tbm_surface_set_last_result(tbm_surface_error_e err) +{ +#ifdef HAVE_CAPI_0_1_1 + set_last_result(err); +#endif +} + int tbm_surface_query_formats(uint32_t **formats, uint32_t *num) { @@ -52,11 +60,10 @@ tbm_surface_create(int width, int height, tbm_format format) TBM_TRACE_SURFACE("width(%d) height(%d)", width, height); _tbm_set_last_result(TBM_ERROR_NONE); + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_NONE); if (!(width > 0) || !(height > 0)) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); return NULL; } @@ -66,16 +73,10 @@ tbm_surface_create(int width, int height, tbm_format format) surf = tbm_surface_internal_create_with_flags(width, height, format, TBM_BO_DEFAULT); if (!surf) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_OPERATION); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_OPERATION); return NULL; } -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_NONE); -#endif - return surf; } @@ -145,27 +146,20 @@ tbm_surface_get_width(tbm_surface_h surface) int width = 0; _tbm_set_last_result(TBM_ERROR_NONE); + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_NONE); if (!surface) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); return TBM_SURFACE_ERROR_INVALID_PARAMETER; } width = tbm_surface_internal_get_width(surface); if (tbm_get_last_error() != TBM_ERROR_NONE) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); return TBM_SURFACE_ERROR_INVALID_PARAMETER; } -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_NONE); -#endif - return width; } @@ -177,27 +171,21 @@ tbm_surface_get_height(tbm_surface_h surface) int height = 0; _tbm_set_last_result(TBM_ERROR_NONE); + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_NONE); if (!surface) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); return TBM_SURFACE_ERROR_INVALID_PARAMETER; } height = tbm_surface_internal_get_height(surface); if (tbm_get_last_error() != TBM_ERROR_NONE) { -#ifdef HAVE_CAPI_0_1_1 + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif return TBM_SURFACE_ERROR_INVALID_PARAMETER; } -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_NONE); -#endif - return height; } @@ -207,18 +195,13 @@ tbm_surface_get_format(tbm_surface_h surface) TBM_TRACE_SURFACE("tbm_surface(%p)", surface); _tbm_set_last_result(TBM_ERROR_NONE); + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_NONE); if (!surface) { -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); -#endif + _tbm_surface_set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER); _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); return 0; } -#ifdef HAVE_CAPI_0_1_1 - set_last_result(TBM_SURFACE_ERROR_NONE); -#endif - return tbm_surface_internal_get_format(surface); } -- 2.34.1