summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangyeon Lee <cyeon.lee@samsung.com>2016-05-02 16:16:23 +0900
committerChangyeon Lee <cyeon.lee@samsung.com>2016-05-02 16:16:32 +0900
commit2f7a24673d8fb7f95de30588da552457a034d166 (patch)
treedb3bf952763304807f26d87b7bfe3d1e7882a7ba
parent3d1b94d07f1e5a309ac0dcbb838773f06604941b (diff)
downloadlibtbm-2f7a24673d8fb7f95de30588da552457a034d166.tar.gz
libtbm-2f7a24673d8fb7f95de30588da552457a034d166.tar.bz2
libtbm-2f7a24673d8fb7f95de30588da552457a034d166.zip
Change static function to internal API for checking surface is valid
Change-Id: I12a0d30b0f22f6f4ae0930eedcba9d013b92eaee
-rw-r--r--src/tbm_surface.c14
-rwxr-xr-xsrc/tbm_surface_internal.c70
-rwxr-xr-xsrc/tbm_surface_internal.h8
3 files changed, 50 insertions, 42 deletions
diff --git a/src/tbm_surface.c b/src/tbm_surface.c
index e169dec..669f2e3 100644
--- a/src/tbm_surface.c
+++ b/src/tbm_surface.c
@@ -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
diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c
index de7c2a3..5fec104 100755
--- a/src/tbm_surface_internal.c
+++ b/src/tbm_surface_internal.c
@@ -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)
{
@@ -294,6 +277,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;
diff --git a/src/tbm_surface_internal.h b/src/tbm_surface_internal.h
index 083ef36..d995d27 100755
--- a/src/tbm_surface_internal.h
+++ b/src/tbm_surface_internal.h
@@ -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