pixel-formats: Add internal-only format flag

Add a new hide_from_clients flag which, if set, specifies that the
format is only for internal information and processing, and should not
be advertised for clients.

This will be used for formats like R8 and GR88, which are not useful for
client buffers, but are used internally to implement YUV -> RGB
conversion.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2022-04-28 01:44:19 +01:00 committed by Pekka Paalanen
parent 32ee42d261
commit 1db2fbef61
3 changed files with 10 additions and 3 deletions

View File

@ -2439,7 +2439,7 @@ weston_buffer_from_resource(struct weston_compositor *ec,
pixel_format_get_info_shm(wl_shm_buffer_get_format(shm));
buffer->format_modifier = DRM_FORMAT_MOD_LINEAR;
if (!buffer->pixel_format)
if (!buffer->pixel_format || buffer->pixel_format->hide_from_clients)
goto fail;
} else if ((dmabuf = linux_dmabuf_buffer_get(buffer->resource))) {
buffer->type = WESTON_BUFFER_DMABUF;
@ -2451,7 +2451,7 @@ weston_buffer_from_resource(struct weston_compositor *ec,
pixel_format_get_info(dmabuf->attributes.format);
/* dmabuf import should assure we don't create a buffer with an
* unknown format */
assert(buffer->pixel_format);
assert(buffer->pixel_format && !buffer->pixel_format->hide_from_clients);
buffer->format_modifier = dmabuf->attributes.modifier[0];
if (dmabuf->attributes.flags & ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT)
buffer->buffer_origin = ORIGIN_BOTTOM_LEFT;

View File

@ -42,6 +42,10 @@ struct pixel_format_info {
/** The DRM format name without the DRM_FORMAT_ prefix. */
const char *drm_format_name;
/** If true, is only for internal use and should not be advertised to
* clients to allow them to create buffers of this format. */
bool hide_from_clients;
/** If non-zero, number of planes in base (non-modified) format. */
int num_planes;

View File

@ -2796,7 +2796,10 @@ populate_supported_formats(struct weston_compositor *ec,
return 0;
for (i = 0; i < num_formats; i++) {
if (!pixel_format_get_info(formats[i]))
const struct pixel_format_info *info =
pixel_format_get_info(formats[i]);
if (!info || info->hide_from_clients)
continue;
fmt = weston_drm_format_array_add_format(supported_formats,