mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-13 08:22:16 -04:00
render/pixel_format: add pixel_format_get_opaque_substitute()
We'll soon move opaque substitutes outside of the format table. Prepare the work by introducing a separate function to get this piece of information.
This commit is contained in:
parent
f295d0322a
commit
2d95d8d292
4 changed files with 20 additions and 10 deletions
|
|
@ -163,11 +163,10 @@ static struct wlr_drm_fb *drm_fb_create(struct wlr_drm_backend *drm,
|
|||
attribs.modifier)) {
|
||||
// The format isn't supported by the plane. Try stripping the alpha
|
||||
// channel, if any.
|
||||
const struct wlr_pixel_format_info *info =
|
||||
drm_get_pixel_format_info(attribs.format);
|
||||
if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
|
||||
wlr_drm_format_set_has(formats, info->opaque_substitute, attribs.modifier)) {
|
||||
attribs.format = info->opaque_substitute;
|
||||
uint32_t opaque_substitute = pixel_format_get_opaque_substitute(attribs.format);
|
||||
if (opaque_substitute != DRM_FORMAT_INVALID &&
|
||||
wlr_drm_format_set_has(formats, opaque_substitute, attribs.modifier)) {
|
||||
attribs.format = opaque_substitute;
|
||||
} else {
|
||||
wlr_log(WLR_DEBUG, "Buffer format 0x%"PRIX32" with modifier "
|
||||
"0x%"PRIX64" cannot be scanned out",
|
||||
|
|
|
|||
|
|
@ -157,11 +157,8 @@ bool drm_plane_pick_render_format(struct wlr_drm_plane *plane,
|
|||
|
||||
uint32_t format = DRM_FORMAT_ARGB8888;
|
||||
if (!wlr_drm_format_set_get(&plane->formats, format)) {
|
||||
const struct wlr_pixel_format_info *format_info =
|
||||
drm_get_pixel_format_info(format);
|
||||
assert(format_info != NULL &&
|
||||
format_info->opaque_substitute != DRM_FORMAT_INVALID);
|
||||
format = format_info->opaque_substitute;
|
||||
format = pixel_format_get_opaque_substitute(format);
|
||||
assert(format != DRM_FORMAT_INVALID);
|
||||
}
|
||||
|
||||
const struct wlr_drm_format *render_format =
|
||||
|
|
|
|||
|
|
@ -68,4 +68,10 @@ bool pixel_format_has_alpha(uint32_t fmt);
|
|||
*/
|
||||
bool pixel_format_is_ycbcr(uint32_t fmt);
|
||||
|
||||
/**
|
||||
* Get the equivalent opaque variant of a format if it has an alpha channel,
|
||||
* DRM_FORMAT_INVALID otherwise.
|
||||
*/
|
||||
uint32_t pixel_format_get_opaque_substitute(uint32_t fmt);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -372,3 +372,11 @@ bool pixel_format_is_ycbcr(uint32_t format) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t pixel_format_get_opaque_substitute(uint32_t fmt) {
|
||||
const struct wlr_pixel_format_info *info = drm_get_pixel_format_info(fmt);
|
||||
if (info == NULL) {
|
||||
return DRM_FORMAT_INVALID;
|
||||
}
|
||||
return info->opaque_substitute;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue