window: prevent EGL sub-surface deadlock
authorPekka Paalanen <ppaalanen@gmail.com>
Thu, 25 Apr 2013 10:57:51 +0000 (13:57 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 10 May 2013 18:35:54 +0000 (14:35 -0400)
commite9297f8e7ee09fa39b1d4293fad6e97705ccff21
tree3b26c6bd4aa086c97587b86ad02097e043f59d54
parent7ff7a80007fd27b2082e5219f4b4cb35948e3ed4
window: prevent EGL sub-surface deadlock

Mesa's eglSwapBuffers() waits for the frame event from the previous
swapBuffers, before it returns. Apparently eglSwapInterval(), which
should be able to disable the wait, is unimplemented for now.

When a sub-surface contains an EGL widget, and the commit mode is
synchronized, the frame events will not be delivered to EGL until the
parent surface gets committed. Therefore rendering the EGL widget twice
would lead to a deadlock.

When the window is being resized, we need to force a repaint of the EGL
widget, too, to make the whole window consistent. For that, we need to
make sure the frame event from the previous eglSwapBuffers() actually
arrives.

This patch adds an extra wl_surface.commit(parent), when the window is
being resized, which should guarantee, that the previous eglSwapBuffers
gets its event.

To properly handle an EGL widget in a sub-surface, running in its own
thread, the EGL widget's automatic updates should be paused before
sending the extra wl_surface.commit(parent). A natural place for the
pause would be in the widget's resize hook. However, wl_surface.commit
cannot be called right after resize hooks, because it would commit new,
incomplete surface state. Therefore this patch is not enough for
threaded toytoolkit applications.  Luckily those do not exist yet.

When eglSwapInterval() gets implemented, this patch should be reverted.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
clients/window.c