[clutter/clutter-1.8] cogl: fallback to non-transparent stages if unsupported



commit f05432d57e5e980d0841fd6c13a7f886a46107fe
Author: Robert Bragg <robert linux intel com>
Date:   Tue Nov 1 13:42:40 2011 +0000

    cogl: fallback to non-transparent stages if unsupported
    
    If our check of the CoglOnscreenTemplate during initialization fails
    then we disable the request for an alpha component in the swap chain and
    try the check again.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    Reviewed-by: Emmanuele Bassi <ebassi linux intel com>

 clutter/cogl/clutter-backend-cogl.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/clutter/cogl/clutter-backend-cogl.c b/clutter/cogl/clutter-backend-cogl.c
index 1ca8850..1343dd1 100644
--- a/clutter/cogl/clutter-backend-cogl.c
+++ b/clutter/cogl/clutter-backend-cogl.c
@@ -296,6 +296,7 @@ clutter_backend_cogl_create_context (ClutterBackend  *backend,
 #endif
   CoglSwapChain *swap_chain = NULL;
   CoglOnscreenTemplate *onscreen_template = NULL;
+  gboolean status;
 
   if (backend->cogl_context)
     return TRUE;
@@ -325,9 +326,28 @@ clutter_backend_cogl_create_context (ClutterBackend  *backend,
    * Conceptually should we be able to check an onscreen_template
    * without more details about the CoglDisplay configuration?
    */
-  if (!cogl_renderer_check_onscreen_template (backend->cogl_renderer,
-                                              onscreen_template,
-                                              error))
+  status = cogl_renderer_check_onscreen_template (backend->cogl_renderer,
+                                                  onscreen_template,
+                                                  error);
+#ifdef COGL_HAS_XLIB_SUPPORT
+  if (!status && clutter_x11_get_use_argb_visual ())
+    {
+      g_clear_error (error);
+      /* It's possible that the current renderer doesn't support transparency
+       * in a swap_chain so lets see if we can fallback to not having any
+       * transparency...
+       *
+       * XXX: It might be nice to have a CoglRenderer feature we could
+       * explicitly check for ahead of time.
+       */
+      cogl_swap_chain_set_has_alpha (swap_chain, FALSE);
+      status = cogl_renderer_check_onscreen_template (backend->cogl_renderer,
+                                                      onscreen_template,
+                                                      error);
+    }
+#endif
+
+  if (!status)
     goto error;
 
   backend->cogl_display = cogl_display_new (backend->cogl_renderer,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]