[mutter] egl: Pass EGL errors via custom error domain
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] egl: Pass EGL errors via custom error domain
- Date: Sat, 4 Mar 2017 10:34:41 +0000 (UTC)
commit d8ee96c6cbbbf9b7aac60d0cbd549ff14c0c4517
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Feb 16 17:20:43 2017 +0800
egl: Pass EGL errors via custom error domain
Introduce META_EGL_ERROR and have the error code be EGL error codes.
https://bugzilla.gnome.org/show_bug.cgi?id=779112
src/backends/meta-egl.c | 19 ++++++++++---------
src/backends/meta-egl.h | 4 ++++
2 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/src/backends/meta-egl.c b/src/backends/meta-egl.c
index 258f5be..ca687c6 100644
--- a/src/backends/meta-egl.c
+++ b/src/backends/meta-egl.c
@@ -70,13 +70,11 @@ struct _MetaEgl
G_DEFINE_TYPE (MetaEgl, meta_egl, G_TYPE_OBJECT)
+G_DEFINE_QUARK (-meta-egl-error-quark, meta_egl_error)
+
static const char *
-get_egl_error_str (void)
+get_egl_error_str (EGLint error_number)
{
- EGLint error_number;
-
- error_number = eglGetError ();
-
switch (error_number)
{
case EGL_SUCCESS:
@@ -133,14 +131,16 @@ get_egl_error_str (void)
static void
set_egl_error (GError **error)
{
+ EGLint error_number;
const char *error_str;
if (!error)
return;
- error_str = get_egl_error_str ();
- g_set_error_literal (error, G_IO_ERROR,
- G_IO_ERROR_FAILED,
+ error_number = eglGetError ();
+ error_str = get_egl_error_str (error_number);
+ g_set_error_literal (error, META_EGL_ERROR,
+ error_number,
error_str);
}
@@ -200,7 +200,8 @@ meta_egl_has_extensions (MetaEgl *egl,
extensions_str = (const char *) eglQueryString (display, EGL_EXTENSIONS);
if (!extensions_str)
{
- g_warning ("Failed to query string: %s", get_egl_error_str ());
+ g_warning ("Failed to query string: %s",
+ get_egl_error_str (eglGetError ()));
return FALSE;
}
diff --git a/src/backends/meta-egl.h b/src/backends/meta-egl.h
index 209cc3e..0a648a6 100644
--- a/src/backends/meta-egl.h
+++ b/src/backends/meta-egl.h
@@ -29,9 +29,13 @@
#include <EGL/eglext.h>
#include <glib-object.h>
+#define META_EGL_ERROR meta_egl_error_quark ()
+
#define META_TYPE_EGL (meta_egl_get_type ())
G_DECLARE_FINAL_TYPE (MetaEgl, meta_egl, META, EGL, GObject)
+GQuark meta_egl_error_quark (void);
+
gboolean meta_egl_has_extensions (MetaEgl *egl,
EGLDisplay display,
char ***missing_extensions,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]