[RFC PATCH] window: do proper Cairo device flushing
Pekka Paalanen
ppaalanen at gmail.com
Tue Dec 13 00:29:16 PST 2011
The Cairo documentation tells us to always call cairo_device_flush()
before using other rendering APIs on the cairo surface, especially where
the Cairo device shares state with us (that is, EGL and GL state in this
case).
Add a call to cairo_device_flush() into display_acquire_window_surface(),
which the toytoolkit offers for switching to native (GL) rendering.
Drawback:
So far, we have usually been using Cairo
commit 9bdfae6e218185dd9cc2770f5e7d4ca887ce
"boilerplate/xcb: Fix silly cut'n'paste errors in previous commit"
to get an arbitrary version of Cairo where the GL backend is not too
broken and works with Wayland.
Adding device flushing breaks cairo_gl_surface_swapbuffers(), which we
may call via window_flush() in toytoolkit. Also, application windows
without decorations have been broken for pure EGL rendering to begin
with.
The fix in Cairo is commit 909f4a4a7f0a6082f4f1e9edaba8034a819a12ec
"gl: Set the destination for swap buffers, required by EGL at least".
After adding cairo_device_flush(), the fix is necessary for all Wayland
demo clients using native EGL rendering with toytoolkit. The fix also
fixes the decorationless EGL case.
The Cairo fix allows wscreensaver to work without decorations, which
would otherwise require a hack in toytoolkit.
Unfortunately, at the time of writing this, the Cairo master HEAD is
still too broken in the GL backend to be used. Therefore I suggest to
use Cairo 9bdfae6e218185dd9cc2770f5e7d4ca887ce and add the above fix on
top.
Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
clients/window.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index e0693da..2c2d826 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -988,11 +988,6 @@ window_draw_decorations(struct window *window)
cairo_show_text(cr, window->title);
cairo_destroy(cr);
-
- /* FIXME: this breakes gears, fix cairo? */
-#if 0
- cairo_device_flush (window->display->device);
-#endif
}
void
@@ -2470,6 +2465,7 @@ display_acquire_window_surface(struct display *display,
data = cairo_surface_get_user_data(window->cairo_surface,
&surface_data_key);
+ cairo_device_flush(device);
cairo_device_acquire(device);
if (!eglMakeCurrent(display->dpy, data->surf, data->surf, ctx))
fprintf(stderr, "failed to make surface current\n");
--
1.7.3.4
More information about the wayland-devel
mailing list