1
0
Fork 0

drm-buffer: Handle both XR24 and AR24 in legacy path

drmModeAddFB() doesn't take a format, but depth and bits per pixel.
These can be used to determine whether there should be an alpha channel
or not, and is roughly assumed to result in either XR24 or AR24 if one
passes 24 or 32 as depth, with 32 as bpp.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3926>
This commit is contained in:
Jonas Ådahl 2024-08-06 21:36:37 +02:00 committed by Marge Bot
parent fd598e1868
commit 86c9d602cd

View file

@ -122,7 +122,11 @@ meta_drm_buffer_do_ensure_fb_id (MetaDrmBuffer *buffer,
&fb_id,
0))
{
if (fb_args->format != DRM_FORMAT_XRGB8888)
uint8_t depth;
uint8_t bpp;
if (fb_args->format != DRM_FORMAT_XRGB8888 &&
fb_args->format != DRM_FORMAT_ARGB8888)
{
g_set_error (error,
G_IO_ERROR,
@ -135,11 +139,23 @@ meta_drm_buffer_do_ensure_fb_id (MetaDrmBuffer *buffer,
return FALSE;
}
switch (fb_args->format)
{
case DRM_FORMAT_XRGB8888:
depth = 24;
bpp = 32;
break;
case DRM_FORMAT_ARGB8888:
depth = 32;
bpp = 32;
break;
}
if (drmModeAddFB (fd,
fb_args->width,
fb_args->height,
24,
32,
depth,
bpp,
fb_args->strides[0],
fb_args->handles[0],
&fb_id))