tbm_surface: Clean up code 42/319842/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 18 Feb 2025 06:17:41 +0000 (15:17 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 20 Feb 2025 02:18:55 +0000 (11:18 +0900)
Change-Id: I8542a7e9ea1da1da361be98be1c477f85678c574

src/tbm_surface.c

index cf43a4e05bdd04205c5c6f008de99dfc8c60eb36..917b4055d9ae726f9de882468013b0ef9ac85b0a 100644 (file)
@@ -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);
 }