summaryrefslogtreecommitdiff
path: root/hw/xwayland
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2020-09-14 14:26:34 +0200
committerOlivier Fourdan <ofourdan@redhat.com>2020-09-22 17:59:42 +0200
commitae84f14fb554e5ad54c51c2e6d52ab4a68bf7a0a (patch)
treef146c12cbe26770a7527f5cf7d97bdaa51e5e9f4 /hw/xwayland
parent239ebdc9e447d4f836d0c2aa6068c6064fffb46c (diff)
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: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'hw/xwayland')
-rw-r--r--hw/xwayland/xwayland-glamor-eglstream.c1
-rw-r--r--hw/xwayland/xwayland-glamor-gbm.c2
-rw-r--r--hw/xwayland/xwayland-glamor.c20
-rw-r--r--hw/xwayland/xwayland-glamor.h12
-rw-r--r--hw/xwayland/xwayland-present.c5
-rw-r--r--hw/xwayland/xwayland-screen.c4
6 files changed, 37 insertions, 7 deletions
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
index a344c2993..ee7f95b56 100644
--- a/hw/xwayland/xwayland-glamor-eglstream.c
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
@@ -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;
}
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 396188070..0a76b60a2 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -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;
}
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index d9523b0a7..3c439f304 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -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)
{
diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h
index e9896bfef..07b08a828 100644
--- a/hw/xwayland/xwayland-glamor.h
+++ b/hw/xwayland/xwayland-glamor.h
@@ -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 */
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index afcd03187..d36b47149 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -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))
diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index 92643c0ed..bc6751be7 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -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,