compositor-drm: Fix multi head rendering
diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c
index 7580472..524a25c 100644
--- a/compositor/compositor-wayland.c
+++ b/compositor/compositor-wayland.c
@@ -163,19 +163,31 @@
wlsc_compositor_finish_frame(&c->base, time);
}
+static int
+wayland_output_prepare_render(struct wlsc_output *output_base)
+{
+ struct wayland_output *output = (struct wayland_output *) output_base;
+ struct wlsc_compositor *ec = output->base.compositor;
+
+ if (!eglMakeCurrent(ec->display, output->egl_surface,
+ output->egl_surface, ec->context)) {
+ fprintf(stderr, "failed to make current\n");
+ return -1;
+ }
+
+ return 0;
+}
+
static void
wayland_compositor_present(struct wlsc_compositor *base)
{
struct wayland_compositor *c = (struct wayland_compositor *) base;
struct wayland_output *output;
-
wl_list_for_each(output, &base->output_list, base.link) {
- if (!eglMakeCurrent(c->base.display, output->egl_surface,
- output->egl_surface, c->base.context)) {
- fprintf(stderr, "failed to make current\n");
+ if (wayland_output_prepare_render(&output->base))
continue;
- }
+
eglSwapBuffers(c->base.display, output->egl_surface);
}
@@ -230,6 +242,8 @@
glClearColor(0, 0, 0, 0.5);
+ output->base.prepare_render = wayland_output_prepare_render;
+
wl_list_insert(c->base.output_list.prev, &output->base.link);
return 0;