tpl_wayland_egl: implement free_flush protocol 39/132539/1
authorSangjin Lee <lsj119@samsung.com>
Tue, 6 Jun 2017 22:59:01 +0000 (07:59 +0900)
committerSangjin Lee <lsj119@samsung.com>
Tue, 6 Jun 2017 23:03:27 +0000 (08:03 +0900)
Implement free_flush of tizen_surface_shm_flusher.
Just flush free_buffer when receive free_flush event from server.
If this protocol is active in server, it can reduce quick_panel buffer 3 to 1 in idle time.

Change-Id: I165af89f6030b651f4417e260e1dcb6115acaa44

src/protocol/tizen-surface-client.h
src/protocol/tizen-surface-protocol.c
src/protocol/tizen-surface.xml [new file with mode: 0644]
src/tpl_wayland_egl.c

index 6159a82..6eaa459 100644 (file)
@@ -14,15 +14,17 @@ struct wl_resource;
 
 struct tizen_surface_shm;
 struct tizen_surface_shm_flusher;
+struct wl_surface;
 
 extern const struct wl_interface tizen_surface_shm_interface;
 extern const struct wl_interface tizen_surface_shm_flusher_interface;
 
 #define TIZEN_SURFACE_SHM_GET_FLUSHER  0
 
+#define TIZEN_SURFACE_SHM_GET_FLUSHER_SINCE_VERSION    1
+
 static inline void
-tizen_surface_shm_set_user_data(struct tizen_surface_shm *tizen_surface_shm,
-                                                               void *user_data)
+tizen_surface_shm_set_user_data(struct tizen_surface_shm *tizen_surface_shm, void *user_data)
 {
        wl_proxy_set_user_data((struct wl_proxy *) tizen_surface_shm, user_data);
 }
@@ -33,6 +35,12 @@ tizen_surface_shm_get_user_data(struct tizen_surface_shm *tizen_surface_shm)
        return wl_proxy_get_user_data((struct wl_proxy *) tizen_surface_shm);
 }
 
+static inline uint32_t
+tizen_surface_shm_get_version(struct tizen_surface_shm *tizen_surface_shm)
+{
+       return wl_proxy_get_version((struct wl_proxy *) tizen_surface_shm);
+}
+
 static inline void
 tizen_surface_shm_destroy(struct tizen_surface_shm *tizen_surface_shm)
 {
@@ -40,14 +48,12 @@ tizen_surface_shm_destroy(struct tizen_surface_shm *tizen_surface_shm)
 }
 
 static inline struct tizen_surface_shm_flusher *
-tizen_surface_shm_get_flusher(struct tizen_surface_shm *tizen_surface_shm,
-                                                         struct wl_surface *surface)
+tizen_surface_shm_get_flusher(struct tizen_surface_shm *tizen_surface_shm, struct wl_surface *surface)
 {
        struct wl_proxy *id;
 
        id = wl_proxy_marshal_constructor((struct wl_proxy *) tizen_surface_shm,
-                                                                         TIZEN_SURFACE_SHM_GET_FLUSHER, &tizen_surface_shm_flusher_interface, NULL,
-                                                                         surface);
+                        TIZEN_SURFACE_SHM_GET_FLUSHER, &tizen_surface_shm_flusher_interface, NULL, surface);
 
        return (struct tizen_surface_shm_flusher *) id;
 }
@@ -57,41 +63,50 @@ struct tizen_surface_shm_flusher_listener {
         * flush - (none)
         */
        void (*flush)(void *data,
-                                 struct tizen_surface_shm_flusher *tizen_surface_shm_flusher);
+                     struct tizen_surface_shm_flusher *tizen_surface_shm_flusher);
+       /**
+        * free_flush - (none)
+        * @since: 2
+        */
+       void (*free_flush)(void *data,
+                          struct tizen_surface_shm_flusher *tizen_surface_shm_flusher);
 };
 
 static inline int
-tizen_surface_shm_flusher_add_listener(struct tizen_surface_shm_flusher
-                                                                          *tizen_surface_shm_flusher,
-                                                                          const struct tizen_surface_shm_flusher_listener *listener, void *data)
+tizen_surface_shm_flusher_add_listener(struct tizen_surface_shm_flusher *tizen_surface_shm_flusher,
+                                      const struct tizen_surface_shm_flusher_listener *listener, void *data)
 {
        return wl_proxy_add_listener((struct wl_proxy *) tizen_surface_shm_flusher,
-                                                                (void (* *)(void)) listener, data);
+                                    (void (**)(void)) listener, data);
 }
 
 #define TIZEN_SURFACE_SHM_FLUSHER_DESTROY      0
 
+#define TIZEN_SURFACE_SHM_FLUSHER_DESTROY_SINCE_VERSION        1
+
 static inline void
-tizen_surface_shm_flusher_set_user_data(struct tizen_surface_shm_flusher
-                                                                               *tizen_surface_shm_flusher, void *user_data)
+tizen_surface_shm_flusher_set_user_data(struct tizen_surface_shm_flusher *tizen_surface_shm_flusher, void *user_data)
 {
-       wl_proxy_set_user_data((struct wl_proxy *) tizen_surface_shm_flusher,
-                                                  user_data);
+       wl_proxy_set_user_data((struct wl_proxy *) tizen_surface_shm_flusher, user_data);
 }
 
 static inline void *
-tizen_surface_shm_flusher_get_user_data(struct tizen_surface_shm_flusher
-                                                                               *tizen_surface_shm_flusher)
+tizen_surface_shm_flusher_get_user_data(struct tizen_surface_shm_flusher *tizen_surface_shm_flusher)
 {
        return wl_proxy_get_user_data((struct wl_proxy *) tizen_surface_shm_flusher);
 }
 
+static inline uint32_t
+tizen_surface_shm_flusher_get_version(struct tizen_surface_shm_flusher *tizen_surface_shm_flusher)
+{
+       return wl_proxy_get_version((struct wl_proxy *) tizen_surface_shm_flusher);
+}
+
 static inline void
-tizen_surface_shm_flusher_destroy(struct tizen_surface_shm_flusher
-                                                                 *tizen_surface_shm_flusher)
+tizen_surface_shm_flusher_destroy(struct tizen_surface_shm_flusher *tizen_surface_shm_flusher)
 {
        wl_proxy_marshal((struct wl_proxy *) tizen_surface_shm_flusher,
-                                        TIZEN_SURFACE_SHM_FLUSHER_DESTROY);
+                        TIZEN_SURFACE_SHM_FLUSHER_DESTROY);
 
        wl_proxy_destroy((struct wl_proxy *) tizen_surface_shm_flusher);
 }
index 8420280..90da268 100644 (file)
@@ -26,11 +26,12 @@ static const struct wl_message tizen_surface_shm_flusher_requests[] = {
 
 static const struct wl_message tizen_surface_shm_flusher_events[] = {
        { "flush", "", types + 0 },
+       { "free_flush", "2", types + 0 },
 };
 
 WL_EXPORT const struct wl_interface tizen_surface_shm_flusher_interface = {
-       "tizen_surface_shm_flusher", 1,
+       "tizen_surface_shm_flusher", 2,
        1, tizen_surface_shm_flusher_requests,
-       1, tizen_surface_shm_flusher_events,
+       2, tizen_surface_shm_flusher_events,
 };
 
diff --git a/src/protocol/tizen-surface.xml b/src/protocol/tizen-surface.xml
new file mode 100644 (file)
index 0000000..ad516c0
--- /dev/null
@@ -0,0 +1,16 @@
+<protocol name="tizen_surface">
+  <interface name="tizen_surface_shm" version="2">
+    <request name="get_flusher">
+      <arg name="id" type="new_id" interface="tizen_surface_shm_flusher" summary=""/>
+      <arg name="surface" type="object" interface="wl_surface" summary="surface object"/>
+    </request>
+  </interface>
+
+  <interface name="tizen_surface_shm_flusher" version="2">
+    <request name="destroy" type="destructor" />
+    <event name="flush">
+    </event>
+    <event name="free_flush" since="2">
+    </event>
+  </interface>
+</protocol>
index 5e83345..f71b046 100644 (file)
@@ -1556,9 +1556,47 @@ static void __cb_tizen_surface_shm_flusher_flush_callback(void *data,
        }
 }
 
+static void __cb_tizen_surface_shm_flusher_free_flush_callback(void *data,
+               struct tizen_surface_shm_flusher *tizen_surface_shm_flusher)
+{
+       tpl_surface_t *surface = data;
+       tpl_wayland_egl_surface_t *wayland_egl_surface;
+       tpl_wayland_egl_display_t *wayland_egl_display;
+       int ret;
+
+       TPL_CHECK_ON_NULL_RETURN(surface);
+       wayland_egl_surface = surface->backend.data;
+       TPL_CHECK_ON_NULL_RETURN(wayland_egl_surface);
+       TPL_CHECK_ON_NULL_RETURN(surface->display);
+       wayland_egl_display = surface->display->backend.data;
+       TPL_CHECK_ON_NULL_RETURN(wayland_egl_display);
+
+       TPL_CHECK_ON_NULL_RETURN(wayland_egl_display->wl_dpy);
+       TPL_CHECK_ON_NULL_RETURN(wayland_egl_display->wl_tbm_event_queue);
+       TPL_CHECK_ON_NULL_RETURN(wayland_egl_surface->tbm_queue);
+
+       TPL_LOG_B("WL_EGL", "[FLUSH_CB] tpl_wayland_egl_surface_t(%p)",
+                         wayland_egl_surface);
+
+       /*Fist distach panding queue for TPL
+               - dispatch buffer-release
+               - dispatch queue flush
+       */
+       ret = wl_display_dispatch_queue_pending(wayland_egl_display->wl_dpy,
+                                                                                       wayland_egl_display->wl_tbm_event_queue);
+       if (ret == -1) {
+               TPL_ERR("Failed to wl_display_dispatch_queue_pending ret:%d, err:%d", ret,
+                               errno);
+               return;
+       }
+
+       tbm_surface_queue_free_flush(wayland_egl_surface->tbm_queue);
+}
+
 static const struct tizen_surface_shm_flusher_listener
 tizen_surface_shm_flusher_listener = {
-       __cb_tizen_surface_shm_flusher_flush_callback
+       __cb_tizen_surface_shm_flusher_flush_callback,
+       __cb_tizen_surface_shm_flusher_free_flush_callback
 };
 
 static void