Add bind surface APIs 43/126343/1
authorHyunho Kang <hhstark.kang@samsung.com>
Tue, 18 Apr 2017 11:24:13 +0000 (20:24 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Fri, 21 Apr 2017 04:47:45 +0000 (21:47 -0700)
- screen_connector_toolkit_add_with_surface
- screen_connector_toolkit_evas_add_with_win

Change-Id: I375e74a3a6b26da81befff3109987fc9b9a32234
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
(cherry picked from commit e4674c573afede712f7f0b92afefaae90dd46e73)

screen_connector_watcher/include/screen_connector_toolkit.h
screen_connector_watcher/src/screen_connector_toolkit.c
screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index a5db07e..39968b1 100644 (file)
@@ -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
 }
index 910d73f..3a36df2 100644 (file)
@@ -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)
 {
index 1fb75f6..d0d4a89 100644 (file)
@@ -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);
+
 
 /**
  * @}
index ea1d1ad..ea8961a 100644 (file)
@@ -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)
 {