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
This commit is contained in:
parent
55d1c7e2ab
commit
ac76940530
@ -527,6 +527,7 @@ data_to_cogl_handle (const guchar *data,
|
|||||||
CoglHandle texture, offscreen;
|
CoglHandle texture, offscreen;
|
||||||
CoglColor clear_color;
|
CoglColor clear_color;
|
||||||
guint size;
|
guint size;
|
||||||
|
GError *error;
|
||||||
|
|
||||||
size = MAX (width, height);
|
size = MAX (width, height);
|
||||||
|
|
||||||
@ -543,7 +544,26 @@ data_to_cogl_handle (const guchar *data,
|
|||||||
COGL_TEXTURE_NO_SLICING,
|
COGL_TEXTURE_NO_SLICING,
|
||||||
COGL_PIXEL_FORMAT_ANY);
|
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_color_set_from_4ub (&clear_color, 0, 0, 0, 0);
|
||||||
cogl_push_framebuffer (offscreen);
|
cogl_push_framebuffer (offscreen);
|
||||||
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
|
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
|
||||||
|
Loading…
Reference in New Issue
Block a user