diff --git a/libweston/compositor.c b/libweston/compositor.c index b37a93bd..cd053d1a 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -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; diff --git a/libweston/pixel-formats.h b/libweston/pixel-formats.h index c14a3ed4..bbd1bff8 100644 --- a/libweston/pixel-formats.h +++ b/libweston/pixel-formats.h @@ -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; diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 2eeefcbb..31bb74ac 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -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,