Commit ae84f14f authored by Olivier Fourdan's avatar Olivier Fourdan
Browse files

xwayland: Add a flag to expose EGL backend features



The present flip does not work with the EGLStream backend. Similarly,
the EGLStream backend does not require the buffer to be flushed as
eglSwapBuffers() should take care of this.

Instead of actually checking the backend in use in the present code,
add a flag in the form of a bitfield to the EGL backend to indicate
its features and requirements.

This should not introduce any functional change.

v2: Fix logical test (Adam Jackson <ajax@redhat.com>)
Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
parent 239ebdc9
......@@ -939,4 +939,5 @@ xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
xwl_screen->eglstream_backend.post_damage = xwl_glamor_eglstream_post_damage;
xwl_screen->eglstream_backend.allow_commits = xwl_glamor_eglstream_allow_commits;
xwl_screen->eglstream_backend.is_available = TRUE;
xwl_screen->eglstream_backend.backend_flags = XWL_EGL_BACKEND_NO_FLAG;
}
......@@ -1116,4 +1116,6 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen)
xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen;
xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap;
xwl_screen->gbm_backend.is_available = TRUE;
xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_HAS_PRESENT_FLIP |
XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH;
}
......@@ -176,6 +176,26 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen,
return 0;
}
Bool
xwl_glamor_has_present_flip(struct xwl_screen *xwl_screen)
{
if (!xwl_screen->glamor || !xwl_screen->egl_backend)
return FALSE;
return (xwl_screen->egl_backend->backend_flags &
XWL_EGL_BACKEND_HAS_PRESENT_FLIP);
}
Bool
xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen)
{
if (!xwl_screen->glamor || !xwl_screen->egl_backend)
return FALSE;
return (xwl_screen->egl_backend->backend_flags &
XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH);
}
void
xwl_glamor_init_backends(struct xwl_screen *xwl_screen, Bool use_eglstream)
{
......
......@@ -32,10 +32,19 @@
#include "xwayland-types.h"
typedef enum _xwl_egl_backend_flags {
XWL_EGL_BACKEND_NO_FLAG = 0,
XWL_EGL_BACKEND_HAS_PRESENT_FLIP = (1 << 0),
XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH = (1 << 1),
} xwl_egl_backend_flags;
struct xwl_egl_backend {
/* Set by the backend if available */
Bool is_available;
/* Features and requirements set by the backend */
xwl_egl_backend_flags backend_flags;
/* Called once for each interface in the global registry. Backends
* should use this to bind to any wayland interfaces they need.
*/
......@@ -109,6 +118,9 @@ void xwl_glamor_post_damage(struct xwl_window *xwl_window,
PixmapPtr pixmap, RegionPtr region);
Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
Bool xwl_glamor_has_present_flip(struct xwl_screen *xwl_screen);
Bool xwl_glamor_needs_buffer_flush(struct xwl_screen *xwl_screen);
#ifdef XV
/* glamor Xv Adaptor */
......
......@@ -540,10 +540,7 @@ xwl_present_init(ScreenPtr screen)
{
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
/*
* doesn't work with the EGLStream backend.
*/
if (xwl_screen->egl_backend == &xwl_screen->eglstream_backend)
if (!xwl_glamor_has_present_flip(xwl_screen))
return FALSE;
if (!dixRegisterPrivateKey(&xwl_present_window_private_key, PRIVATE_WINDOW, 0))
......
......@@ -330,10 +330,8 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
return;
#ifdef XWL_HAS_GLAMOR
if (xwl_screen->glamor &&
xwl_screen->egl_backend == &xwl_screen->gbm_backend) {
if (xwl_glamor_needs_buffer_flush(xwl_screen))
glamor_block_handler(xwl_screen->screen);
}
#endif
xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment