From bb84bb650ddc1724bc3abb0ee8da8fa9ae34c9a4 Mon Sep 17 00:00:00 2001 From: George Matsumura Date: Sat, 25 Jul 2020 02:14:13 -0600 Subject: [PATCH] cogl: Ensure onscreen framebuffers have an alpha component if required Prior to this change, cogl often queried GLX so that it returned a framebuffer that could not support an alpha component. Signed-off-by: George Matsumura --- boilerplate/cairo-boilerplate-cogl.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/boilerplate/cairo-boilerplate-cogl.c b/boilerplate/cairo-boilerplate-cogl.c index ae42578fd..68ee5bd5d 100644 --- a/boilerplate/cairo-boilerplate-cogl.c +++ b/boilerplate/cairo-boilerplate-cogl.c @@ -115,7 +115,25 @@ _cairo_boilerplate_cogl_create_onscreen_color_surface (const char *name, if (height < 1) height = 1; - context = cogl_context_new (NULL, NULL); + if (content & CAIRO_CONTENT_ALPHA) { + /* A hackish way to ensure that we get a framebuffer with + * an alpha component */ + CoglSwapChain *swap_chain; + CoglOnscreenTemplate *onscreen_template; + CoglRenderer *renderer; + CoglDisplay *display; + + swap_chain = cogl_swap_chain_new (); + cogl_swap_chain_set_has_alpha (swap_chain, TRUE); + + onscreen_template = cogl_onscreen_template_new (swap_chain); + renderer = cogl_renderer_new (); + display = cogl_display_new (renderer, onscreen_template); + + context = cogl_context_new (display, NULL); + } else { + context = cogl_context_new (NULL, NULL); + } device = cairo_cogl_device_create (context);