[PATCH weston v2 2/2] clients/simple-dmabuf-intel: request no-roundtrip dmabuf import
Varad Gautam
varadgautam at gmail.com
Thu Jan 19 07:21:55 UTC 2017
From: Varad Gautam <varad.gautam at collabora.com>
request immediate dmabuf import when run with "immed" arg.
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
clients/simple-dmabuf-intel.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index ec5f1cb..9917a74 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -54,6 +54,7 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb8888_format_found;
+ int req_dmabuf_immediate;
};
struct buffer {
@@ -279,7 +280,16 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer,
modifier >> 32,
modifier & 0xffffffff);
zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, buffer);
- zwp_linux_buffer_params_v1_create(params,
+ if (display->req_dmabuf_immediate) {
+ buffer->buffer = zwp_linux_buffer_params_v1_create_immed(params,
+ buffer->width,
+ buffer->height,
+ DRM_FORMAT_XRGB8888,
+ flags);
+ wl_buffer_add_listener(buffer->buffer, &buffer_listener, buffer);
+ }
+ else
+ zwp_linux_buffer_params_v1_create(params,
buffer->width,
buffer->height,
DRM_FORMAT_XRGB8888,
@@ -503,7 +513,8 @@ registry_handle_global(void *data, struct wl_registry *registry,
id, &zwp_fullscreen_shell_v1_interface, 1);
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
d->dmabuf = wl_registry_bind(registry,
- id, &zwp_linux_dmabuf_v1_interface, 1);
+ id, &zwp_linux_dmabuf_v1_interface,
+ d->req_dmabuf_immediate ? 2 : 1);
zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, d);
}
}
@@ -520,7 +531,7 @@ static const struct wl_registry_listener registry_listener = {
};
static struct display *
-create_display(void)
+create_display(int is_immediate)
{
struct display *display;
@@ -534,6 +545,7 @@ create_display(void)
/* XXX: fake, because the compositor does not yet advertise anything */
display->xrgb8888_format_found = 1;
+ display->req_dmabuf_immediate = is_immediate;
display->registry = wl_display_get_registry(display->display);
wl_registry_add_listener(display->registry,
@@ -587,9 +599,22 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display *display;
struct window *window;
+ int is_immediate = 0;
int ret = 0;
- display = create_display();
+ if (argc > 1) {
+ if (!strcmp(argv[1], "immed")) {
+ is_immediate = 1;
+ }
+ else {
+ fprintf(stderr, "usage:\n\tsimple-dmabuf-intel [options]\n"
+ "available options:\n\timmed: avoid dmabuf "
+ "creation roundtrip and import immediately\n");
+ return 1;
+ }
+ }
+
+ display = create_display(is_immediate);
window = create_window(display, 250, 250);
if (!window)
return 1;
@@ -599,7 +624,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
- /* Here we retrieve the linux-dmabuf objects, or error */
+ /* Here we retrieve the linux-dmabuf objects if executed without immed,
+ * or error */
wl_display_roundtrip(display->display);
if (!running)
--
2.6.2
More information about the wayland-devel
mailing list