add wait_usable protocol to wl_tbm_queue 88/210188/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 9 Jul 2019 08:31:21 +0000 (17:31 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 10 Jul 2019 10:14:17 +0000 (19:14 +0900)
Change-Id: Idd204b90d4a5d5872b428a8185b669d7c5e315bc

protocol/wayland-tbm.xml
src/wayland-tbm-server.c
src/wayland-tbm-server.h

index 16f20795ac1a9762d02eac8eac06acc8856001a6..1169430e5e9909b23b2776ba6f02589b185f0536 100644 (file)
     <request name="dequeue_buffer">
       <arg name="buffer" type="object" interface="wl_buffer"/>
     </request>
+
+    <request name="wait_usable">
+    </request>
   </interface>
 
   <interface name="wl_tbm_monitor" version="2">
index 0affd194c86653e16a02b6c1c05847c86b19793b..0169d63e5bbd90cc11186781c29e2542318dcdb5 100644 (file)
@@ -92,7 +92,10 @@ struct wayland_tbm_client_queue {
        pid_t pid;
 
        wayland_tbm_server_client_queue_dequeue_cb dequeue_cb;
-       void *dequeue_cb_data;;
+       void *dequeue_cb_data;
+
+       wayland_tbm_server_client_queue_wait_usable_cb wait_usable_cb;
+       void *wait_usable_cb_data;
 
        struct wl_list link;
 };
@@ -485,10 +488,31 @@ _wayland_tbm_server_queue_impl_dequeue_buffer(struct wl_client *client,
                cqueue->dequeue_cb(cqueue, tbm_buffer->surface, cqueue->dequeue_cb_data);
 }
 
+static void
+_wayland_tbm_server_queue_impl_wait_usable(struct wl_client *client,
+                                     struct wl_resource *wl_tbm_queue)
+{
+       struct wayland_tbm_client_queue *cqueue = NULL;
+
+#ifdef DEBUG_TRACE
+       pid_t pid;
+
+       wl_client_get_credentials(client, &pid, NULL, NULL);
+       WL_TBM_TRACE("wait usable. pid:%d", pid);
+#endif
+
+       cqueue = wl_resource_get_user_data(wl_tbm_queue);
+       WL_TBM_RETURN_IF_FAIL(cqueue);
+
+       if (cqueue->wait_usable_cb)
+               cqueue->wait_usable_cb(cqueue, cqueue->wait_usable_cb_data);
+}
+
 static const struct wl_tbm_queue_interface _wayland_tbm_queue_impementation = {
        _wayland_tbm_server_queue_impl_destroy,
        _wayland_tbm_server_queue_impl_detach_buffer,
        _wayland_tbm_server_queue_impl_dequeue_buffer,
+       _wayland_tbm_server_queue_impl_wait_usable,
 };
 
 static void
@@ -1033,6 +1057,22 @@ wayland_tbm_server_client_queue_set_dequeue_cb(struct wayland_tbm_client_queue *
        return 1;
 }
 
+int
+wayland_tbm_server_client_queue_set_wait_usable_cb(struct wayland_tbm_client_queue *cqueue,
+                                       wayland_tbm_server_client_queue_wait_usable_cb wait_usable_cb, void *user_data)
+{
+       WL_TBM_RETURN_VAL_IF_FAIL(cqueue != NULL, 0);
+       WL_TBM_RETURN_VAL_IF_FAIL(cqueue->wl_tbm_queue != NULL, 0);
+
+#ifdef DEBUG_TRACE
+       WL_TBM_TRACE("    pid:%d", cqueue->pid);
+#endif
+       cqueue->wait_usable_cb = wait_usable_cb;
+       cqueue->wait_usable_cb_data = user_data;
+
+       return 1;
+}
+
 int
 wayland_tbm_server_client_queue_send_buffer_usable(struct wayland_tbm_client_queue *cqueue,
                                struct wl_resource *wl_buffer)
index fad8e0b066f248ffc2ad9f0b5ccd2e0cf11d1e07..934d9bc4127cce93e42926467d68cbae97d38159 100644 (file)
@@ -48,6 +48,9 @@ typedef void (*wayland_tbm_server_surface_detach_cb) (struct wayland_tbm_client_
 typedef void (*wayland_tbm_server_client_queue_dequeue_cb) (struct wayland_tbm_client_queue *cqueue,
                                        tbm_surface_h surface, void *data);
 
+typedef void (*wayland_tbm_server_client_queue_wait_usable_cb) (struct wayland_tbm_client_queue *cqueue,
+                                       void *data);
+
 struct wayland_tbm_server *
 wayland_tbm_server_init(struct wl_display *display,
                        const char *device_name,
@@ -129,6 +132,10 @@ int
 wayland_tbm_server_client_queue_send_buffer_usable(struct wayland_tbm_client_queue *cqueue,
                               struct wl_resource *wl_buffer);
 
+int
+wayland_tbm_server_client_queue_set_wait_usable_cb(struct wayland_tbm_client_queue *cqueue,
+                                       wayland_tbm_server_client_queue_wait_usable_cb wait_usable_cb, void *user_data);
+
 #ifdef  __cplusplus
 }
 #endif