From: Changyeon Lee Date: Thu, 4 Feb 2016 12:52:03 +0000 (+0900) Subject: Move user data code to tbm_bufmgr X-Git-Tag: accepted/tizen/ivi/20160218.024517~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19e00e6a0ffb4a4a08ccbfbe1a63aeaf12e47c6f;p=platform%2Fcore%2Fuifw%2Flibtbm.git Move user data code to tbm_bufmgr Change-Id: If64862dc9c25151a78ee44db5294d03fbeae9ef1 Signed-off-by: Changyeon Lee --- diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index 1d5f1ef..7916afe 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -36,7 +36,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tbm_bufmgr_backend.h" #include "tbm_bufmgr_tgl.h" #include "list.h" -#include "tbm_user_data.h" #define DEBUG #ifdef DEBUG @@ -245,6 +244,49 @@ static inline unsigned int _tgl_get_data(int fd, unsigned int key, unsigned int return arg.data1; } + +tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key) +{ + tbm_user_data *user_data = NULL; + tbm_user_data *old_data = NULL, *tmp = NULL; + + if (!LIST_IS_EMPTY(user_data_list)) { + LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, user_data_list, item_link) { + if (old_data->key == key) { + user_data = old_data; + return user_data; + } + } + } + + return user_data; +} + +tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func) +{ + tbm_user_data *user_data = NULL; + + user_data = calloc(1, sizeof(tbm_user_data)); + if (!user_data) + return NULL; + + user_data->key = key; + user_data->free_func = data_free_func; + user_data->data = (void *)0; + + return user_data; +} + +void user_data_delete(tbm_user_data * user_data) +{ + if (user_data->data && user_data->free_func) + user_data->free_func(user_data->data); + + LIST_DEL(&user_data->item_link); + + free(user_data); +} + static int _bo_lock(tbm_bo bo, int device, int opt) { tbm_bufmgr bufmgr = bo->bufmgr; diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index c78207b..8c7ad56 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -201,6 +201,15 @@ struct _tbm_surface { struct list_head user_data_list; /* list of the user_date in surface */ }; +typedef struct { + unsigned long key; + void *data; + tbm_data_free free_func; + + /* link of user_data */ + struct list_head item_link; +} tbm_user_data; + int tbm_bufmgr_get_drm_fd_x11(void); int tbm_bufmgr_get_drm_fd_wayland(void); @@ -215,4 +224,8 @@ tbm_format tbm_surface_internal_get_format(tbm_surface_h surface); unsigned int _tbm_surface_internal_get_debug_pid(tbm_surface_h surface); char * _tbm_surface_internal_format_to_str(tbm_format format); +tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key); +tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func); +void user_data_delete(tbm_user_data * user_data); + #endif /* _TBM_BUFMGR_INT_H_ */ diff --git a/src/tbm_surface_internal.c b/src/tbm_surface_internal.c index 30e235f..a444dce 100644 --- a/src/tbm_surface_internal.c +++ b/src/tbm_surface_internal.c @@ -34,7 +34,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tbm_bufmgr_int.h" #include "tbm_surface_internal.h" #include "list.h" -#include "tbm_user_data.h" static tbm_bufmgr g_surface_bufmgr = NULL; static pthread_mutex_t tbm_surface_lock; diff --git a/src/tbm_user_data.c b/src/tbm_user_data.c deleted file mode 100644 index 0ae9ba9..0000000 --- a/src/tbm_user_data.c +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************** - -libtbm - -Copyright 2014 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee -Boram Park , Changyeon Lee - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -#include "config.h" -#include "tbm_user_data.h" - -tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key) -{ - tbm_user_data *user_data = NULL; - tbm_user_data *old_data = NULL, *tmp = NULL; - - if (!LIST_IS_EMPTY(user_data_list)) { - LIST_FOR_EACH_ENTRY_SAFE(old_data, tmp, user_data_list, item_link) { - if (old_data->key == key) { - user_data = old_data; - return user_data; - } - } - } - - return user_data; -} - -tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func) -{ - tbm_user_data *user_data = NULL; - - user_data = calloc(1, sizeof(tbm_user_data)); - if (!user_data) - return NULL; - - user_data->key = key; - user_data->free_func = data_free_func; - user_data->data = (void *)0; - - return user_data; -} - -void user_data_delete(tbm_user_data * user_data) -{ - if (user_data->data && user_data->free_func) - user_data->free_func(user_data->data); - - LIST_DEL(&user_data->item_link); - - free(user_data); -} - diff --git a/src/tbm_user_data.h b/src/tbm_user_data.h deleted file mode 100644 index 9d6986e..0000000 --- a/src/tbm_user_data.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************** - -libtbm - -Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: SooChan Lim , Sangjin Lee -Boram Park , Changyeon Lee - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -#ifndef _TBM_USER_DATA_H_ -#define _TBM_USER_DATA_H_ - -#ifdef __cplusplus -extern "C" { -#endif -typedef struct { - unsigned long key; - void *data; - tbm_data_free free_func; - - /* link of user_data */ - struct list_head item_link; -} tbm_user_data; - -tbm_user_data *user_data_lookup(struct list_head *user_data_list, unsigned long key); -tbm_user_data *user_data_create(unsigned long key, tbm_data_free data_free_func); -void user_data_delete(tbm_user_data * user_data); - -#ifdef __cplusplus -} -#endif -#endif /* _TBM_USER_DATA_H_ */ -