[gnome-shell/gnome-3-18] st_theme_node_prerender_shadow: guard against failure to allocate a texture



commit e7528bf2fa0bc5c7eb3584169af04c093b95fee4
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Oct 26 13:35:49 2015 -0400

    st_theme_node_prerender_shadow: guard against failure to allocate a texture
    
    If we are trying to render a shadow at a size that is very large in one
    direction, but small in the other direction (so that we don't 9-slice
    the texture), then allocating the backing texture for the offscreen
    buffer may fail due to texture-size limits. Don't crash in that case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757150

 src/st/st-theme-node-drawing.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index 28151b9..2741bf4 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -2150,7 +2150,7 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
   guint border_radius[4];
   int max_borders[4];
   int center_radius, corner_id;
-  CoglHandle buffer, offscreen;
+  CoglHandle buffer, offscreen = COGL_INVALID_HANDLE;
 
   /* Get infos from the node */
   if (state->alloc_width < node->box_shadow_min_width ||
@@ -2191,7 +2191,8 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
                                        state->box_shadow_height,
                                        COGL_TEXTURE_NO_SLICING,
                                        COGL_PIXEL_FORMAT_ANY);
-  offscreen = cogl_offscreen_new_to_texture (buffer);
+  if (buffer != COGL_INVALID_HANDLE)
+    offscreen = cogl_offscreen_new_to_texture (buffer);
 
   if (offscreen != COGL_INVALID_HANDLE)
     {
@@ -2211,7 +2212,9 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
       state->box_shadow_material = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node),
                                                                buffer);
     }
-  cogl_handle_unref (buffer);
+
+  if (buffer != COGL_INVALID_HANDLE)
+    cogl_handle_unref (buffer);
 }
 
 static void


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