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
This commit is contained in:
Jonas Ådahl 2017-02-16 17:20:43 +08:00
parent 3821ed162b
commit d8ee96c6cb
2 changed files with 14 additions and 9 deletions

View File

@ -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;
}

View File

@ -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,