rendered paste bodyFrom 03aece1facc7374953c274d4dd9ca90c01f0e436 Mon Sep 17 00:00:00 2001From: Robert Bragg <robert@linux.intel.com>Date: Tue, 22 Jun 2010 15:45:54 +0100Subject: [PATCH] cogl-texture-pixmap-x11: return a boolean success statusAnother pedantic change to get_fbconfig_for_depth() so that we don'tneed to make any assumptions about the GLXFBConfig typedef.get_fbconfig_for_depth() now simply returns FALSE if it fails to find aconfig.--- clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c | 29 ++++++++----------- 1 files changed, 12 insertions(+), 17 deletions(-)diff --git a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.cindex da5dbef..62ddfc6 100644--- a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c+++ b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c@@ -220,16 +220,17 @@ _cogl_texture_pixmap_x11_filter (XEvent *event, gpointer data) #ifdef COGL_HAS_GLX_SUPPORT -static void+static gboolean get_fbconfig_for_depth (unsigned int depth, GLXFBConfig *fbconfig_ret, gboolean *can_mipmap_ret) {- GLXFBConfig *fbconfigs, ret = NULL;- int n_elements, i, found;+ GLXFBConfig *fbconfigs;+ int n_elements, i; Display *dpy; int db, stencil, alpha, mipmap, rgba, value; int spare_cache_slot = 0;+ gboolean found = FALSE; _COGL_GET_CONTEXT (ctxt, NO_RETVAL); @@ -241,7 +242,7 @@ get_fbconfig_for_depth (unsigned int depth, { *fbconfig_ret = ctxt->winsys.glx_cached_configs[i].fb_config; *can_mipmap_ret = ctxt->winsys.glx_cached_configs[i].can_mipmap;- return;+ return TRUE; } dpy = _cogl_xlib_get_display ();@@ -254,8 +255,6 @@ get_fbconfig_for_depth (unsigned int depth, mipmap = 0; rgba = 0; - found = n_elements;- for (i = 0; i < n_elements; i++) { XVisualInfo *vi;@@ -340,7 +339,9 @@ get_fbconfig_for_depth (unsigned int depth, mipmap = value; } - found = i;+ *fb_config_ret = fbconfigs[i];+ *can_mipmap_ret = mipmap;+ found = TRUE; /* If we've found a config that supports mipmaps then there's no * need to keep looking for anything better. */@@ -348,9 +349,6 @@ get_fbconfig_for_depth (unsigned int depth, break; } - if (found != n_elements)- ret = fbconfigs[found];- if (n_elements) XFree (fbconfigs); @@ -358,8 +356,7 @@ get_fbconfig_for_depth (unsigned int depth, ctxt->winsys.glx_cached_configs[spare_cache_slot].fb_config = ret; ctxt->winsys.glx_cached_configs[spare_cache_slot].can_mipmap = mipmap; - *fbconfig_ret = ret;- *can_mipmap_ret = mipmap;+ return found; } static gboolean@@ -416,7 +413,7 @@ try_create_glx_pixmap (CoglTexturePixmapX11 *tex_pixmap, gboolean mipmap) { Display *dpy;- GLXFBConfig fb_config = NULL;+ GLXFBConfig fb_config; int attribs[7]; int i = 0; GLenum target;@@ -433,10 +430,8 @@ try_create_glx_pixmap (CoglTexturePixmapX11 *tex_pixmap, dpy = _cogl_xlib_get_display (); - get_fbconfig_for_depth (tex_pixmap->depth, &fb_config,- &tex_pixmap->glx_can_mipmap);-- if (!fb_config)+ if (!get_fbconfig_for_depth (tex_pixmap->depth, &fb_config,+ &tex_pixmap->glx_can_mipmap)) { COGL_NOTE (TEXTURE_PIXMAP, "No suitable FBConfig found for depth %i", tex_pixmap->depth);-- 1.6.3.3