Change static function to internal API for checking surface is valid 92/68092/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 2 May 2016 07:16:23 +0000 (16:16 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Mon, 2 May 2016 07:16:32 +0000 (16:16 +0900)
Change-Id: I12a0d30b0f22f6f4ae0930eedcba9d013b92eaee

src/tbm_surface.c
src/tbm_surface_internal.c
src/tbm_surface_internal.h

index e169deca3d2e2b0b416ebfc5a9a558f7fff9ab7c..669f2e33177efc14964124bc72484e2e0f72424c 100644 (file)
@@ -72,7 +72,7 @@ tbm_surface_create(int width, int height, tbm_format format)
 int
 tbm_surface_destroy(tbm_surface_h surface)
 {
-       if (!_tbm_surface_is_valid(surface))
+       if (!tbm_surface_internal_is_valid(surface))
                return TBM_SURFACE_ERROR_INVALID_PARAMETER;
 
        tbm_surface_internal_destroy(surface);
@@ -83,7 +83,7 @@ tbm_surface_destroy(tbm_surface_h surface)
 int
 tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
        int ret = 0;
@@ -98,7 +98,7 @@ tbm_surface_map(tbm_surface_h surface, int opt, tbm_surface_info_s *info)
 int
 tbm_surface_unmap(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
        tbm_surface_internal_unmap(surface);
 
@@ -108,7 +108,7 @@ tbm_surface_unmap(tbm_surface_h surface)
 int
 tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
        TBM_RETURN_VAL_IF_FAIL(info != NULL, TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
        int ret = 0;
@@ -123,7 +123,7 @@ tbm_surface_get_info(tbm_surface_h surface, tbm_surface_info_s *info)
 int
 tbm_surface_get_width(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
        return tbm_surface_internal_get_width(surface);
 }
@@ -131,7 +131,7 @@ tbm_surface_get_width(tbm_surface_h surface)
 int
 tbm_surface_get_height(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), TBM_SURFACE_ERROR_INVALID_PARAMETER);
 
        return tbm_surface_internal_get_height(surface);
 }
@@ -139,7 +139,7 @@ tbm_surface_get_height(tbm_surface_h surface)
 tbm_format
 tbm_surface_get_format(tbm_surface_h surface)
 {
-       if (!_tbm_surface_is_valid(surface)) {
+       if (!tbm_surface_internal_is_valid(surface)) {
 #ifdef HAVE_CAPI_0_1_1
                set_last_result(TBM_SURFACE_ERROR_INVALID_PARAMETER);
 #endif
index de7c2a348fa6f1d11c26b554ab9033ed8bf4ff69..5fec104036ba24d1828c4cad14734bfbf9045f71 100755 (executable)
@@ -39,23 +39,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 static tbm_bufmgr g_surface_bufmgr;
 static pthread_mutex_t tbm_surface_lock;
 
-int
-_tbm_surface_is_valid(tbm_surface_h surface)
-{
-       tbm_surface_h old_data = NULL, tmp = NULL;
-
-       if (surface == NULL || g_surface_bufmgr == NULL)
-               return 0;
-
-       if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
-               LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &g_surface_bufmgr->surf_list, item_link) {
-                       if (old_data == surface)
-                               return 1;
-               }
-       }
-       return 0;
-}
-
 char *
 _tbm_surface_internal_format_to_str(tbm_format format)
 {
@@ -293,6 +276,23 @@ _tbm_surface_internal_destroy(tbm_surface_h surface)
        }
 }
 
+int
+tbm_surface_internal_is_valid(tbm_surface_h surface)
+{
+       tbm_surface_h old_data = NULL, tmp = NULL;
+
+       if (surface == NULL || g_surface_bufmgr == NULL)
+               return 0;
+
+       if (!LIST_IS_EMPTY(&g_surface_bufmgr->surf_list)) {
+               LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, &g_surface_bufmgr->surf_list, item_link) {
+                       if (old_data == surface)
+                               return 1;
+               }
+       }
+       return 0;
+}
+
 int
 tbm_surface_internal_query_supported_formats(uint32_t **formats,
                uint32_t *num)
@@ -748,7 +748,7 @@ bail1:
 void
 tbm_surface_internal_destroy(tbm_surface_h surface)
 {
-       if (!_tbm_surface_is_valid(surface))
+       if (!tbm_surface_internal_is_valid(surface))
                return;
 
        _tbm_surface_mutex_lock();
@@ -769,7 +769,7 @@ tbm_surface_internal_destroy(tbm_surface_h surface)
 void
 tbm_surface_internal_ref(tbm_surface_h surface)
 {
-       TBM_RETURN_IF_FAIL(_tbm_surface_is_valid(surface));
+       TBM_RETURN_IF_FAIL(tbm_surface_internal_is_valid(surface));
 
        _tbm_surface_mutex_lock();
 
@@ -781,7 +781,7 @@ tbm_surface_internal_ref(tbm_surface_h surface)
 void
 tbm_surface_internal_unref(tbm_surface_h surface)
 {
-       TBM_RETURN_IF_FAIL(_tbm_surface_is_valid(surface));
+       TBM_RETURN_IF_FAIL(tbm_surface_internal_is_valid(surface));
 
        _tbm_surface_mutex_lock();
 
@@ -801,7 +801,7 @@ tbm_surface_internal_unref(tbm_surface_h surface)
 int
 tbm_surface_internal_get_num_bos(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        int num;
@@ -819,7 +819,7 @@ tbm_surface_internal_get_num_bos(tbm_surface_h surface)
 tbm_bo
 tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), NULL);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), NULL);
        TBM_RETURN_VAL_IF_FAIL(bo_idx > -1, NULL);
 
        struct _tbm_surface *surf;
@@ -838,7 +838,7 @@ tbm_surface_internal_get_bo(tbm_surface_h surface, int bo_idx)
 int
 tbm_surface_internal_get_size(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        unsigned int size;
@@ -857,7 +857,7 @@ int
 tbm_surface_internal_get_plane_data(tbm_surface_h surface, int plane_idx,
                                    uint32_t *size, uint32_t *offset, uint32_t *pitch)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
        TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
 
        struct _tbm_surface *surf;
@@ -889,7 +889,7 @@ int
 tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
                              tbm_surface_info_s *info, int map)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        tbm_bo_handle bo_handles[4];
@@ -943,7 +943,7 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
 void
 tbm_surface_internal_unmap(tbm_surface_h surface)
 {
-       TBM_RETURN_IF_FAIL(_tbm_surface_is_valid(surface));
+       TBM_RETURN_IF_FAIL(tbm_surface_internal_is_valid(surface));
 
        struct _tbm_surface *surf;
        int i;
@@ -961,7 +961,7 @@ tbm_surface_internal_unmap(tbm_surface_h surface)
 unsigned int
 tbm_surface_internal_get_width(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        unsigned int width;
@@ -979,7 +979,7 @@ tbm_surface_internal_get_width(tbm_surface_h surface)
 unsigned int
 tbm_surface_internal_get_height(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        unsigned int height;
@@ -998,7 +998,7 @@ tbm_surface_internal_get_height(tbm_surface_h surface)
 tbm_format
 tbm_surface_internal_get_format(tbm_surface_h surface)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        struct _tbm_surface *surf;
        tbm_format format;
@@ -1016,7 +1016,7 @@ tbm_surface_internal_get_format(tbm_surface_h surface)
 int
 tbm_surface_internal_get_plane_bo_idx(tbm_surface_h surface, int plane_idx)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
        TBM_RETURN_VAL_IF_FAIL(plane_idx > -1, 0);
        struct _tbm_surface *surf;
        int bo_idx;
@@ -1042,7 +1042,7 @@ _tbm_surface_internal_get_debug_pid(tbm_surface_h surface)
 void
 tbm_surface_internal_set_debug_pid(tbm_surface_h surface, unsigned int pid)
 {
-       TBM_RETURN_IF_FAIL(_tbm_surface_is_valid(surface));
+       TBM_RETURN_IF_FAIL(tbm_surface_internal_is_valid(surface));
 
        surface->debug_pid = pid;
 }
@@ -1051,7 +1051,7 @@ int
 tbm_surface_internal_add_user_data(tbm_surface_h surface, unsigned long key,
                                   tbm_data_free data_free_func)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        tbm_user_data *data;
 
@@ -1077,7 +1077,7 @@ int
 tbm_surface_internal_set_user_data(tbm_surface_h surface, unsigned long key,
                                   void *data)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        tbm_user_data *old_data;
 
@@ -1100,7 +1100,7 @@ int
 tbm_surface_internal_get_user_data(tbm_surface_h surface, unsigned long key,
                                   void **data)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        tbm_user_data *old_data;
 
@@ -1122,7 +1122,7 @@ int
 tbm_surface_internal_delete_user_data(tbm_surface_h surface,
                                      unsigned long key)
 {
-       TBM_RETURN_VAL_IF_FAIL(_tbm_surface_is_valid(surface), 0);
+       TBM_RETURN_VAL_IF_FAIL(tbm_surface_internal_is_valid(surface), 0);
 
        tbm_user_data *old_data = (void *)0;
 
index 083ef36913992b766a7424295ed4d4115db85340..d995d27e7dc0a616978acded372e85b3227e36ec 100755 (executable)
@@ -433,6 +433,14 @@ void tbm_surface_internal_dump_end(void);
  */
 void tbm_internal_surface_dump_buffer(tbm_surface_h surface, const char *type);
 
+/**
+ * @brief check valid tbm surface.
+ * @since_tizen 3.0
+ * @param[in] surface : the tbm surface.
+ * @return 1 if surface is valid, otherwise 0.
+ */
+int tbm_surface_internal_is_valid(tbm_surface_h surface);
+
 #ifdef __cplusplus
 }
 #endif