From d857edf09c0fbff3d6314f97ce1e5a36ec72dbbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 9 Jul 2020 20:58:20 +0200 Subject: [PATCH] clutter: Remove support for transparent windows We're only ever a compositor, so we're never asking to be transparent. Thus remove support for requesting to paint to GLX or EGL displays with an alpha channel. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364 --- clutter/clutter/x11/clutter-backend-x11.c | 89 ++----------------- clutter/clutter/x11/clutter-x11.h | 5 -- cogl/cogl/cogl-swap-chain-private.h | 2 - cogl/cogl/cogl-swap-chain.c | 7 -- cogl/cogl/winsys/cogl-glx-display-private.h | 1 - cogl/cogl/winsys/cogl-winsys-egl.c | 2 +- cogl/cogl/winsys/cogl-winsys-glx.c | 41 +-------- .../clutter/interactive/test-paint-wrapper.c | 4 - 8 files changed, 12 insertions(+), 139 deletions(-) diff --git a/clutter/clutter/x11/clutter-backend-x11.c b/clutter/clutter/x11/clutter-backend-x11.c index 697334b9a..e4bc3b8df 100644 --- a/clutter/clutter/x11/clutter-backend-x11.c +++ b/clutter/clutter/x11/clutter-backend-x11.c @@ -98,7 +98,6 @@ static const gchar *atom_names[] = { /* various flags corresponding to pre init setup calls */ static gboolean clutter_enable_xinput = TRUE; -static gboolean clutter_enable_argb = FALSE; static gboolean clutter_enable_stereo = FALSE; static Display *_foreign_dpy = NULL; @@ -240,13 +239,6 @@ clutter_backend_x11_pre_parse (ClutterBackend *backend, env_string = NULL; } - env_string = g_getenv ("CLUTTER_DISABLE_ARGB_VISUAL"); - if (env_string) - { - clutter_enable_argb = FALSE; - env_string = NULL; - } - env_string = g_getenv ("CLUTTER_DISABLE_XINPUT"); if (env_string) { @@ -550,15 +542,12 @@ clutter_backend_x11_get_renderer (ClutterBackend *backend, static gboolean check_onscreen_template (CoglRenderer *renderer, - CoglSwapChain *swap_chain, CoglOnscreenTemplate *onscreen_template, - gboolean enable_argb, gboolean enable_stereo, GError **error) { GError *internal_error = NULL; - cogl_swap_chain_set_has_alpha (swap_chain, enable_argb); cogl_onscreen_template_set_stereo_enabled (onscreen_template, clutter_enable_stereo); @@ -573,17 +562,15 @@ check_onscreen_template (CoglRenderer *renderer, */ if (cogl_renderer_check_onscreen_template (renderer, onscreen_template, &internal_error)) { - clutter_enable_argb = enable_argb; clutter_enable_stereo = enable_stereo; return TRUE; } else { - if (enable_argb || enable_stereo) /* More possibilities to try */ + if (enable_stereo) /* More possibilities to try */ CLUTTER_NOTE (BACKEND, - "Creation of a CoglDisplay with alpha=%s, stereo=%s failed: %s", - enable_argb ? "enabled" : "disabled", + "Creation of a CoglDisplay with, stereo=%s failed: %s", enable_stereo ? "enabled" : "disabled", internal_error != NULL ? internal_error->message @@ -611,8 +598,7 @@ clutter_backend_x11_get_display (ClutterBackend *backend, CoglDisplay *display = NULL; gboolean res = FALSE; - CLUTTER_NOTE (BACKEND, "Creating CoglDisplay, alpha=%s, stereo=%s", - clutter_enable_argb ? "enabled" : "disabled", + CLUTTER_NOTE (BACKEND, "Creating CoglDisplay, stereo=%s", clutter_enable_stereo ? "enabled" : "disabled"); onscreen_template = cogl_onscreen_template_new (swap_chain); @@ -620,22 +606,13 @@ clutter_backend_x11_get_display (ClutterBackend *backend, /* It's possible that the current renderer doesn't support transparency * or doesn't support stereo, so we try the different combinations. */ - if (clutter_enable_argb && clutter_enable_stereo) - res = check_onscreen_template (renderer, swap_chain, onscreen_template, - TRUE, TRUE, error); - - /* Prioritize stereo over alpha */ - if (!res && clutter_enable_stereo) - res = check_onscreen_template (renderer, swap_chain, onscreen_template, - FALSE, TRUE, error); - - if (!res && clutter_enable_argb) - res = check_onscreen_template (renderer, swap_chain, onscreen_template, - TRUE, FALSE, error); + if (clutter_enable_stereo) + res = check_onscreen_template (renderer, onscreen_template, + TRUE, error); if (!res) - res = check_onscreen_template (renderer, swap_chain, onscreen_template, - FALSE, FALSE, error); + res = check_onscreen_template (renderer, onscreen_template, + FALSE, error); if (res) display = cogl_display_new (renderer, onscreen_template); @@ -972,56 +949,6 @@ clutter_x11_has_composite_extension (void) return have_composite; } -/** - * clutter_x11_set_use_argb_visual: - * @use_argb: %TRUE if ARGB visuals should be requested by default - * - * Sets whether the Clutter X11 backend should request ARGB visuals by default - * or not. - * - * By default, Clutter requests RGB visuals. - * - * If no ARGB visuals are found, the X11 backend will fall back to - * requesting a RGB visual instead. - * - * ARGB visuals are required for the #ClutterStage:use-alpha property to work. - * - * This function can only be called once, and before clutter_init() is - * called. - * - * Since: 1.2 - */ -void -clutter_x11_set_use_argb_visual (gboolean use_argb) -{ - if (_clutter_context_is_initialized ()) - { - g_warning ("%s() can only be used before calling clutter_init()", - G_STRFUNC); - return; - } - - CLUTTER_NOTE (BACKEND, "ARGB visuals are %s", - use_argb ? "enabled" : "disabled"); - - clutter_enable_argb = use_argb; -} - -/** - * clutter_x11_get_use_argb_visual: - * - * Retrieves whether the Clutter X11 backend is using ARGB visuals by default - * - * Return value: %TRUE if ARGB visuals are queried by default - * - * Since: 1.2 - */ -gboolean -clutter_x11_get_use_argb_visual (void) -{ - return clutter_enable_argb; -} - /** * clutter_x11_set_use_stereo_stage: * @use_stereo: %TRUE if the stereo stages should be used if possible. diff --git a/clutter/clutter/x11/clutter-x11.h b/clutter/clutter/x11/clutter-x11.h index bf58e6f56..a257360c7 100644 --- a/clutter/clutter/x11/clutter-x11.h +++ b/clutter/clutter/x11/clutter-x11.h @@ -112,11 +112,6 @@ void clutter_x11_remove_filter (ClutterX11FilterFunc func, CLUTTER_EXPORT gboolean clutter_x11_has_composite_extension (void); -CLUTTER_EXPORT -void clutter_x11_set_use_argb_visual (gboolean use_argb); -CLUTTER_EXPORT -gboolean clutter_x11_get_use_argb_visual (void); - CLUTTER_EXPORT void clutter_x11_set_use_stereo_stage (gboolean use_stereo); CLUTTER_EXPORT diff --git a/cogl/cogl/cogl-swap-chain-private.h b/cogl/cogl/cogl-swap-chain-private.h index 34c2e2120..3e14c2932 100644 --- a/cogl/cogl/cogl-swap-chain-private.h +++ b/cogl/cogl/cogl-swap-chain-private.h @@ -37,8 +37,6 @@ struct _CoglSwapChain { CoglObject _parent; - gboolean has_alpha; - int length; }; diff --git a/cogl/cogl/cogl-swap-chain.c b/cogl/cogl/cogl-swap-chain.c index 89bab0049..a01f2d4db 100644 --- a/cogl/cogl/cogl-swap-chain.c +++ b/cogl/cogl/cogl-swap-chain.c @@ -59,13 +59,6 @@ cogl_swap_chain_new (void) return _cogl_swap_chain_object_new (swap_chain); } -void -cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain, - gboolean has_alpha) -{ - swap_chain->has_alpha = has_alpha; -} - void cogl_swap_chain_set_length (CoglSwapChain *swap_chain, int length) diff --git a/cogl/cogl/winsys/cogl-glx-display-private.h b/cogl/cogl/winsys/cogl-glx-display-private.h index 265868c40..f931b1764 100644 --- a/cogl/cogl/winsys/cogl-glx-display-private.h +++ b/cogl/cogl/winsys/cogl-glx-display-private.h @@ -50,7 +50,6 @@ typedef struct _CoglGLXDisplay CoglGLXCachedConfig glx_cached_configs[COGL_GLX_N_CACHED_CONFIGS]; gboolean found_fbconfig; - gboolean fbconfig_has_rgba_visual; gboolean is_direct; gboolean have_vblank_counter; gboolean can_vblank_wait; diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c index 8c999c52b..6aaac8ef8 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/cogl/winsys/cogl-winsys-egl.c @@ -223,7 +223,7 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display, attributes[i++] = 1; attributes[i++] = EGL_ALPHA_SIZE; - attributes[i++] = config->swap_chain->has_alpha ? 1 : EGL_DONT_CARE; + attributes[i++] = EGL_DONT_CARE; attributes[i++] = EGL_DEPTH_SIZE; attributes[i++] = 1; diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 0b1c1eac2..452a88060 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -885,7 +885,7 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display, attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1; attributes[i++] = GLX_ALPHA_SIZE; - attributes[i++] = config->swap_chain->has_alpha ? 1 : GLX_DONT_CARE; + attributes[i++] = GLX_DONT_CARE; attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1; attributes[i++] = GLX_STENCIL_SIZE; @@ -944,40 +944,8 @@ find_fbconfig (CoglDisplay *display, goto done; } - if (config->swap_chain->has_alpha) - { - int i; - - for (i = 0; i < n_configs; i++) - { - XVisualInfo *vinfo; - - vinfo = glx_renderer->glXGetVisualFromFBConfig (xlib_renderer->xdpy, - configs[i]); - if (vinfo == NULL) - continue; - - if (vinfo->depth == 32 && - (vinfo->red_mask | vinfo->green_mask | vinfo->blue_mask) - != 0xffffffff) - { - COGL_NOTE (WINSYS, "Found an ARGB FBConfig [index:%d]", i); - *config_ret = configs[i]; - goto done; - } - } - - g_set_error_literal (error, COGL_WINSYS_ERROR, - COGL_WINSYS_ERROR_CREATE_CONTEXT, - "Unable to find fbconfig with rgba visual"); - ret = FALSE; - goto done; - } - else - { - COGL_NOTE (WINSYS, "Using the first available FBConfig"); - *config_ret = configs[0]; - } + COGL_NOTE (WINSYS, "Using the first available FBConfig"); + *config_ret = configs[0]; done: XFree (configs); @@ -1059,8 +1027,6 @@ create_context (CoglDisplay *display, GError **error) CoglXlibRenderer *xlib_renderer = _cogl_xlib_renderer_get_data (display->renderer); CoglGLXRenderer *glx_renderer = display->renderer->winsys; - gboolean support_transparent_windows = - display->onscreen_template->config.swap_chain->has_alpha; GLXFBConfig config; GError *fbconfig_error = NULL; XSetWindowAttributes attrs; @@ -1084,7 +1050,6 @@ create_context (CoglDisplay *display, GError **error) } glx_display->fbconfig = config; - glx_display->fbconfig_has_rgba_visual = support_transparent_windows; COGL_NOTE (WINSYS, "Creating GLX Context (display: %p)", xlib_renderer->xdpy); diff --git a/src/tests/clutter/interactive/test-paint-wrapper.c b/src/tests/clutter/interactive/test-paint-wrapper.c index f66f79433..038226d07 100644 --- a/src/tests/clutter/interactive/test-paint-wrapper.c +++ b/src/tests/clutter/interactive/test-paint-wrapper.c @@ -212,10 +212,6 @@ test_paint_wrapper_main (int argc, char *argv[]) error = NULL; -#ifdef CLUTTER_WINDOWING_X11 - clutter_x11_set_use_argb_visual (TRUE); -#endif - if (clutter_init_with_args (&argc, &argv, NULL, super_oh_entries,