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>
This commit is contained in:
parent
1ac3dd77d5
commit
9730fb64ea
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue