summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2016-01-11 19:04:37 +0000
committerDerek Foreman <derekf@osg.samsung.com>2016-01-11 13:31:48 -0600
commit8ef2957873fcb6f04b1ec6e5de6b43f63d277e62 (patch)
treee152c3c0658ae806987162225d5b0738c424c268
parent3b65b0b38f63e46bbf2b3aae5a71ba2fa9c7545a (diff)
downloadweston-8ef2957873fcb6f04b1ec6e5de6b43f63d277e62.tar.gz
clients: Fix a few issues in simple-dmabuf-intel
Those were found while working on simple-dmabuf-v4l, as found in the next patch of this series. After each buffer’s params were ready to be submitted to the compositor, a roundtrip was done, which is wasteful since we can do it only once after having queued all the params we want. Removing those nested roundtrips also prevent the potentially dangerous side-effect of calling callbacks for later events while previous events were still being processed. An extraneous surface damage was also removed. Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Differential Revision: https://phabricator.freedesktop.org/D344
-rw-r--r--clients/simple-dmabuf-intel.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index f371d804..0ceefebb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -35,9 +35,9 @@
#include <fcntl.h>
#include <xf86drm.h>
-#include <libdrm/i915_drm.h>
-#include <libdrm/intel_bufmgr.h>
-#include <libdrm/drm_fourcc.h>
+#include <i915_drm.h>
+#include <intel_bufmgr.h>
+#include <drm_fourcc.h>
#include <wayland-client.h>
#include "xdg-shell-unstable-v5-client-protocol.h"
@@ -204,6 +204,7 @@ create_failed(void *data, struct zwp_linux_buffer_params_v1 *params)
struct buffer *buffer = data;
buffer->buffer = NULL;
+ running = 0;
zwp_linux_buffer_params_v1_destroy(params);
@@ -274,13 +275,6 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer,
DRM_FORMAT_XRGB8888,
flags);
- /* params is destroyed by the event handlers */
-
- wl_display_roundtrip(display->display);
- if (buffer->buffer == NULL) {
- goto error2;
- }
-
return 0;
error2:
@@ -313,6 +307,8 @@ static struct window *
create_window(struct display *display, int width, int height)
{
struct window *window;
+ int i;
+ int ret;
window = calloc(1, sizeof *window);
if (!window)
@@ -344,6 +340,14 @@ create_window(struct display *display, int width, int height)
assert(0);
}
+ for (i = 0; i < 2; ++i) {
+ ret = create_dmabuf_buffer(display, &window->buffers[i],
+ width, height);
+
+ if (ret < 0)
+ return NULL;
+ }
+
return window;
}
@@ -375,7 +379,6 @@ static struct buffer *
window_next_buffer(struct window *window)
{
struct buffer *buffer;
- int ret = 0;
if (!window->buffers[0].busy)
buffer = &window->buffers[0];
@@ -384,14 +387,6 @@ window_next_buffer(struct window *window)
else
return NULL;
- if (!buffer->buffer) {
- ret = create_dmabuf_buffer(window->display, buffer,
- window->width, window->height);
-
- if (ret < 0)
- return NULL;
- }
-
return buffer;
}
@@ -574,9 +569,11 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
- /* Initialise damage to full surface, so the padding gets painted */
- wl_surface_damage(window->surface, 0, 0,
- window->width, window->height);
+ /* Here we retrieve the linux-dmabuf objects, or error */
+ wl_display_roundtrip(display->display);
+
+ if (!running)
+ return 1;
redraw(window, NULL, 0);