render/pixel-format: Move has_alpha into it's own array

Some opaque pixel formats (nv12, p010) require per-plane bytes_per_block
info. However, it doesn't make sense to store them in
wlr_pixel_format_info, as they will never be useful (currently, this
info is used for shm, which doesn't have a concept of multi-planar
buffers.)

Let's define a separate array and function for determining whether a
pixel format has alpha.
This commit is contained in:
Leo Li 2024-01-31 12:30:16 -05:00
parent 3a91dc1b48
commit 71fb55f3bf
5 changed files with 46 additions and 28 deletions

View file

@ -381,13 +381,10 @@ static struct wlr_texture *gles2_texture_from_dmabuf(
return NULL;
}
const struct wlr_pixel_format_info *drm_fmt =
drm_get_pixel_format_info(attribs->format);
texture->target = buffer->external_only ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
texture->buffer = buffer;
texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways
texture->has_alpha = drm_fmt ? drm_fmt->has_alpha : true;
texture->has_alpha = pixel_format_has_alpha(attribs->format);
struct wlr_egl_context prev_ctx;
wlr_egl_save_context(&prev_ctx);