[gnome-shell] StTextureCache: don't crash if we fail to allocate a framebuffer



commit ac76940530039654cf3f01e243541a5c990eb269
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Mar 10 22:43:18 2014 +0100

    StTextureCache: don't crash if we fail to allocate a framebuffer
    
    It's possible that FBO creation fails due to hw limits or the
    driver not exposing the EXT_framebuffer_object extension.
    In that case, just give up on creating square icons.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724977

 src/st/st-texture-cache.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index f102f39..d12118c 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -527,6 +527,7 @@ data_to_cogl_handle (const guchar *data,
   CoglHandle texture, offscreen;
   CoglColor clear_color;
   guint size;
+  GError *error;
 
   size = MAX (width, height);
 
@@ -543,7 +544,26 @@ data_to_cogl_handle (const guchar *data,
                                         COGL_TEXTURE_NO_SLICING,
                                         COGL_PIXEL_FORMAT_ANY);
 
-  offscreen = cogl_offscreen_new_to_texture (texture);
+  offscreen = cogl_offscreen_new_with_texture (texture);
+
+  error = NULL;
+  if (!cogl_framebuffer_allocate (offscreen, &error))
+    {
+      g_warning ("Failed to allocate FBO (sized %d): %s", size, error->message);
+
+      cogl_object_unref (texture);
+      cogl_object_unref (offscreen);
+      g_clear_error (&error);
+
+      return cogl_texture_new_from_data (width,
+                                         height,
+                                         COGL_TEXTURE_NONE,
+                                         has_alpha ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
+                                         COGL_PIXEL_FORMAT_ANY,
+                                         rowstride,
+                                         data);
+  }
+
   cogl_color_set_from_4ub (&clear_color, 0, 0, 0, 0);
   cogl_push_framebuffer (offscreen);
   cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);


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