gl-renderer: do not set compositor capabilities on failure

When gl_renderer_display_create() fails, do not change the compositor
capabilities.

The compositor may not abort when that happens, it may simply decide to
fallback to another renderer. So setting anything on failure is wrong.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2025-02-14 21:38:17 -03:00
parent c10857df5d
commit ed7ceef37e

View file

@ -4688,14 +4688,6 @@ gl_renderer_display_create(struct weston_compositor *ec,
if (gl_renderer_setup(ec) < 0)
goto fail_terminate;
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
ec->capabilities |= WESTON_CAP_VIEW_CLIP_MASK;
if (gl_features_has(gr, FEATURE_EXPLICIT_SYNC))
ec->capabilities |= WESTON_CAP_EXPLICIT_SYNC;
if (gl_features_has(gr, FEATURE_COLOR_TRANSFORMS))
ec->capabilities |= WESTON_CAP_COLOR_OPS;
if (gr->allocator)
gr->base.dmabuf_alloc = gl_renderer_dmabuf_alloc;
@ -4769,6 +4761,19 @@ gl_renderer_display_create(struct weston_compositor *ec,
yuv_formats[i].format);
}
/**
* Keep this at the end of the function. We don't want to change the
* caps if something fails, as the compositor may fallback to another
* renderer and the caps we set here would be invalid.
*/
ec->capabilities |= WESTON_CAP_ROTATION_ANY;
ec->capabilities |= WESTON_CAP_CAPTURE_YFLIP;
ec->capabilities |= WESTON_CAP_VIEW_CLIP_MASK;
if (gl_features_has(gr, FEATURE_EXPLICIT_SYNC))
ec->capabilities |= WESTON_CAP_EXPLICIT_SYNC;
if (gl_features_has(gr, FEATURE_COLOR_TRANSFORMS))
ec->capabilities |= WESTON_CAP_COLOR_OPS;
return 0;
fail_with_error: