Delay resuming time 59/127059/1
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 26 Apr 2017 05:08:33 +0000 (14:08 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Wed, 26 Apr 2017 05:08:33 +0000 (14:08 +0900)
- 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 <jh9216.park@samsung.com>
screen_connector_watcher_evas/include/screen_connector_toolkit_evas.h
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index d0d4a89..b1ae572 100644 (file)
@@ -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);
index cb9b226..d53e0ed 100644 (file)
@@ -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);
 }
 
@@ -169,6 +174,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);
 }
 
@@ -211,6 +218,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;
@@ -234,9 +257,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;
 }
 
@@ -600,6 +642,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)
 {