renderer-native: Move some error reporting up the call stack

Pass GErrors to functions that can fail, and report the error att the
call site.

https://bugzilla.gnome.org/show_bug.cgi?id=785381
This commit is contained in:
Jonas Ådahl 2017-07-24 17:35:55 +08:00
parent 376dcd3b92
commit 492d2eb573

View File

@ -1594,13 +1594,13 @@ meta_renderer_native_create_onscreen (MetaGpuKms *gpu_kms,
CoglContext *context, CoglContext *context,
MetaMonitorTransform transform, MetaMonitorTransform transform,
gint view_width, gint view_width,
gint view_height) gint view_height,
GError **error)
{ {
CoglOnscreen *onscreen; CoglOnscreen *onscreen;
CoglOnscreenEGL *onscreen_egl; CoglOnscreenEGL *onscreen_egl;
MetaOnscreenNative *onscreen_native; MetaOnscreenNative *onscreen_native;
gint width, height; gint width, height;
GError *error = NULL;
if (meta_monitor_transform_is_rotated (transform)) if (meta_monitor_transform_is_rotated (transform))
{ {
@ -1617,11 +1617,9 @@ meta_renderer_native_create_onscreen (MetaGpuKms *gpu_kms,
cogl_onscreen_set_swap_throttled (onscreen, cogl_onscreen_set_swap_throttled (onscreen,
_clutter_get_sync_to_vblank ()); _clutter_get_sync_to_vblank ());
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), &error)) if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), error))
{ {
g_warning ("Could not create onscreen: %s", error->message);
cogl_object_unref (onscreen); cogl_object_unref (onscreen);
g_error_free (error);
return NULL; return NULL;
} }
@ -1637,16 +1635,16 @@ meta_renderer_native_create_offscreen (MetaRendererNative *renderer,
CoglContext *context, CoglContext *context,
MetaMonitorTransform transform, MetaMonitorTransform transform,
gint view_width, gint view_width,
gint view_height) gint view_height,
GError **error)
{ {
CoglOffscreen *fb; CoglOffscreen *fb;
CoglTexture2D *tex; CoglTexture2D *tex;
GError *error = NULL;
tex = cogl_texture_2d_new_with_size (context, view_width, view_height); tex = cogl_texture_2d_new_with_size (context, view_width, view_height);
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex), FALSE); cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex), FALSE);
if (!cogl_texture_allocate (COGL_TEXTURE (tex), &error)) if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
{ {
cogl_object_unref (tex); cogl_object_unref (tex);
return FALSE; return FALSE;
@ -1654,10 +1652,8 @@ meta_renderer_native_create_offscreen (MetaRendererNative *renderer,
fb = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex)); fb = cogl_offscreen_new_with_texture (COGL_TEXTURE (tex));
cogl_object_unref (tex); cogl_object_unref (tex);
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (fb), &error)) if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (fb), error))
{ {
g_warning ("Could not create offscreen: %s", error->message);
g_error_free (error);
cogl_object_unref (fb); cogl_object_unref (fb);
return FALSE; return FALSE;
} }
@ -1786,9 +1782,10 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
cogl_context, cogl_context,
view_transform, view_transform,
width, width,
height); height,
&error);
if (!onscreen) if (!onscreen)
meta_fatal ("Failed to allocate onscreen framebuffer\n"); g_error ("Failed to allocate onscreen framebuffer: %s", error->message);
if (view_transform != META_MONITOR_TRANSFORM_NORMAL) if (view_transform != META_MONITOR_TRANSFORM_NORMAL)
{ {
@ -1796,9 +1793,10 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
cogl_context, cogl_context,
view_transform, view_transform,
width, width,
height); height,
&error);
if (!offscreen) if (!offscreen)
meta_fatal ("Failed to allocate back buffer texture\n"); g_error ("Failed to allocate back buffer texture: %s", error->message);
} }
view = g_object_new (META_TYPE_RENDERER_VIEW, view = g_object_new (META_TYPE_RENDERER_VIEW,