surface: add _tbm_set_last_result() 92/177192/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 24 Apr 2018 12:23:53 +0000 (21:23 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 25 Apr 2018 05:01:11 +0000 (14:01 +0900)
Change-Id: Ie53550bd938ba4ad379b165a1c4852143d556ec7

src/tbm_surface.c

index 1ca367e..07cf55a 100644 (file)
@@ -41,7 +41,7 @@ tbm_surface_query_formats(uint32_t **formats, uint32_t *num)
        TBM_TRACE_SURFACE("\n");
 
        if (!tbm_surface_internal_query_supported_formats(formats, num))
-               return TBM_SURFACE_ERROR_INVALID_OPERATION;
+               return tbm_get_last_error();
 
        return TBM_SURFACE_ERROR_NONE;
 }
@@ -51,10 +51,13 @@ tbm_surface_create(int width, int height, tbm_format format)
 {
        TBM_TRACE_SURFACE("width(%d) height(%d)\n", width, height);
 
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
        if (!(width > 0) || !(height > 0)) {
 #ifdef HAVE_CAPI_0_1_1
                set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
 #endif
+               _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER);
                return NULL;
        }
 
@@ -68,9 +71,11 @@ tbm_surface_create(int width, int height, tbm_format format)
 #endif
                return NULL;
        }
+
 #ifdef HAVE_CAPI_0_1_1
        set_last_result(TBM_SURFACE_ERROR_NONE);
 #endif
+
        return surf;
 }
 
@@ -83,7 +88,7 @@ tbm_surface_destroy(tbm_surface_h surface)
 
        tbm_surface_internal_destroy(surface);
 
-       return TBM_SURFACE_ERROR_NONE;
+       return tbm_get_last_error();
 }
 
 int
@@ -98,7 +103,7 @@ tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
 
        ret = tbm_surface_internal_get_info(surface, opt, info, 1);
        if (ret == 0)
-               return TBM_SURFACE_ERROR_INVALID_OPERATION;
+               return tbm_get_last_error();
 
        return TBM_SURFACE_ERROR_NONE;
 }
@@ -112,7 +117,7 @@ tbm_surface_unmap(tbm_surface_h surface)
 
        tbm_surface_internal_unmap(surface);
 
-       return TBM_SURFACE_ERROR_NONE;
+       return tbm_get_last_error();
 }
 
 int
@@ -127,7 +132,7 @@ tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
 
        ret = tbm_surface_internal_get_info(surface, 0, info, 0);
        if (ret == 0)
-               return TBM_SURFACE_ERROR_INVALID_OPERATION;
+               return tbm_get_last_error();
 
        return TBM_SURFACE_ERROR_NONE;
 }
@@ -137,7 +142,19 @@ tbm_surface_get_width(tbm_surface_h surface)
 {
        TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
-       TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
+       if (!surface) {
+#ifdef HAVE_CAPI_0_1_1
+               set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
+#endif
+               _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_width(surface);
 }
@@ -147,7 +164,19 @@ tbm_surface_get_height(tbm_surface_h surface)
 {
        TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
-       TBM_RETURN_VAL_IF_FAIL(surface, TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
+       if (!surface) {
+#ifdef HAVE_CAPI_0_1_1
+               set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
+#endif
+               _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_height(surface);
 }
@@ -157,14 +186,19 @@ tbm_surface_get_format(tbm_surface_h surface)
 {
        TBM_TRACE_SURFACE("tbm_surface(%p)\n", surface);
 
+       _tbm_set_last_result(TBM_ERROR_NONE);
+
        if (!surface) {
 #ifdef HAVE_CAPI_0_1_1
                set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
 #endif
+               _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);
 }