frontend: add output-straight-alpha config option

This introduces a new .ini config option: output-straight-alpha. It's
currently only supported by the headless backend, and it forces
renderers to produce straight alpha framebuffers for headless backend
outputs.

For now, only the GL renderer supports creating straight alpha
framebuffers (the support was introduced in "backend-drm: add support
for KMS devices with only coverage blend mode").

This is useful mostly for testing, and the main motivation to add such
support in our DRM-backend and GL-renderer was to be able to support KMS
devices that only supports straight alpha framebuffers.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2026-05-20 14:40:27 -03:00 committed by Marius Vlad
parent 56f1793f76
commit bf00fef07d
4 changed files with 20 additions and 0 deletions

View file

@ -4217,6 +4217,7 @@ load_headless_backend(struct weston_compositor *c,
bool force_gl;
bool force_vulkan;
bool no_outputs = false;
bool output_straight_alpha;
char *transform = NULL;
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
@ -4232,6 +4233,8 @@ load_headless_backend(struct weston_compositor *c,
false);
weston_config_section_get_bool(section, "output-decorations", &config.decorate,
false);
weston_config_section_get_bool(section, "output-straight-alpha", &output_straight_alpha,
false);
const struct weston_option options[] = {
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
@ -4265,6 +4268,9 @@ load_headless_backend(struct weston_compositor *c,
config.renderer = renderer;
}
config.output_fb_alpha_encoding = output_straight_alpha ?
WESTON_OUTPUT_FB_ALPHA_STRAIGHT : WESTON_OUTPUT_FB_ALPHA_PREMULT;
if (transform) {
if (weston_parse_transform(transform, &parsed_options->transform) < 0) {
weston_log("Invalid transform \"%s\"\n", transform);

View file

@ -54,6 +54,11 @@ struct weston_headless_backend_config {
* The default is not to create a wl_seat.
*/
bool fake_seat;
/** Defines if renderers must produce straight or premultiplied alpha
* framebuffers for headless-backend outputs.
*/
enum weston_output_fb_alpha_encoding output_fb_alpha_encoding;
};
#ifdef __cplusplus

View file

@ -70,6 +70,7 @@ struct headless_backend {
int refresh;
bool repaint_only_on_capture;
enum weston_output_fb_alpha_encoding output_fb_alpha_encoding;
bool use_fake_seat;
};
@ -547,6 +548,7 @@ headless_output_create(struct weston_backend *backend, const char *name)
output->base.enable = headless_output_enable;
output->base.attach_head = NULL;
output->base.repaint_only_on_capture = b->repaint_only_on_capture;
output->base.fb_alpha_encoding = b->output_fb_alpha_encoding;
output->backend = b;
@ -680,6 +682,7 @@ headless_backend_create(struct weston_compositor *compositor,
b->base.create_output = headless_output_create;
b->decorate = config->decorate;
b->output_fb_alpha_encoding = config->output_fb_alpha_encoding;
if (b->decorate) {
b->theme = theme_create();
if (!b->theme) {
@ -786,6 +789,7 @@ config_init_to_defaults(struct weston_headless_backend_config *config)
{
config->refresh = DEFAULT_OUTPUT_REPAINT_REFRESH;
config->fake_seat = false;
config->output_fb_alpha_encoding = WESTON_OUTPUT_FB_ALPHA_PREMULT;
}
WL_EXPORT int

View file

@ -237,6 +237,11 @@ Boolean, defaults to
These decorations cannot normally be screenshot. This option is useful for
the Weston test suite only.
.TP 7
.BI "output-straight-alpha=" true
Require straight alpha framebuffers from renderers for outputs. Only supported
by the headless backend. Boolean, defaults to
.BR false .
.TP 7
.BI "placeholder-color=" 0xRRGGBB
sets the color of the placeholder (unsigned integer). The hexadecimal digit
pairs are in order red, green, and blue. This placeholder is used for