From 37d3685ffff8645be11073128affd4f66e6565c1 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Mon, 3 Apr 2017 09:39:45 +0900 Subject: [PATCH 01/16] Fix memory leak Signed-off-by: seungha.son Change-Id: I81669725500ecf915feca52bbb303aa8cb55bea1 (cherry picked from commit 7dc3034997783c336c8fcaab761d4cfffa93a0e9) --- screen_connector_watcher_evas/src/screen_connector_watcher_evas.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 3f0eddc..0e4d177 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -231,18 +231,22 @@ static void __watcher_update_cb(struct tizen_remote_surface *trs, uint32_t type, EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, void *data) { - screen_connector_watcher_evas_h handle; screen_connector_watcher_evas_ops *evas_ops; screen_connector_watcher_ops *watcher_ops; watcher_ops = (screen_connector_watcher_ops *)calloc(1, sizeof(screen_connector_watcher_ops)); + if (watcher_ops == NULL) { + LOGE("watcher_ops calloc fail"); + return NULL; + } watcher_ops->added_cb = __watcher_added_cb; watcher_ops->updated_cb = __watcher_update_cb; watcher_ops->removed_cb = __watcher_removed_cb; evas_ops = (screen_connector_watcher_evas_ops *)calloc(1, sizeof(screen_connector_watcher_evas_ops)); if (evas_ops == NULL) { + free(watcher_ops); LOGE("evas_ops calloc fail"); return NULL; } @@ -251,6 +255,7 @@ EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(scr handle = (screen_connector_watcher_evas_h)calloc(1, sizeof(struct _screen_connector_watcher_evas_h)); if (handle == NULL) { LOGE("handle calloc fail"); + free(watcher_ops); free(evas_ops); return NULL; } @@ -259,7 +264,6 @@ EXPORT_API screen_connector_watcher_evas_h screen_connector_watcher_evas_add(scr handle->watcher_h = screen_connector_watcher_add(watcher_ops, handle); return handle; - } static void __destroy_watcher_evas_handle(screen_connector_watcher_evas_h watcher_evas_h) -- 2.7.4 From 197eb51514caf094a9dacfeb356e00c633543c36 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 3 Apr 2017 10:27:59 +0900 Subject: [PATCH 02/16] Fix memory leak Change-Id: Ie3ff7bcbb7340b1e6336e19ad5b2e1ab667dda0e Signed-off-by: Hyunho Kang (cherry picked from commit 0b07eb5a3e067f73857aae585ac369433ad8e1fa) --- screen_connector_watcher/src/screen_connector_watcher.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index 36df1d9..02bd07b 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -206,6 +206,9 @@ static void __destroy_watcher_h(screen_connector_watcher_h handle) if (!handle) return; + if (handle->ops) + free(handle->ops); + if (handle->aul_handle) aul_screen_connector_remove_screen_viewer(handle->aul_handle); -- 2.7.4 From e92ecd43a72a70a48a57653bc4d979a2d8d5ef0b Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Wed, 12 Apr 2017 20:39:40 +0900 Subject: [PATCH 03/16] Make widget work. The data of '___PLUGID' key is used on accessibility environment. A widget process window such as 'Alarm Widget' on wearable is using same data. Becase the widget process could make more than one window, the data should be the instance ID, NOT the application ID to separate thoes windows. Change-Id: I2ee38bc57128b4c6497111b1628183512ed9e0f2 --- screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 5a78547..ea1d1ad 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -454,7 +454,7 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, g_hash_table_insert(toolkit_evas_h->type_h->toolkit_table, toolkit_evas_h->img_tbm, toolkit_evas_h); /* Set data to use in accessibility */ - snprintf(plug_id, sizeof(plug_id), "%s:%d", appid, pid); + snprintf(plug_id, sizeof(plug_id), "%s:%d", instance_id, pid); evas_object_data_set(toolkit_evas_h->img_tbm, "___PLUGID", strdup(plug_id)); evas_object_event_callback_add(toolkit_evas_h->img_tbm, EVAS_CALLBACK_MOVE, __obj_update_visibility, toolkit_evas_h); -- 2.7.4 From bdd46fd18e3e1ea115c7da869cf1b88655cf9020 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 18 Apr 2017 20:24:13 +0900 Subject: [PATCH 04/16] Add bind surface APIs - screen_connector_toolkit_add_with_surface - screen_connector_toolkit_evas_add_with_win Change-Id: I375e74a3a6b26da81befff3109987fc9b9a32234 Signed-off-by: Hyunho Kang (cherry picked from commit e4674c573afede712f7f0b92afefaae90dd46e73) --- .../include/screen_connector_toolkit.h | 2 + .../src/screen_connector_toolkit.c | 61 +++++++++++++++++++++ .../include/screen_connector_toolkit_evas.h | 3 ++ .../src/screen_connector_toolkit_evas.c | 62 ++++++++++++++++++++++ 4 files changed, 128 insertions(+) diff --git a/screen_connector_watcher/include/screen_connector_toolkit.h b/screen_connector_watcher/include/screen_connector_toolkit.h index a5db07e..39968b1 100644 --- a/screen_connector_watcher/include/screen_connector_toolkit.h +++ b/screen_connector_watcher/include/screen_connector_toolkit.h @@ -78,6 +78,8 @@ screen_connector_toolkit_h screen_connector_toolkit_create_handle(char *id, int screen_connector_toolkit_ops *ops, void *data); struct tizen_remote_surface *screen_connector_toolkit_get_trs(screen_connector_toolkit_h h); int screen_connector_toolkit_redirect_surface(screen_connector_toolkit_h info); +screen_connector_toolkit_h screen_connector_toolkit_add_with_surface(screen_connector_toolkit_ops *ops, char *id, + screen_connector_screen_type_e type, struct wl_surface *surface, void *data); #ifdef __cplusplus } diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index 910d73f..3a36df2 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.c +++ b/screen_connector_watcher/src/screen_connector_toolkit.c @@ -52,6 +52,7 @@ struct _screen_connector_toolkit_h { struct tizen_remote_surface *surface; struct _screen_connector_type_h *type_h; void *data; + struct wl_surface *bind_surface; }; static GHashTable *__type_table; @@ -110,6 +111,9 @@ EXPORT_API int screen_connector_toolkit_redirect_surface(screen_connector_toolki tizen_remote_surface_add_listener(toolkit_h->surface, &__rs_listener, toolkit_h); tizen_remote_surface_redirect(toolkit_h->surface); + if (toolkit_h->bind_surface != NULL) + tizen_remote_surface_manager_bind_surface(rsm, toolkit_h->bind_surface, toolkit_h->surface); + return 0; } @@ -271,6 +275,63 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_create_handle(cha return toolkit_h; } +EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add_with_surface(screen_connector_toolkit_ops *ops, char *id, + screen_connector_screen_type_e type, struct wl_surface *surface, void *data) +{ + screen_connector_toolkit_h toolkit_h; + screen_connector_type_h type_h; + screen_connector_toolkit_ops *ops_copy; + + if (id == NULL || ops == NULL) { + LOGE("Invalid param"); + return NULL; + } + + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); + if (type_h == NULL) { + LOGE("type %d is not initialized !!", type); + return NULL; + } + + ops_copy = (screen_connector_toolkit_ops *)calloc(1, sizeof(screen_connector_toolkit_ops)); + if (ops_copy == NULL) { + LOGE("ops_copy calloc fail"); + return NULL; + } + memcpy(ops_copy, ops, sizeof(screen_connector_toolkit_ops)); + + toolkit_h = (screen_connector_toolkit_h)calloc(1, sizeof(struct _screen_connector_toolkit_h)); + if (toolkit_h == NULL) { + LOGE("toolkit_h calloc fail"); + free(ops_copy); + return NULL; + } + + toolkit_h->instance_id = strdup(id); + if (toolkit_h->instance_id == NULL) { + LOGE("strdup id fail"); + free(ops_copy); + free(toolkit_h); + return NULL; + } + + toolkit_h->data = data; + toolkit_h->ops = ops_copy; + toolkit_h->type_h = type_h; + toolkit_h->bind_surface = surface; + + if (type_h->toolkit_table == NULL) + type_h->toolkit_table = g_hash_table_new_full(g_str_hash, + g_str_equal, free, __destroy_toolkit_h); + + g_hash_table_insert(type_h->toolkit_table, strdup(id), toolkit_h); + + if (type_h->aul_handle == NULL) + aul_screen_connector_add_screen_viewer(__aul_screen_viewer_cb, type, true, type_h, &type_h->aul_handle); + + return toolkit_h; +} + EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add(screen_connector_toolkit_ops *ops, char *id, screen_connector_screen_type_e type, void *data) { diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index 1fb75f6..d0d4a89 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -105,6 +105,9 @@ int screen_connector_toolkit_evas_get_pid(Evas_Object *obj, int *pid); screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_by_rid(screen_connector_toolkit_evas_ops *ops, int res_id, screen_connector_screen_type_e type, void *data); int screen_connector_toolkit_evas_get_rid(Evas_Object *obj, int *resource_id); +screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_with_win(screen_connector_toolkit_evas_ops *ops, char *id, + screen_connector_screen_type_e type, Evas_Object *win, void *data); + /** * @} diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index ea1d1ad..ea8961a 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -581,6 +581,68 @@ static void __toolkit_removed_cb(const char *appid, const char *instance_id, con __free_toolkit_evas_h(toolkit_evas_h); } +EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_with_win(screen_connector_toolkit_evas_ops *ops, char *id, + screen_connector_screen_type_e type, Evas_Object *win, void *data) +{ + screen_connector_toolkit_evas_h handle; + screen_connector_toolkit_evas_ops *evas_ops; + screen_connector_toolkit_ops toolkit_ops; + screen_connector_type_evas_h type_h; + int int_type = type; + struct wl_surface *surface; + Ecore_Wl_Window *wl_win; + + if (win == NULL || ops == NULL || id == NULL + || type < SCREEN_CONNECTOR_SCREEEN_TYPE_WIDGET + || type > SCREEN_CONNECTOR_SCREEEN_TYPE_ALL) { + LOGE("Invalid param NULL"); + return NULL; + } + + wl_win = elm_win_wl_window_get(win); + if (wl_win == NULL) { + LOGE("failed to get wl_win"); + return NULL; + } + + surface = ecore_wl_window_surface_get(wl_win); + if (surface == NULL) { + LOGE("failed to get surface"); + return NULL; + } + + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(int_type)); + if (type_h == NULL) { + LOGE("type %d is not initialized !!", type); + return NULL; + } + + toolkit_ops.added_cb = __toolkit_added_cb; + toolkit_ops.updated_cb = NULL; + toolkit_ops.removed_cb = __toolkit_removed_cb; + + evas_ops = (screen_connector_toolkit_evas_ops *)calloc(1, sizeof(screen_connector_toolkit_evas_ops)); + if (evas_ops == NULL) { + LOGE("evas_ops calloc fail"); + return NULL; + } + + memcpy(evas_ops, ops, sizeof(screen_connector_toolkit_evas_ops)); + handle = (screen_connector_toolkit_evas_h)calloc(1, sizeof(struct _screen_connector_toolkit_evas_h)); + if (handle == NULL) { + LOGE("handle calloc fail"); + free(evas_ops); + return NULL; + } + handle->img_type = -1; + handle->ops = evas_ops; + handle->data = data; + handle->type_h = type_h; + handle->toolkit_h = screen_connector_toolkit_add_with_surface(&toolkit_ops, id, type, surface, handle); + + return handle; +} + EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add(screen_connector_toolkit_evas_ops *ops, char *id, screen_connector_screen_type_e type, void *data) { -- 2.7.4 From 9d6abe60aaeed93ca7dfc1f7a81ec093cc076b11 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 19 Apr 2017 14:05:53 +0900 Subject: [PATCH 05/16] Fix toolkit_table destroy bug screen_connector_toolkit_evas_fini is called remote surface is destroyed but screen_connector_toolkit_evas_h will not freed, so callback which have a screen_connector_toolkit_evas_h as a user data like __rs_cb_mouse_move callback could cause crash when they try to send event through already destroyed remote surface Change-Id: Ifda77fa1cb0244186179c7ffe2dc77b536593586 Signed-off-by: Hyunho Kang (cherry picked from commit e5b91194895ffb1bb3b1b32a77c14dbb42963c64) --- .../src/screen_connector_toolkit_evas.c | 149 +++++++++++---------- 1 file changed, 80 insertions(+), 69 deletions(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index ea8961a..da62bf8 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -34,6 +34,7 @@ #endif #define LOG_TAG "SC_WATCHER_EVAS" +#define SC_TOOLKIT_HANDLE_TAG "SC_TOOLKIT_HANDLE_TAG" struct _screen_connector_type_evas_h { GHashTable *toolkit_table; @@ -70,6 +71,53 @@ static void __destroy_type_h(gpointer data) free(type_h); } +static void __clear_img_tbm(screen_connector_toolkit_evas_h toolkit_evas_h) +{ + char *plug_id; + + if (toolkit_evas_h->img_tbm == NULL) + return; + + plug_id = evas_object_data_del(toolkit_evas_h->img_tbm, "___PLUGID"); + if (plug_id) + free(plug_id); + + evas_object_del(toolkit_evas_h->img_tbm); + toolkit_evas_h->img_tbm = NULL; +} + +static void __clear_img_file(screen_connector_toolkit_evas_h toolkit_evas_h) +{ + if (toolkit_evas_h->img_file == NULL) + return; + + evas_object_del(toolkit_evas_h->img_file); + toolkit_evas_h->img_file = NULL; +} + +static void __destroy_toolkit_evas_h(gpointer data) +{ + char *plug_id; + screen_connector_toolkit_evas_h toolkit_evas_h = data; + + if (!toolkit_evas_h) + return; + + if (toolkit_evas_h->img_tbm != NULL) { + plug_id = evas_object_data_del(toolkit_evas_h->img_tbm, "___PLUGID"); + if (plug_id) + free(plug_id); + } + + if (toolkit_evas_h->toolkit_h) + screen_connector_toolkit_remove(toolkit_evas_h->toolkit_h); + + if (toolkit_evas_h->ops) + free(toolkit_evas_h->ops); + + free(toolkit_evas_h); +} + EXPORT_API int screen_connector_toolkit_evas_init(Evas_Object *win, screen_connector_screen_type_e type) { screen_connector_type_evas_h type_h; @@ -83,7 +131,7 @@ EXPORT_API int screen_connector_toolkit_evas_init(Evas_Object *win, screen_conne type_h = (screen_connector_type_evas_h)calloc(1, sizeof(struct _screen_connector_type_evas_h)); g_hash_table_insert(__type_table, GINT_TO_POINTER(type), type_h); - type_h->toolkit_table = g_hash_table_new(g_direct_hash, g_direct_equal); + type_h->toolkit_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, __destroy_toolkit_evas_h); if (!type_h->toolkit_table) { LOGE("failed to create table"); return -1; @@ -120,7 +168,7 @@ EXPORT_API int screen_connector_toolkit_evas_fini(screen_connector_screen_type_e return screen_connector_toolkit_fini(type); } -static bool __obj_is_visible(Evas_Object *obj, screen_connector_toolkit_evas_h toolkit_evas_h) +static bool __obj_is_visible(screen_connector_toolkit_evas_h toolkit_evas_h) { int x, y, w, h; Ecore_Wl_Window *window = NULL; @@ -132,9 +180,14 @@ static bool __obj_is_visible(Evas_Object *obj, screen_connector_toolkit_evas_h t return false; } + if (toolkit_evas_h->img_tbm == NULL) { + LOGE("img_tbm is NULL"); + return false; + } + window = elm_win_wl_window_get(toolkit_evas_h->type_h->viewer_win); ecore_wl_window_geometry_get(window, &window_x, &window_y, &window_w, &window_h); - evas_object_geometry_get(obj, &x, &y, &w, &h); + evas_object_geometry_get(toolkit_evas_h->img_tbm, &x, &y, &w, &h); rotation = ecore_wl_window_rotation_get(window); if (x >= 0 && x < window_w && @@ -192,7 +245,7 @@ static void __obj_update_visibility(void *data, Evas *e, Evas_Object *obj, void return; } - if (__obj_is_visible(obj, toolkit_evas_h)) + if (__obj_is_visible(toolkit_evas_h)) __set_visibility(toolkit_evas_h, VISIBILITY_TYPE_UNOBSCURED); else __set_visibility(toolkit_evas_h, VISIBILITY_TYPE_FULLY_OBSCURED); @@ -386,25 +439,6 @@ static void __rs_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_in __obj_update_visibility(data, e, obj, event_info); } -static void __clear_img_tbm(screen_connector_toolkit_evas_h toolkit_evas_h) -{ - if (toolkit_evas_h->img_tbm == NULL) - return; - - g_hash_table_remove(toolkit_evas_h->type_h->toolkit_table, toolkit_evas_h->img_tbm); - evas_object_del(toolkit_evas_h->img_tbm); - toolkit_evas_h->img_tbm = NULL; -} - -static void __clear_img_file(screen_connector_toolkit_evas_h toolkit_evas_h) -{ - if (toolkit_evas_h->img_file == NULL) - return; - - evas_object_del(toolkit_evas_h->img_file); - toolkit_evas_h->img_file = NULL; -} - static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, const char *appid, const char *instance_id, const int pid, void *data) @@ -451,11 +485,13 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, __rs_cb_resize, toolkit_evas_h); /* Store toolkit_evas_h */ - g_hash_table_insert(toolkit_evas_h->type_h->toolkit_table, toolkit_evas_h->img_tbm, toolkit_evas_h); + g_hash_table_insert(toolkit_evas_h->type_h->toolkit_table, strdup(instance_id), toolkit_evas_h); /* Set data to use in accessibility */ snprintf(plug_id, sizeof(plug_id), "%s:%d", instance_id, pid); evas_object_data_set(toolkit_evas_h->img_tbm, "___PLUGID", strdup(plug_id)); + + evas_object_data_set(toolkit_evas_h->img_tbm, SC_TOOLKIT_HANDLE_TAG, toolkit_evas_h); evas_object_event_callback_add(toolkit_evas_h->img_tbm, EVAS_CALLBACK_MOVE, __obj_update_visibility, toolkit_evas_h); } @@ -534,25 +570,6 @@ static void __toolkit_added_cb(const char *appid, const char *instance_id, const { } -static void __free_toolkit_evas_h(screen_connector_toolkit_evas_h toolkit_evas_h) -{ - if (!toolkit_evas_h) - return; - - if (toolkit_evas_h->toolkit_h) - screen_connector_toolkit_remove(toolkit_evas_h->toolkit_h); - - __clear_img_file(toolkit_evas_h); - __clear_img_tbm(toolkit_evas_h); - - if (toolkit_evas_h->ops) { - free(toolkit_evas_h->ops); - toolkit_evas_h->ops = NULL; - } - - free(toolkit_evas_h); -} - static void __toolkit_removed_cb(const char *appid, const char *instance_id, const int pid, void *data) { screen_connector_toolkit_evas_h toolkit_evas_h; @@ -565,20 +582,18 @@ static void __toolkit_removed_cb(const char *appid, const char *instance_id, con return; } - if (toolkit_evas_h->type_h->toolkit_table != NULL && toolkit_evas_h->img_tbm != NULL) { - g_hash_table_remove(toolkit_evas_h->type_h->toolkit_table, toolkit_evas_h->img_tbm); - - /* Remove data used in accessibility */ + if (toolkit_evas_h->img_tbm != NULL) { plug_id = evas_object_data_del(toolkit_evas_h->img_tbm, "___PLUGID"); - free(plug_id); - } + if (plug_id) + free(plug_id); - if (toolkit_evas_h->img_tbm != NULL) + evas_object_data_del(toolkit_evas_h->img_tbm, SC_TOOLKIT_HANDLE_TAG); toolkit_evas_h->ops->removed_cb(appid, instance_id, pid, toolkit_evas_h->img_tbm, toolkit_evas_h->data); - else if (toolkit_evas_h->img_file != NULL) + } else if (toolkit_evas_h->img_file != NULL) { toolkit_evas_h->ops->removed_cb(appid, instance_id, pid, toolkit_evas_h->img_file, toolkit_evas_h->data); + } - __free_toolkit_evas_h(toolkit_evas_h); + g_hash_table_remove(toolkit_evas_h->type_h->toolkit_table, instance_id); } EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_with_win(screen_connector_toolkit_evas_ops *ops, char *id, @@ -686,10 +701,18 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add(scr EXPORT_API int screen_connector_toolkit_evas_remove(screen_connector_toolkit_evas_h handle) { + const char *instance_id; + if (handle == NULL) return -1; - __free_toolkit_evas_h(handle); + instance_id = screen_connector_toolkit_get_instance_id(handle->toolkit_h); + if (instance_id == NULL) { + LOGE("Null instance_id"); + return -1; + } + g_hash_table_remove(handle->type_h->toolkit_table, instance_id); + return 0; } @@ -701,7 +724,6 @@ EXPORT_API int screen_connector_toolkit_evas_update(const char *appid, const cha static void __send_visibility(gpointer key, gpointer value, gpointer user_data) { screen_connector_toolkit_evas_h toolkit_evas_h = (screen_connector_toolkit_evas_h)value; - Evas_Object *evas_obj = (Evas_Object *)key; unsigned int event = GPOINTER_TO_INT(user_data); int ret; visibility_type type; @@ -709,7 +731,7 @@ static void __send_visibility(gpointer key, gpointer value, gpointer user_data) if (toolkit_evas_h->freeze) return; - if (!__obj_is_visible(evas_obj, toolkit_evas_h)) + if (!__obj_is_visible(toolkit_evas_h)) return; if (event) @@ -719,7 +741,7 @@ static void __send_visibility(gpointer key, gpointer value, gpointer user_data) ret = __set_visibility(toolkit_evas_h, type); if (ret == -1) - LOGE("failed to set object visibility set %p to %d", evas_obj, type); + LOGE("failed to set object visibility set %p to %d", toolkit_evas_h->img_tbm, type); } static Eina_Bool __visibility_cb(void *data, int type, void *event) @@ -770,21 +792,10 @@ EXPORT_API int screen_connector_toolkit_evas_stop_visibility_notify(void) screen_connector_toolkit_evas_h __find_toolkit_evas_h(Evas_Object *obj) { screen_connector_toolkit_evas_h toolkit_evas_h; - GHashTableIter iter; - gpointer key, value; - screen_connector_type_evas_h cur_type; - g_hash_table_iter_init(&iter, __type_table); - while (g_hash_table_iter_next(&iter, &key, &value)) { - cur_type = (screen_connector_type_evas_h)value; - if (cur_type->toolkit_table) { - toolkit_evas_h = g_hash_table_lookup(cur_type->toolkit_table, obj); - if (toolkit_evas_h != NULL) - return toolkit_evas_h; - } - } + toolkit_evas_h = evas_object_data_get(obj, SC_TOOLKIT_HANDLE_TAG); - return NULL; + return toolkit_evas_h; } EXPORT_API int screen_connector_toolkit_evas_freeze_visibility(Evas_Object *obj, visibility_type type) -- 2.7.4 From ca3456314b10f189efc3a53e418046225600f076 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 26 Apr 2017 14:08:33 +0900 Subject: [PATCH 06/16] Delay resuming time - This patch allows some widgets to postpone getting resuming callback - If widgets change the visibility repeatedly, the performance will not be good - Added API will help to adjust the delayed resuming time - By default, the delayed resuming time is 0 Change-Id: I87edb61a7706bd0abf28fe63c9289c56635d64e5 Signed-off-by: Junghoon Park (cherry picked from commit acf380a217578c085f28fa13b10f8cba00f5ae53) --- .../include/screen_connector_toolkit_evas.h | 1 + .../src/screen_connector_toolkit_evas.c | 51 +++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index d0d4a89..b1ae572 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -65,6 +65,7 @@ int screen_connector_toolkit_evas_init(Evas_Object *win, screen_connector_screen int screen_connector_toolkit_evas_fini(screen_connector_screen_type_e type); screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add(screen_connector_toolkit_evas_ops *ops, char *id, screen_connector_screen_type_e type, void *data); +int screen_connector_toolkit_evas_set_delayed_resuming_time(int ms); int screen_connector_toolkit_evas_remove(screen_connector_toolkit_evas_h handle); int screen_connector_toolkit_evas_update(const char *appid, const char *instance_id); int screen_connector_toolkit_evas_start_visibility_notify(void); diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index da62bf8..7af5c5c 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -52,11 +52,13 @@ struct _screen_connector_toolkit_evas_h { uint32_t img_type; struct wl_buffer *pre_buffer; struct _screen_connector_type_evas_h *type_h; + guint resuming_timer; void *data; }; static GHashTable *__type_table = NULL; static Ecore_Event_Handler *__visibility_listener; +static int __delayed_resuming_time; static void __destroy_type_h(gpointer data) { @@ -115,6 +117,9 @@ static void __destroy_toolkit_evas_h(gpointer data) if (toolkit_evas_h->ops) free(toolkit_evas_h->ops); + if (toolkit_evas_h->resuming_timer > 0) + g_source_remove(toolkit_evas_h->resuming_timer); + free(toolkit_evas_h); } @@ -165,6 +170,8 @@ EXPORT_API int screen_connector_toolkit_evas_fini(screen_connector_screen_type_e __type_table = NULL; } + __delayed_resuming_time = 0; + return screen_connector_toolkit_fini(type); } @@ -207,6 +214,22 @@ static bool __obj_is_visible(screen_connector_toolkit_evas_h toolkit_evas_h) return false; } +static gboolean __resuming_timeout_cb(gpointer user_data) +{ + screen_connector_toolkit_evas_h toolkit_evas_h = user_data; + struct tizen_remote_surface *surface; + + surface = screen_connector_toolkit_get_trs(toolkit_evas_h->toolkit_h); + if (surface) { + tizen_remote_surface_transfer_visibility(surface, + TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE); + } + + toolkit_evas_h->resuming_timer = 0; + + return G_SOURCE_REMOVE; +} + static int __set_visibility(screen_connector_toolkit_evas_h toolkit_evas_h, visibility_type type) { int obscured; @@ -230,9 +253,28 @@ static int __set_visibility(screen_connector_toolkit_evas_h toolkit_evas_h, visi } surface = screen_connector_toolkit_get_trs(toolkit_evas_h->toolkit_h); - if (surface) + if (!surface) + return -1; + + if (__delayed_resuming_time == 0) { tizen_remote_surface_transfer_visibility(surface, obscured); + return 0; + } + + if (obscured == TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE) { + if (toolkit_evas_h->resuming_timer > 0) { + g_source_remove(toolkit_evas_h->resuming_timer); + toolkit_evas_h->resuming_timer = 0; + } + tizen_remote_surface_transfer_visibility(surface, obscured); + } else { + if (toolkit_evas_h->resuming_timer == 0) { + toolkit_evas_h->resuming_timer = g_timeout_add(__delayed_resuming_time, + __resuming_timeout_cb, toolkit_evas_h); + } + } + return 0; } @@ -596,6 +638,13 @@ static void __toolkit_removed_cb(const char *appid, const char *instance_id, con g_hash_table_remove(toolkit_evas_h->type_h->toolkit_table, instance_id); } +EXPORT_API int screen_connector_toolkit_evas_set_delayed_resuming_time(int ms) +{ + __delayed_resuming_time = ms; + + return 0; +} + EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_with_win(screen_connector_toolkit_evas_ops *ops, char *id, screen_connector_screen_type_e type, Evas_Object *win, void *data) { -- 2.7.4 From 365a36cc65c0d7d6638a449d2a668d8cc46cfe3a Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Tue, 16 May 2017 11:18:24 +0900 Subject: [PATCH 07/16] Add APIs to control visibility Change-Id: I901d56fce6ab6703f865388fd361157b374f82d6 Signed-off-by: Junghoon Park (cherry picked from commit fcefc9d15e719d27fcc34919d2fd2eca079259fc) --- .../include/screen_connector_toolkit_evas.h | 1 + .../src/screen_connector_toolkit_evas.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index b1ae572..7cd665d 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -72,6 +72,7 @@ int screen_connector_toolkit_evas_start_visibility_notify(void); int screen_connector_toolkit_evas_stop_visibility_notify(void); int screen_connector_toolkit_evas_freeze_visibility(Evas_Object *obj, visibility_type type); int screen_connector_toolkit_evas_thaw_visibility(Evas_Object *obj); +int screen_connector_toolkit_evas_send_visibility(Evas_Object *obj, visibility_type type); int screen_connector_toolkit_evas_send_mouse_up(Evas_Object *obj); int screen_connector_toolkit_evas_send_touch_cancel(Evas_Object *obj); diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 7af5c5c..6dab25b 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -875,6 +875,19 @@ EXPORT_API int screen_connector_toolkit_evas_thaw_visibility(Evas_Object *obj) return 0; } +EXPORT_API int screen_connector_toolkit_evas_send_visibility(Evas_Object *obj, visibility_type type) +{ + screen_connector_toolkit_evas_h toolkit_evas_h; + + toolkit_evas_h = __find_toolkit_evas_h(obj); + if (!toolkit_evas_h) { + LOGE("obj not found"); + return -1; + } + + return __set_visibility(toolkit_evas_h, type); +} + EXPORT_API int screen_connector_toolkit_evas_send_mouse_up(Evas_Object *obj) { screen_connector_toolkit_evas_h toolkit_evas_h; -- 2.7.4 From dc8164a1c543c62c4f508c77f4a955519e017a94 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 31 May 2017 19:26:00 +0900 Subject: [PATCH 08/16] Add object visible check API - screen_connector_toolkit_evas_is_visible Change-Id: Id8010fa0507770ea85135fcf3597032f36ca0734 Signed-off-by: Hyunho Kang (cherry picked from commit 5616860841370bdd65cdc322ebf735199073f751) --- .../include/screen_connector_toolkit_evas.h | 1 + .../src/screen_connector_toolkit_evas.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index 7cd665d..4a6dabf 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -109,6 +109,7 @@ screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_by_rid(screen_ int screen_connector_toolkit_evas_get_rid(Evas_Object *obj, int *resource_id); screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_with_win(screen_connector_toolkit_evas_ops *ops, char *id, screen_connector_screen_type_e type, Evas_Object *win, void *data); +int screen_connector_toolkit_evas_is_visible(Evas_Object *obj, bool *is_visible); /** diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 6dab25b..dc5e989 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -1042,3 +1042,22 @@ EXPORT_API int screen_connector_toolkit_evas_get_pid(Evas_Object *obj, int *pid) return 0; } + +EXPORT_API int screen_connector_toolkit_evas_is_visible(Evas_Object *obj, bool *is_visible) +{ + screen_connector_toolkit_evas_h toolkit_evas_h; + + if (obj == NULL || is_visible == NULL) { + LOGE("invalid argument"); + return -1; + } + toolkit_evas_h = __find_toolkit_evas_h(obj); + if (!toolkit_evas_h) { + LOGE("obj not found"); + return -1; + } + + *is_visible = __obj_is_visible(toolkit_evas_h); + + return 0; +} -- 2.7.4 From 2984f4600a6f94d099b707689ea167a0b6cb55b5 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Thu, 25 May 2017 19:36:43 +0900 Subject: [PATCH 09/16] Add buffer changed event filter Some watcher application like task-manager want to receive only file type update event. Using these APIs developer can filter update event. - screen_connector_watcher_set_changed_event_filter - screen_connector_watcher_evas_set_changed_event_filter Change-Id: I773f6817d3ab6c2ac58941b1948940daaed90976 Signed-off-by: Hyunho Kang --- .../include/screen_connector_watcher.h | 10 ++++++++ .../src/screen_connector_trs.c | 2 +- .../src/screen_connector_watcher.c | 30 ++++++++++++++++++++++ .../include/screen_connector_watcher_evas.h | 9 +++++++ .../src/screen_connector_watcher_evas.c | 5 ++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/screen_connector_watcher/include/screen_connector_watcher.h b/screen_connector_watcher/include/screen_connector_watcher.h index 31d6b85..ca82edc 100644 --- a/screen_connector_watcher/include/screen_connector_watcher.h +++ b/screen_connector_watcher/include/screen_connector_watcher.h @@ -23,6 +23,14 @@ extern "C" { #endif +typedef enum { + SCREEN_CONNECTOR_CHANGED_EVENT_FILTER_NONE = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_NONE, + SCREEN_CONNECTOR_CHANGED_EVENT_FILTER_TBM = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM, + SCREEN_CONNECTOR_CHANGED_EVENT_FILTER_IMAGE_FILE = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE, + SCREEN_CONNECTOR_CHANGED_EVENT_FILTER_ALL = + TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM | TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE, +} screen_connector_changed_event_filter_type; + typedef void (*screen_connector_watcher_added_cb)(const char *appid, const char *instance_id, const int pid, void *data); typedef void (*screen_connector_watcher_removed_cb)(const char *appid, const char *instance_id, const int pid, void *data); typedef void (*screen_connector_watcher_update_cb)(struct tizen_remote_surface *trs, uint32_t type, struct wl_buffer *tbm, @@ -53,6 +61,8 @@ int screen_connector_watcher_set_resource_id(screen_connector_watcher_h h, int r struct tizen_remote_surface *screen_connector_watcher_get_trs(screen_connector_watcher_h h); screen_connector_watcher_h screen_connector_watcher_create_handle(char *id, int pid, screen_connector_watcher_ops *ops, void *data); int screen_connector_watcher_redirect_surface(screen_connector_info_h info); +int screen_connector_watcher_set_changed_event_filter(screen_connector_watcher_h h, + screen_connector_changed_event_filter_type type); #ifdef __cplusplus } diff --git a/screen_connector_watcher/src/screen_connector_trs.c b/screen_connector_watcher/src/screen_connector_trs.c index fedb303..548fcc1 100644 --- a/screen_connector_watcher/src/screen_connector_trs.c +++ b/screen_connector_watcher/src/screen_connector_trs.c @@ -72,7 +72,7 @@ int screen_connector_trs_init(void) if (!strcmp(global->interface, "tizen_remote_surface_manager")) { __rsm = wl_registry_bind(registry, global->id, &tizen_remote_surface_manager_interface, - global->version < 4 ? global->version : 4); + global->version < 5 ? global->version : 5); } } diff --git a/screen_connector_watcher/src/screen_connector_watcher.c b/screen_connector_watcher/src/screen_connector_watcher.c index 02bd07b..d4653a7 100644 --- a/screen_connector_watcher/src/screen_connector_watcher.c +++ b/screen_connector_watcher/src/screen_connector_watcher.c @@ -43,6 +43,7 @@ struct _screen_connector_watcher_h { void *data; GHashTable *info_table; aul_screen_viewer_h aul_handle; + screen_connector_changed_event_filter_type changed_filter; }; struct _screen_connector_info_h { @@ -54,6 +55,7 @@ struct _screen_connector_info_h { struct tizen_remote_surface *surface; bool renderable; void *data; + screen_connector_changed_event_filter_type changed_filter; }; static void __buffer_updated(void *data, struct tizen_remote_surface *trs, struct wl_buffer *buffer, uint32_t time) @@ -106,6 +108,8 @@ EXPORT_API int screen_connector_watcher_redirect_surface(screen_connector_info_h LOGD("resource_id : %d, (%p)", info->surface_id, info->surface); tizen_remote_surface_add_listener(info->surface, &__rs_listener, info); tizen_remote_surface_redirect(info->surface); + tizen_remote_surface_set_changed_buffer_event_filter(info->surface, info->changed_filter); + LOGD("set filter [%d] for [%s]", info->changed_filter, info->instance_id); return 0; } @@ -158,6 +162,7 @@ static void __aul_screen_viewer_cb(const char *appid, const char *instance_id, info->ops = watcher_h->ops; info->data = watcher_h->data; info->renderable = false; + info->changed_filter = watcher_h->changed_filter; if (event_type == AUL_SCREEN_CONNECTOR_EVENT_TYPE_ADD) { @@ -228,6 +233,7 @@ EXPORT_API screen_connector_watcher_h screen_connector_watcher_add(screen_connec LOGE("watcher_h calloc fail"); return NULL; } + watcher_h->changed_filter = SCREEN_CONNECTOR_CHANGED_EVENT_FILTER_ALL; watcher_h->data = data; watcher_h->ops = ops; watcher_h->info_table = g_hash_table_new_full(g_str_hash, @@ -301,3 +307,27 @@ EXPORT_API void *screen_connector_watcher_get_user_data(screen_connector_info_h { return h->data; } + +EXPORT_API int screen_connector_watcher_set_changed_event_filter(screen_connector_watcher_h h, + screen_connector_changed_event_filter_type type) +{ + GHashTableIter iter; + gpointer key, value; + screen_connector_info_h info; + + if (h == NULL || h->info_table == NULL) { + LOGE("Invalid param"); + return -1; + } + + g_hash_table_iter_init(&iter, h->info_table); + while (g_hash_table_iter_next(&iter, &key, &value)) { + info = (screen_connector_info_h)value; + LOGD("set filter [%d] for [%s]", type, info->instance_id); + tizen_remote_surface_set_changed_buffer_event_filter(info->surface, type); + } + + h->changed_filter = type; + + return 0; +} diff --git a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h index 75959dd..97e4528 100644 --- a/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_watcher_evas.h @@ -36,6 +36,13 @@ extern "C" { * @addtogroup CAPI_SCREEN_CONNECTOR_WATCHER_EVAS_MODULE * @{ */ +typedef enum { + SCREEN_CONNECTOR_EVAS_CHANGED_EVENT_FILTER_NONE = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_NONE, + SCREEN_CONNECTOR_EVAS_CHANGED_EVENT_FILTER_TBM = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM, + SCREEN_CONNECTOR_EVAS_CHANGED_EVENT_FILTER_IMAGE_FILE = TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE, + SCREEN_CONNECTOR_EVAS_CHANGED_EVENT_FILTER_ALL = + TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM | TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE, +} screen_connector_evas_changed_event_filter_type; typedef void (*screen_connector_watcher_evas_added_cb)(const char *appid, const char *instance_id, const int pid, void *data); typedef void (*screen_connector_watcher_evas_removed_cb)(const char *appid, const char *instance_id, const int pid, void *data); @@ -55,6 +62,8 @@ int screen_connector_watcher_evas_fini(void); screen_connector_watcher_evas_h screen_connector_watcher_evas_add(screen_connector_watcher_evas_ops *ops, void *data); int screen_connector_watcher_evas_remove(screen_connector_watcher_evas_h h); int screen_connector_watcher_evas_update(screen_connector_watcher_evas_h watcher_evas_h, const char *instance_id); +int screen_connector_watcher_evas_set_changed_event_filter(screen_connector_watcher_evas_h watcher_evas_h, + screen_connector_evas_changed_event_filter_type type); /** * @} diff --git a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c index 0e4d177..b39b4cf 100644 --- a/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_watcher_evas.c @@ -302,3 +302,8 @@ EXPORT_API int screen_connector_watcher_evas_update(screen_connector_watcher_eva return screen_connector_watcher_update(watcher_evas_h->watcher_h, instance_id); } +EXPORT_API int screen_connector_watcher_evas_set_changed_event_filter(screen_connector_watcher_evas_h watcher_evas_h, + screen_connector_evas_changed_event_filter_type type) +{ + return screen_connector_watcher_set_changed_event_filter(watcher_evas_h->watcher_h, type); +} -- 2.7.4 From 30b7fa3bf70ae082cd7bcb717060996700cc9b6c Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Fri, 2 Jun 2017 16:34:04 +0900 Subject: [PATCH 10/16] Fix add by rid bug - Only main viewer should remove prev tbm buffer. - Resources which generated by add_by_rid should be managed Change-Id: Icf2dfdc47b131e2efd86b82aabdb1ff683d30203 Signed-off-by: Hyunho Kang --- .../include/screen_connector_toolkit.h | 7 +- .../src/screen_connector_toolkit.c | 23 +++++- .../src/screen_connector_toolkit_evas.c | 83 ++++++++++++++++++---- 3 files changed, 96 insertions(+), 17 deletions(-) diff --git a/screen_connector_watcher/include/screen_connector_toolkit.h b/screen_connector_watcher/include/screen_connector_toolkit.h index 39968b1..7fe718c 100644 --- a/screen_connector_watcher/include/screen_connector_toolkit.h +++ b/screen_connector_watcher/include/screen_connector_toolkit.h @@ -74,13 +74,16 @@ void *screen_connector_toolkit_get_user_data(screen_connector_toolkit_h h); unsigned int screen_connector_toolkit_get_event_filter(screen_connector_toolkit_h h); int screen_connector_toolkit_check_input_disabled(screen_connector_toolkit_h h, screen_connector_input_type_e input); -screen_connector_toolkit_h screen_connector_toolkit_create_handle(char *id, int surface_id, - screen_connector_toolkit_ops *ops, void *data); +screen_connector_toolkit_h screen_connector_toolkit_add_by_rid(screen_connector_toolkit_ops *ops, char *id, + screen_connector_screen_type_e type, int surface_id, void *data); struct tizen_remote_surface *screen_connector_toolkit_get_trs(screen_connector_toolkit_h h); int screen_connector_toolkit_redirect_surface(screen_connector_toolkit_h info); screen_connector_toolkit_h screen_connector_toolkit_add_with_surface(screen_connector_toolkit_ops *ops, char *id, screen_connector_screen_type_e type, struct wl_surface *surface, void *data); +int screen_connector_toolkit_bind(screen_connector_toolkit_h h, struct wl_surface *surface); +int screen_connector_toolkit_unbind(screen_connector_toolkit_h h); + #ifdef __cplusplus } #endif diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index 3a36df2..0227d48 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.c +++ b/screen_connector_watcher/src/screen_connector_toolkit.c @@ -247,11 +247,18 @@ EXPORT_API int screen_connector_toolkit_fini(screen_connector_screen_type_e type return ret; } -EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_create_handle(char *id, int surface_id, - screen_connector_toolkit_ops *ops, void *data) +EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add_by_rid(screen_connector_toolkit_ops *ops, char *id, + screen_connector_screen_type_e type, int surface_id, void *data) { screen_connector_toolkit_h toolkit_h = NULL; screen_connector_toolkit_ops *ops_copy; + screen_connector_type_h type_h; + + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); + if (type_h == NULL) { + LOGE("type %d is not initialized !!", type); + return NULL; + } ops_copy = (screen_connector_toolkit_ops *)calloc(1, sizeof(screen_connector_toolkit_ops)); if (ops_copy == NULL) { @@ -271,6 +278,18 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_create_handle(cha toolkit_h->instance_id = strdup(id); toolkit_h->data = data; toolkit_h->ops = ops_copy; + toolkit_h->type_h = type_h; + + if (type_h->toolkit_table == NULL) + type_h->toolkit_table = g_hash_table_new_full(g_str_hash, + g_str_equal, free, __destroy_toolkit_h); + + g_hash_table_insert(type_h->toolkit_table, strdup(id), toolkit_h); + + if (type_h->aul_handle == NULL) + aul_screen_connector_add_screen_viewer(__aul_screen_viewer_cb, type, true, type_h, &type_h->aul_handle); + + screen_connector_toolkit_redirect_surface(toolkit_h); return toolkit_h; } diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index dc5e989..d2ef2f3 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "screen_connector_toolkit.h" #include "screen_connector_toolkit_evas.h" @@ -41,6 +42,12 @@ struct _screen_connector_type_evas_h { Evas_Object *viewer_win; }; +struct _cur_buffer_info_h { + struct wl_buffer *cur_buffer; + int ref_count; +}; +typedef struct _cur_buffer_info_h *cur_buffer_info_h; + struct _screen_connector_toolkit_evas_h { screen_connector_toolkit_evas_ops *ops; screen_connector_toolkit_h toolkit_h; @@ -50,12 +57,13 @@ struct _screen_connector_toolkit_evas_h { Evas_Object *img_tbm; Evas_Object *img_file; uint32_t img_type; - struct wl_buffer *pre_buffer; + struct wl_buffer *cur_buffer; struct _screen_connector_type_evas_h *type_h; guint resuming_timer; void *data; }; +static GHashTable *__cur_buffer_table = NULL; static GHashTable *__type_table = NULL; static Ecore_Event_Handler *__visibility_listener; static int __delayed_resuming_time; @@ -73,6 +81,37 @@ static void __destroy_type_h(gpointer data) free(type_h); } +static void __cur_buffer_info_ref(cur_buffer_info_h info) +{ + info->ref_count++; +} + +static void __cur_buffer_info_unref(struct tizen_remote_surface *trs, cur_buffer_info_h info) +{ + tbm_surface_h cur_tbm_surface; + + info->ref_count--; + if (info->ref_count == 0) { + tizen_remote_surface_release(trs, info->cur_buffer); + cur_tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(info->cur_buffer); + tbm_surface_internal_unref(cur_tbm_surface); + g_hash_table_remove(__cur_buffer_table, info->cur_buffer); + } +} + +static void __destroy_cur_buffer(gpointer data) +{ + cur_buffer_info_h info = (cur_buffer_info_h)data; + + if (!info) + return; + + if (info->cur_buffer) + wl_buffer_destroy(info->cur_buffer); + + free(info); +} + static void __clear_img_tbm(screen_connector_toolkit_evas_h toolkit_evas_h) { char *plug_id; @@ -130,6 +169,9 @@ EXPORT_API int screen_connector_toolkit_evas_init(Evas_Object *win, screen_conne if (__type_table == NULL) __type_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_type_h); + if (__cur_buffer_table == NULL) + __cur_buffer_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __destroy_cur_buffer); + type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { @@ -168,6 +210,10 @@ EXPORT_API int screen_connector_toolkit_evas_fini(screen_connector_screen_type_e if (g_hash_table_size(__type_table) == 0) { g_hash_table_destroy(__type_table); __type_table = NULL; + + if (__cur_buffer_table) + g_hash_table_destroy(__cur_buffer_table); + __cur_buffer_table = NULL; } __delayed_resuming_time = 0; @@ -493,7 +539,7 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, char format[] = "png"; char plug_id[256]; screen_connector_toolkit_evas_h toolkit_evas_h; - tbm_surface_h pre_tbm_surface; + cur_buffer_info_h c_buf_info; toolkit_evas_h = (screen_connector_toolkit_evas_h)data; if (toolkit_evas_h->img_tbm == NULL) { @@ -572,15 +618,24 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, evas_object_image_native_surface_set(toolkit_evas_h->img_tbm, NULL); /* set null to previous object for the tbm type */ } - if (toolkit_evas_h->pre_buffer) { + if (toolkit_evas_h->cur_buffer) { if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) { - tizen_remote_surface_release(trs, toolkit_evas_h->pre_buffer); - pre_tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(toolkit_evas_h->pre_buffer); - tbm_surface_internal_unref(pre_tbm_surface); - wl_buffer_destroy(toolkit_evas_h->pre_buffer); + c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer); + if (c_buf_info != NULL) + __cur_buffer_info_unref(trs, c_buf_info); } } - toolkit_evas_h->pre_buffer = tbm; + + toolkit_evas_h->cur_buffer = tbm; + c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer); + if (c_buf_info == NULL) { + c_buf_info = (cur_buffer_info_h)calloc(1, sizeof(struct _cur_buffer_info_h)); + c_buf_info->cur_buffer = toolkit_evas_h->cur_buffer; + __cur_buffer_info_ref(c_buf_info); + g_hash_table_insert(__cur_buffer_table, toolkit_evas_h->cur_buffer, c_buf_info); + } else { + __cur_buffer_info_ref(c_buf_info); + } if (is_added) { LOGD("call added !!!! %s, type %d", appid, type); @@ -594,7 +649,6 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, __clear_img_file(toolkit_evas_h); } } else { - LOGD("call updated !!!! %s, type %d", appid, type); if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { toolkit_evas_h->ops->updated_cb(appid, instance_id, pid, toolkit_evas_h->img_file, toolkit_evas_h->data); @@ -970,7 +1024,9 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_by_ screen_connector_toolkit_evas_ops *evas_ops; screen_connector_toolkit_ops toolkit_ops; screen_connector_type_evas_h type_h; - char rid_str[32]; + char id_str[70]; + char uuid[37]; + uuid_t u; type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type)); if (type_h == NULL) { @@ -1000,9 +1056,10 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add_by_ handle->data = data; handle->type_h = type_h; - snprintf(rid_str, sizeof(rid_str), "%d", res_id); - handle->toolkit_h = screen_connector_toolkit_create_handle(rid_str, res_id, &toolkit_ops, handle); - screen_connector_toolkit_redirect_surface(handle->toolkit_h); + uuid_generate(u); + uuid_unparse(u, uuid); + snprintf(id_str, sizeof(id_str), "%s:%d", uuid, res_id); + handle->toolkit_h = screen_connector_toolkit_add_by_rid(&toolkit_ops, id_str, type, res_id, handle); return handle; } -- 2.7.4 From 3b97c8349396894c28944c2efa6207834cffe610 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 11 May 2017 14:09:39 +0900 Subject: [PATCH 11/16] Add APIs for binding and unbinding window Change-Id: I0ae4e1aaff04896400047ed9867fd5c75f823cb6 Signed-off-by: Junghoon Park Signed-off-by: Hyunho Kang --- .../src/screen_connector_toolkit.c | 34 ++++++++++++++++++++++ .../include/screen_connector_toolkit_evas.h | 3 ++ .../src/screen_connector_toolkit_evas.c | 34 ++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index 0227d48..c79e6b5 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.c +++ b/screen_connector_watcher/src/screen_connector_toolkit.c @@ -493,3 +493,37 @@ EXPORT_API struct tizen_remote_surface *screen_connector_toolkit_get_trs(screen_ return h->surface; } + +EXPORT_API int screen_connector_toolkit_bind(screen_connector_toolkit_h h, + struct wl_surface *surface) +{ + struct tizen_remote_surface_manager *rsm = screen_connector_get_rsm(); + + if (!h || !rsm || !(h->surface)) { + LOGE("invalid argument %p %p", h, rsm); + + return -1; + } + + tizen_remote_surface_manager_bind_surface(rsm, surface, h->surface); + + return 0; +} + +EXPORT_API int screen_connector_toolkit_unbind(screen_connector_toolkit_h h) +{ + struct tizen_remote_surface_manager *rsm = screen_connector_get_rsm(); + + if (!h || !rsm || !(h->surface)) { + LOGE("invalid argument %p %p", h, rsm); + + return -1; + } + + tizen_remote_surface_manager_bind_surface(rsm, NULL, h->surface); + tizen_remote_surface_redirect(h->surface); + + return 0; +} + + diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index 4a6dabf..65c7724 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -75,6 +75,9 @@ int screen_connector_toolkit_evas_thaw_visibility(Evas_Object *obj); int screen_connector_toolkit_evas_send_visibility(Evas_Object *obj, visibility_type type); int screen_connector_toolkit_evas_send_mouse_up(Evas_Object *obj); int screen_connector_toolkit_evas_send_touch_cancel(Evas_Object *obj); +int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_h h, Evas_Object *win); +int screen_connector_toolkit_evas_unbind(screen_connector_toolkit_evas_h h); + /** * @brief Add screen connector toolkit by rid. diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index d2ef2f3..7a6182f 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -1118,3 +1118,37 @@ EXPORT_API int screen_connector_toolkit_evas_is_visible(Evas_Object *obj, bool * return 0; } + +EXPORT_API int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_h h, + Evas_Object *win) +{ + struct wl_surface *surface; + Ecore_Wl_Window *wl_win; + + if (!h) + return -1; + + wl_win = elm_win_wl_window_get(win); + if (!wl_win) { + LOGE("failed to get wl_win"); + return -1; + } + + surface = ecore_wl_window_surface_get(wl_win); + if (!surface) { + LOGE("failed to get surface"); + return -1; + } + + return screen_connector_toolkit_bind(h->toolkit_h, surface); +} + +EXPORT_API int screen_connector_toolkit_evas_unbind(screen_connector_toolkit_evas_h h) +{ + if (!h || !(h->toolkit_h)) { + LOGE("invalid argument %p", h); + return -1; + } + + return screen_connector_toolkit_unbind(h->toolkit_h); +} -- 2.7.4 From e049192b600ef84a417fe26cf6bdc644bd658c1c Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Fri, 16 Jun 2017 15:54:05 +0900 Subject: [PATCH 12/16] Remove evas callback from destroyed surface tbm Destroyed surface's tbm buffer can be remained in viewer application so we need to remove every callback from destroyed surface's tbm buffer. Change-Id: I0487f697ae506079790c333875cc8f7885452087 Signed-off-by: Hyunho Kang --- .../src/screen_connector_toolkit_evas.c | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 7a6182f..2fb66c2 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -68,6 +68,15 @@ static GHashTable *__type_table = NULL; static Ecore_Event_Handler *__visibility_listener; static int __delayed_resuming_time; +static void __rs_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_mouse_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_show(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __rs_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __obj_update_visibility(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void __destroy_type_h(gpointer data) { screen_connector_type_evas_h type_h = (screen_connector_type_evas_h)data; @@ -145,6 +154,41 @@ static void __destroy_toolkit_evas_h(gpointer data) return; if (toolkit_evas_h->img_tbm != NULL) { + + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_DOWN, + __rs_cb_mouse_down); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_UP, + __rs_cb_mouse_up); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_MOVE, + __rs_cb_mouse_move); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_MOUSE_WHEEL, + __rs_cb_mouse_wheel); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_SHOW, + __rs_cb_show); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_HIDE, + __rs_cb_hide); + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_RESIZE, + __rs_cb_resize); + + evas_object_event_callback_del( + toolkit_evas_h->img_tbm, + EVAS_CALLBACK_MOVE, + __obj_update_visibility); + plug_id = evas_object_data_del(toolkit_evas_h->img_tbm, "___PLUGID"); if (plug_id) free(plug_id); -- 2.7.4 From a877b798d4dc88046dd2f4a4abe40dbbc27a2e94 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 21 Jun 2017 16:13:25 +0900 Subject: [PATCH 13/16] Clear tbm when surface destroyed Change-Id: I272f64c095b201b217bf6920d654c538917d0fa9 Signed-off-by: Hyunho Kang --- screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 2fb66c2..ce6a499 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -192,6 +192,8 @@ static void __destroy_toolkit_evas_h(gpointer data) plug_id = evas_object_data_del(toolkit_evas_h->img_tbm, "___PLUGID"); if (plug_id) free(plug_id); + + __clear_img_tbm(toolkit_evas_h); } if (toolkit_evas_h->toolkit_h) -- 2.7.4 From 6e1c4b55b142ea22e730bab785b5512e5dbd0b8a Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Fri, 14 Jul 2017 11:20:02 +0900 Subject: [PATCH 14/16] Do not destroy buffer when receive same buffer Change-Id: Ie5a3560a1a745534e950359e4949007d64c7fca4 Signed-off-by: Hyunho Kang --- .../src/screen_connector_toolkit_evas.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index ce6a499..41a7926 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -95,7 +95,7 @@ static void __cur_buffer_info_ref(cur_buffer_info_h info) info->ref_count++; } -static void __cur_buffer_info_unref(struct tizen_remote_surface *trs, cur_buffer_info_h info) +static bool __cur_buffer_info_unref(struct tizen_remote_surface *trs, cur_buffer_info_h info) { tbm_surface_h cur_tbm_surface; @@ -105,7 +105,10 @@ static void __cur_buffer_info_unref(struct tizen_remote_surface *trs, cur_buffer cur_tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(info->cur_buffer); tbm_surface_internal_unref(cur_tbm_surface); g_hash_table_remove(__cur_buffer_table, info->cur_buffer); + return true; } + + return false; } static void __destroy_cur_buffer(gpointer data) @@ -115,9 +118,6 @@ static void __destroy_cur_buffer(gpointer data) if (!info) return; - if (info->cur_buffer) - wl_buffer_destroy(info->cur_buffer); - free(info); } @@ -667,8 +667,18 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, if (toolkit_evas_h->cur_buffer) { if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) { c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer); - if (c_buf_info != NULL) - __cur_buffer_info_unref(trs, c_buf_info); + if (c_buf_info != NULL) { + struct wl_buffer *tmp_buffer = c_buf_info->cur_buffer; + if (__cur_buffer_info_unref(trs, c_buf_info)) { + if(tmp_buffer != NULL) { + if (tmp_buffer != tbm) { + wl_buffer_destroy(tmp_buffer); + } else { + LOGE("Same buffer %p", tmp_buffer); + } + } + } + } } } -- 2.7.4 From 658251488f63bc4059045ee34e366d781ee8a398 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Tue, 18 Jul 2017 19:30:21 +0900 Subject: [PATCH 15/16] Check multi viewer window visibility Viewer's visibility has to be decided based on every viewer window include bind target window. Change-Id: I1ec9299ab2ff23429cb6b214b39ecc422c747fc1 Signed-off-by: Hyunho Kang --- .../include/screen_connector_toolkit_evas.h | 1 + .../src/screen_connector_toolkit_evas.c | 80 ++++++++++++++++++++-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h index 65c7724..6b16d7d 100644 --- a/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h +++ b/screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h @@ -43,6 +43,7 @@ typedef enum { VISIBILITY_TYPE_UNOBSCURED, VISIBILITY_TYPE_PARTIALLY_OBSCURED, VISIBILITY_TYPE_FULLY_OBSCURED, + VISIBILITY_TYPE_UNKNOWN, } visibility_type; typedef void (*screen_connector_toolkit_evas_added_cb)(const char *appid, const char *instance_id, const int pid, diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index 41a7926..d0b12dd 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -48,6 +48,12 @@ struct _cur_buffer_info_h { }; typedef struct _cur_buffer_info_h *cur_buffer_info_h; +struct _viewer_visibility_h { + visibility_type visibility; + int win_id; +}; +typedef struct _viewer_visibility_h *viewer_visibility_h; + struct _screen_connector_toolkit_evas_h { screen_connector_toolkit_evas_ops *ops; screen_connector_toolkit_h toolkit_h; @@ -60,6 +66,7 @@ struct _screen_connector_toolkit_evas_h { struct wl_buffer *cur_buffer; struct _screen_connector_type_evas_h *type_h; guint resuming_timer; + GList *viewer_visibility_list; void *data; }; @@ -77,6 +84,13 @@ static void __rs_cb_hide(void *data, Evas *e, Evas_Object *obj, void *event_info static void __rs_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info); static void __obj_update_visibility(void *data, Evas *e, Evas_Object *obj, void *event_info); +static gint __comp_win_id(gconstpointer a, gconstpointer b) +{ + viewer_visibility_h win = (viewer_visibility_h)a; + + return !(win->win_id == GPOINTER_TO_INT(b)); +} + static void __destroy_type_h(gpointer data) { screen_connector_type_evas_h type_h = (screen_connector_type_evas_h)data; @@ -205,6 +219,9 @@ static void __destroy_toolkit_evas_h(gpointer data) if (toolkit_evas_h->resuming_timer > 0) g_source_remove(toolkit_evas_h->resuming_timer); + if (toolkit_evas_h->viewer_visibility_list) + g_list_free_full(toolkit_evas_h->viewer_visibility_list, free); + free(toolkit_evas_h); } @@ -883,9 +900,12 @@ EXPORT_API int screen_connector_toolkit_evas_update(const char *appid, const cha static void __send_visibility(gpointer key, gpointer value, gpointer user_data) { screen_connector_toolkit_evas_h toolkit_evas_h = (screen_connector_toolkit_evas_h)value; - unsigned int event = GPOINTER_TO_INT(user_data); + Ecore_Wl_Event_Window_Visibility_Change *ev = user_data; int ret; visibility_type type; + GList *tmp_list = NULL; + GList *iter; + viewer_visibility_h visibility_h; if (toolkit_evas_h->freeze) return; @@ -893,11 +913,50 @@ static void __send_visibility(gpointer key, gpointer value, gpointer user_data) if (!__obj_is_visible(toolkit_evas_h)) return; - if (event) + if (ev->fully_obscured) type = VISIBILITY_TYPE_FULLY_OBSCURED; else type = VISIBILITY_TYPE_UNOBSCURED; + if (toolkit_evas_h->viewer_visibility_list) { + tmp_list = g_list_find_custom( + toolkit_evas_h->viewer_visibility_list, + GINT_TO_POINTER(ev->win), __comp_win_id); + } + + if (tmp_list == NULL) { + visibility_h = (viewer_visibility_h)calloc(1, + sizeof(struct _viewer_visibility_h)); + if (visibility_h == NULL) { + LOGE("Out of memory fail to alloc"); + return; + } + visibility_h->win_id = ev->win; + visibility_h->visibility = type; + toolkit_evas_h->viewer_visibility_list = + g_list_append(toolkit_evas_h->viewer_visibility_list, + visibility_h); + } else { + visibility_h = (viewer_visibility_h)tmp_list->data; + visibility_h->visibility = type; + } + + type = VISIBILITY_TYPE_FULLY_OBSCURED; + iter = toolkit_evas_h->viewer_visibility_list; + while (iter != NULL) { + visibility_h = (viewer_visibility_h)iter->data; + if (visibility_h->visibility == VISIBILITY_TYPE_UNKNOWN) { + LOGE("viewer not ready"); + return; + } else if (visibility_h->visibility == + VISIBILITY_TYPE_UNOBSCURED) { + type = VISIBILITY_TYPE_UNOBSCURED; + break; + } + iter = g_list_next(iter); + } + + LOGW("set visibility to %d", type); ret = __set_visibility(toolkit_evas_h, type); if (ret == -1) LOGE("failed to set object visibility set %p to %d", toolkit_evas_h->img_tbm, type); @@ -920,8 +979,8 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) while (g_hash_table_iter_next(&iter, &key, &value)) { cur_type = (screen_connector_type_evas_h)value; if (cur_type->toolkit_table) - g_hash_table_foreach(cur_type->toolkit_table, __send_visibility, - GINT_TO_POINTER(ev->fully_obscured)); + g_hash_table_foreach(cur_type->toolkit_table, + __send_visibility, ev); } return ECORE_CALLBACK_RENEW; @@ -1180,6 +1239,7 @@ EXPORT_API int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_ { struct wl_surface *surface; Ecore_Wl_Window *wl_win; + viewer_visibility_h visibility_h; if (!h) return -1; @@ -1196,6 +1256,18 @@ EXPORT_API int screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_ return -1; } + visibility_h = (viewer_visibility_h)calloc(1, + sizeof(struct _viewer_visibility_h)); + if (visibility_h == NULL) { + LOGE("Out of memory fail to alloc"); + return -1; + } + visibility_h->win_id = ecore_wl_window_id_get(wl_win); + visibility_h->visibility = VISIBILITY_TYPE_UNKNOWN; + + h->viewer_visibility_list = + g_list_append(h->viewer_visibility_list, visibility_h); + return screen_connector_toolkit_bind(h->toolkit_h, surface); } -- 2.7.4 From 90a9e4ea771cd67486855820a196dd0580f6d90b Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 19 Jul 2017 09:41:19 +0900 Subject: [PATCH 16/16] Do not unref tbm_surface when receive same buffer Change-Id: I09f3e6f72bd1944a19866977a6f9586a7b236b09 Signed-off-by: Hyunho Kang --- .../src/screen_connector_toolkit_evas.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index d0b12dd..8c2342b 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -132,6 +132,9 @@ static void __destroy_cur_buffer(gpointer data) if (!info) return; + if (info->cur_buffer) + wl_buffer_destroy(info->cur_buffer); + free(info); } @@ -603,6 +606,7 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, char plug_id[256]; screen_connector_toolkit_evas_h toolkit_evas_h; cur_buffer_info_h c_buf_info; + bool duplicate_buffer = false; toolkit_evas_h = (screen_connector_toolkit_evas_h)data; if (toolkit_evas_h->img_tbm == NULL) { @@ -685,15 +689,11 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, if (tizen_remote_surface_get_version(trs) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION) { c_buf_info = g_hash_table_lookup(__cur_buffer_table, toolkit_evas_h->cur_buffer); if (c_buf_info != NULL) { - struct wl_buffer *tmp_buffer = c_buf_info->cur_buffer; - if (__cur_buffer_info_unref(trs, c_buf_info)) { - if(tmp_buffer != NULL) { - if (tmp_buffer != tbm) { - wl_buffer_destroy(tmp_buffer); - } else { - LOGE("Same buffer %p", tmp_buffer); - } - } + if (c_buf_info->cur_buffer != tbm) { + __cur_buffer_info_unref(trs, c_buf_info); + } else { + duplicate_buffer = true; + LOGW("Same buffer %p", tbm); } } } @@ -707,7 +707,8 @@ static void __toolkit_update_cb(struct tizen_remote_surface *trs, uint32_t type, __cur_buffer_info_ref(c_buf_info); g_hash_table_insert(__cur_buffer_table, toolkit_evas_h->cur_buffer, c_buf_info); } else { - __cur_buffer_info_ref(c_buf_info); + if (!duplicate_buffer) + __cur_buffer_info_ref(c_buf_info); } if (is_added) { -- 2.7.4