[mutter] Add EGL abstraction class MetaEgl
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Add EGL abstraction class MetaEgl
- Date: Thu, 17 Nov 2016 16:06:46 +0000 (UTC)
commit 22f019826cd3e962aa80292b7cebce18ea7e9bef
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Aug 18 10:18:28 2016 +0800
Add EGL abstraction class MetaEgl
Add a MetaEgl meant to deal with EGL. It is intended to be use by EGL
based renderers and handle extension symbols loading, handle errors etc.
https://bugzilla.gnome.org/show_bug.cgi?id=773629
configure.ac | 1 +
src/Makefile.am | 2 +
src/backends/meta-backend-private.h | 2 +
src/backends/meta-backend.c | 13 ++++
src/backends/meta-egl.c | 137 +++++++++++++++++++++++++++++++++++
src/backends/meta-egl.h | 38 ++++++++++
6 files changed, 193 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f1175a1..cddbf3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,7 @@ CANBERRA_GTK_VERSION=0.26
LIBWACOM_VERSION=0.13
MUTTER_PC_MODULES="
+ egl
gtk+-3.0 >= 3.19.8
gio-unix-2.0 >= 2.35.1
pango >= 1.2.0
diff --git a/src/Makefile.am b/src/Makefile.am
index da4e3df..0c033c6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,6 +91,8 @@ libmutter_la_SOURCES = \
backends/meta-cursor-tracker-private.h \
backends/meta-cursor-renderer.c \
backends/meta-cursor-renderer.h \
+ backends/meta-egl.c \
+ backneds/meta-egl.h \
backends/meta-display-config-shared.h \
backends/meta-idle-monitor.c \
backends/meta-idle-monitor-private.h \
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index b8abccf..07b7af1 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -35,6 +35,7 @@
#include "meta-cursor-renderer.h"
#include "meta-monitor-manager-private.h"
#include "meta-input-settings-private.h"
+#include "backends/meta-egl.h"
#include "backends/meta-pointer-constraint.h"
#include "backends/meta-renderer.h"
#include "core/util-private.h"
@@ -117,6 +118,7 @@ MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend);
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend);
+MetaEgl * meta_backend_get_egl (MetaBackend *backend);
gboolean meta_backend_grab_device (MetaBackend *backend,
int device_id,
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 872d0d3..57ca798 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -65,6 +65,7 @@ struct _MetaBackendPrivate
MetaCursorRenderer *cursor_renderer;
MetaInputSettings *input_settings;
MetaRenderer *renderer;
+ MetaEgl *egl;
ClutterBackend *clutter_backend;
ClutterActor *stage;
@@ -411,6 +412,8 @@ meta_backend_initable_init (GInitable *initable,
MetaBackend *backend = META_BACKEND (initable);
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+ priv->egl = g_object_new (META_TYPE_EGL, NULL);
+
priv->renderer = META_BACKEND_GET_CLASS (backend)->create_renderer (backend);
if (!priv->renderer)
{
@@ -484,6 +487,16 @@ MetaRenderer * meta_backend_get_renderer (MetaBackend *backend)
}
/**
+ * meta_backend_get_egl: (skip)
+ */
+MetaEgl * meta_backend_get_egl (MetaBackend *backend)
+{
+ MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
+
+ return priv->egl;
+}
+
+/**
* meta_backend_grab_device: (skip)
*/
gboolean
diff --git a/src/backends/meta-egl.c b/src/backends/meta-egl.c
new file mode 100644
index 0000000..a5dd14f
--- /dev/null
+++ b/src/backends/meta-egl.c
@@ -0,0 +1,137 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ * Jonas Ådahl <jadahl gmail com>
+ */
+
+#include "config.h"
+
+#include "backends/meta-egl.h"
+
+#include <EGL/egl.h>
+#include <gio/gio.h>
+#include <glib.h>
+#include <glib-object.h>
+
+struct _MetaEgl
+{
+ GObject parent;
+};
+
+G_DEFINE_TYPE (MetaEgl, meta_egl, G_TYPE_OBJECT)
+
+static const char *
+get_egl_error_str (void)
+{
+ EGLint error_number;
+
+ error_number = eglGetError ();
+
+ switch (error_number)
+ {
+ case EGL_SUCCESS:
+ return "The last function succeeded without error.";
+ break;
+ case EGL_NOT_INITIALIZED:
+ return "EGL is not initialized, or could not be initialized, for the specified EGL display
connection.";
+ break;
+ case EGL_BAD_ACCESS:
+ return "EGL cannot access a requested resource (for example a context is bound in another thread).";
+ break;
+ case EGL_BAD_ALLOC:
+ return "EGL failed to allocate resources for the requested operation.";
+ break;
+ case EGL_BAD_ATTRIBUTE:
+ return "An unrecognized attribute or attribute value was passed in the attribute list.";
+ break;
+ case EGL_BAD_CONTEXT:
+ return "An EGLContext argument does not name a valid EGL rendering context.";
+ break;
+ case EGL_BAD_CONFIG:
+ return "An EGLConfig argument does not name a valid EGL frame buffer configuration.";
+ break;
+ case EGL_BAD_CURRENT_SURFACE:
+ return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no
longer valid.";
+ break;
+ case EGL_BAD_DISPLAY:
+ return "An EGLDisplay argument does not name a valid EGL display connection.";
+ break;
+ case EGL_BAD_SURFACE:
+ return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap)
configured for GL rendering.";
+ break;
+ case EGL_BAD_MATCH:
+ return "Arguments are inconsistent (for example, a valid context requires buffers not supplied by a
valid surface).";
+ break;
+ case EGL_BAD_PARAMETER:
+ return "One or more argument values are invalid.";
+ break;
+ case EGL_BAD_NATIVE_PIXMAP:
+ return "A NativePixmapType argument does not refer to a valid native pixmap.";
+ break;
+ case EGL_BAD_NATIVE_WINDOW:
+ return "A NativeWindowType argument does not refer to a valid native window.";
+ break;
+ case EGL_CONTEXT_LOST:
+ return "A power management event has occurred. The application must destroy all contexts and
reinitialise OpenGL ES state and objects to continue rendering. ";
+ break;
+ default:
+ return "Unknown error";
+ break;
+ }
+}
+
+static void
+set_egl_error (GError **error)
+{
+ const char *error_str;
+
+ error_str = get_egl_error_str ();
+ g_set_error (error, G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ error_str);
+}
+
+EGLDisplay
+meta_egl_get_display (MetaEgl *egl,
+ EGLNativeDisplayType display_id,
+ GError **error)
+{
+ EGLDisplay display;
+
+ display = eglGetDisplay (display_id);
+ if (display == EGL_NO_DISPLAY)
+ {
+ set_egl_error (error);
+ return EGL_NO_DISPLAY;
+ }
+
+ return display;
+}
+
+static void
+meta_egl_init (MetaEgl *egl)
+{
+}
+
+static void
+meta_egl_class_init (MetaEglClass *klass)
+{
+}
diff --git a/src/backends/meta-egl.h b/src/backends/meta-egl.h
new file mode 100644
index 0000000..0762c04
--- /dev/null
+++ b/src/backends/meta-egl.h
@@ -0,0 +1,38 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ * Jonas Ådahl <jadahl gmail com>
+ */
+
+#ifndef META_EGL_H
+#define META_EGL_H
+
+#include <EGL/egl.h>
+#include <glib-object.h>
+
+#define META_TYPE_EGL (meta_egl_get_type ())
+G_DECLARE_FINAL_TYPE (MetaEgl, meta_egl, META, EGL, GObject)
+
+EGLDisplay meta_egl_get_display (MetaEgl *egl,
+ EGLNativeDisplayType display_id,
+ GError **error);
+
+#endif /* META_EGL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]