diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2023-03-28 17:57:31 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2023-04-03 11:46:15 +0200 |
commit | 9730fb64ea05c620c90a23eb9999128e43752ec1 (patch) | |
tree | 0aa37b632c4c7c2b2c55023bd27999a62a4e36eb | |
parent | 1ac3dd77d5adbcc0eb4365b2ff08460826ec1be1 (diff) | |
download | xserver-9730fb64ea05c620c90a23eb9999128e43752ec1.tar.gz |
xwayland: Add create_pixmap_for_window() to GBM backend
Add the implementation for create_pixmap_for_window() in the GBM glamor
backend.
To do so, we just rename the existing xwl_glamor_gbm_create_pixmap() as
internal and add an optional drawable parameter, so that it can be used
either from the regular CreatePixmap code path, or from the new direct
Xwayland glamor's hook.
v2: Fallback to xwl_glamor_get_modifiers() if
xwl_glamor_get_drawable_modifiers() returned 0 modifiers. (Michel)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
-rw-r--r-- | hw/xwayland/xwayland-glamor-gbm.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 04cb5bc23..1474eb15d 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -275,11 +275,11 @@ error: } static PixmapPtr -xwl_glamor_gbm_create_pixmap(ScreenPtr screen, - int width, int height, int depth, - unsigned int hint) +xwl_glamor_gbm_create_pixmap_internal(struct xwl_screen *xwl_screen, + DrawablePtr drawable, + int width, int height, int depth, + unsigned int hint) { - struct xwl_screen *xwl_screen = xwl_screen_get(screen); struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); struct gbm_bo *bo = NULL; PixmapPtr pixmap = NULL; @@ -293,10 +293,18 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, #ifdef GBM_BO_WITH_MODIFIERS if (xwl_gbm->dmabuf_capable) { - uint32_t num_modifiers; + uint32_t num_modifiers = 0; uint64_t *modifiers = NULL; - xwl_glamor_get_modifiers(screen, format, &num_modifiers, &modifiers); + if (drawable) { + xwl_glamor_get_drawable_modifiers(drawable, format, + &num_modifiers, &modifiers); + } + + if (num_modifiers == 0) { + xwl_glamor_get_modifiers(xwl_screen->screen, format, + &num_modifiers, &modifiers); + } if (num_modifiers > 0) bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height, @@ -311,7 +319,7 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, } if (bo) { - pixmap = xwl_glamor_gbm_create_pixmap_for_bo(screen, bo, depth, implicit); + pixmap = xwl_glamor_gbm_create_pixmap_for_bo(xwl_screen->screen, bo, depth, implicit); if (!pixmap) { gbm_bo_destroy(bo); @@ -323,11 +331,34 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, } if (!pixmap) - pixmap = glamor_create_pixmap(screen, width, height, depth, hint); + pixmap = glamor_create_pixmap(xwl_screen->screen, width, height, depth, hint); return pixmap; } +static PixmapPtr +xwl_glamor_gbm_create_pixmap(ScreenPtr screen, + int width, int height, int depth, + unsigned int hint) +{ + return xwl_glamor_gbm_create_pixmap_internal(xwl_screen_get(screen), NULL, + width, height, depth, hint); +} + +static PixmapPtr +xwl_glamor_gbm_create_pixmap_for_window(struct xwl_window *xwl_window) +{ + if (xwl_window->window == NullWindow) + return NullPixmap; + + return xwl_glamor_gbm_create_pixmap_internal(xwl_window->xwl_screen, + &xwl_window->window->drawable, + xwl_window->window->drawable.width, + xwl_window->window->drawable.height, + xwl_window->window->drawable.depth, + CREATE_PIXMAP_USAGE_BACKING_PIXMAP); +} + static Bool xwl_glamor_gbm_destroy_pixmap(PixmapPtr pixmap) { @@ -1205,4 +1236,5 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen) xwl_screen->gbm_backend.is_available = TRUE; xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH | XWL_EGL_BACKEND_NEEDS_N_BUFFERING; + xwl_screen->gbm_backend.create_pixmap_for_window = xwl_glamor_gbm_create_pixmap_for_window; } |