All pastes #1888513 Raw Edit

bob

public text v1 · immutable
#1888513 ·published 2010-06-22 15:09 UTC
rendered paste body
From 494faa218c4c0b1b2d223e4a54b2baf7861e1661 Mon Sep 17 00:00:00 2001From: Robert Bragg <robert@linux.intel.com>Date: Tue, 22 Jun 2010 15:42:41 +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-context-winsys.h     |    1 + clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c |   34 +++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-)diff --git a/clutter/cogl/cogl/winsys/cogl-context-winsys.h b/clutter/cogl/cogl/winsys/cogl-context-winsys.hindex 8376102..a0189e8 100644--- a/clutter/cogl/cogl/winsys/cogl-context-winsys.h+++ b/clutter/cogl/cogl/winsys/cogl-context-winsys.h@@ -60,6 +60,7 @@ typedef struct {   /* This will be -1 if there is no cached config in this slot */   int depth;+  gboolean found;   GLXFBConfig fb_config;   gboolean can_mipmap; } CoglWinsysCachedConfig;diff --git a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.cindex 5a1d275..ff8ec7d 100644--- a/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c+++ b/clutter/cogl/cogl/winsys/cogl-texture-pixmap-x11.c@@ -220,18 +220,19 @@ _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);+  _COGL_GET_CONTEXT (ctxt, FALSE);    /* Check if we've already got a cached config for this depth */   for (i = 0; i < COGL_WINSYS_N_CACHED_CONFIGS; i++)@@ -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,21 +339,20 @@ get_fbconfig_for_depth (unsigned int depth,           mipmap =  value;         } -      found = i;+      *fbconfig_ret = fbconfigs[i];+      *can_mipmap_ret = mipmap;+      found = TRUE;     } -  if (found != n_elements)-    ret = fbconfigs[found];-   if (n_elements)     XFree (fbconfigs);    ctxt->winsys.glx_cached_configs[spare_cache_slot].depth = depth;-  ctxt->winsys.glx_cached_configs[spare_cache_slot].fb_config = ret;+  ctxt->winsys.glx_cached_configs[spare_cache_slot].found = found;+  ctxt->winsys.glx_cached_configs[spare_cache_slot].fb_config = *fbconfig_ret;   ctxt->winsys.glx_cached_configs[spare_cache_slot].can_mipmap = mipmap; -  *fbconfig_ret = ret;-  *can_mipmap_ret = mipmap;+  return found; }  static gboolean@@ -411,7 +409,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;@@ -428,10 +426,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