[gnome-shell/wip/wayland: 2/4] Don't try to use GLX if Cogl isn't using that Winsys
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/wayland: 2/4] Don't try to use GLX if Cogl isn't using that Winsys
- Date: Mon, 28 May 2012 18:01:20 +0000 (UTC)
commit e264be5228587306424a2ab0638ef6a725cb535f
Author: Neil Roberts <neil linux intel com>
Date: Thu Mar 15 15:58:36 2012 +0000
Don't try to use GLX if Cogl isn't using that Winsys
Instead of directly using symbols from GLX to check for the swap event
notification, the plugin now first verifies that the Cogl renderer is
actually using the GLX winsys and then indirectly fetches the pointers
for the GLX functions using cogl_get_proc_address. That way it will
continue to work if Cogl is using an EGL winsys.
configure.ac | 16 ++++++++++++
src/Makefile.am | 1 +
src/gnome-shell-plugin.c | 58 ++++++++++++++++++++++++++++++++++++---------
3 files changed, 63 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e4cdab1..0fea438 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,22 @@ PKG_CHECK_MODULES(GNOME_SHELL, gio-unix-2.0 >= $GIO_MIN_VERSION
libnm-glib libnm-util gnome-keyring-1
gcr-3 >= $GCR_MIN_VERSION)
+dnl Check whether GL/glx.h is available. This is used to support the
+dnl GLX_INTEL_swap_event event. Only the header is used and no
+dnl libraries are directly linked to.
+have_glx_h=yes
+PKG_CHECK_MODULES(GL, gl, [], [have_glx_h=no])
+AS_IF([test "x$have_glx_h" = "xyes"], [
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $GL_CFLAGS"
+AC_CHECK_HEADER([GL/glx.h], [], [have_glx_h=no])
+AC_CHECK_HEADER([GL/glxext.h], [], [have_glx_h=no],
+ [AC_INCLUDES_DEFAULT
+ #include <GL/glx.h>])
+CFLAGS="$saved_CFLAGS"])
+AS_IF([test "x$have_glx_h" = "xyes"],
+ [AC_DEFINE(HAVE_GLX_H, 1, [Defined if GL/glx.h is available])])
+
PKG_CHECK_MODULES(SHELL_PERF_HELPER, gtk+-3.0 gio-2.0)
PKG_CHECK_MODULES(SHELL_HOTPLUG_SNIFFER, gio-2.0 gdk-pixbuf-2.0)
diff --git a/src/Makefile.am b/src/Makefile.am
index a3adc00..12c2869 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,6 +85,7 @@ include Makefile-hotplug-sniffer.am
gnome_shell_cflags = \
$(GNOME_SHELL_CFLAGS) \
+ $(GL_CFLAGS) \
$(SYSTEMD_CFLAGS) \
-I$(srcdir)/tray \
-DVERSION=\"$(VERSION)\" \
diff --git a/src/gnome-shell-plugin.c b/src/gnome-shell-plugin.c
index 737c190..f5df5fe 100644
--- a/src/gnome-shell-plugin.c
+++ b/src/gnome-shell-plugin.c
@@ -28,10 +28,14 @@
#include <stdlib.h>
#include <string.h>
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+#define COGL_ENABLE_EXPERIMENTAL_API
#include <clutter/clutter.h>
#include <clutter/x11/clutter-x11.h>
+#ifdef HAVE_GLX_H
#include <GL/glx.h>
#include <GL/glxext.h>
+#endif /* HAVE_GLX_H */
#include <gjs/gjs.h>
#include <meta/display.h>
#include <meta/meta-plugin.h>
@@ -96,6 +100,7 @@ struct _GnomeShellPlugin
int glx_error_base;
int glx_event_base;
guint have_swap_event : 1;
+ CoglContext *cogl_context;
ShellGlobal *global;
};
@@ -135,30 +140,59 @@ gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
{
}
-static void
-gnome_shell_plugin_start (MetaPlugin *plugin)
+static gboolean
+gnome_shell_plugin_has_swap_event (GnomeShellPlugin *shell_plugin)
{
- GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
+ MetaPlugin *plugin = META_PLUGIN (shell_plugin);
+ CoglDisplay *cogl_display =
+ cogl_context_get_display (shell_plugin->cogl_context);
+ CoglRenderer *renderer = cogl_display_get_renderer (cogl_display);
+ const char * (* query_extensions_string) (Display *dpy, int screen);
+ Bool (* query_extension) (Display *dpy, int *error, int *event);
MetaScreen *screen;
MetaDisplay *display;
Display *xdisplay;
- GError *error = NULL;
- int status;
const char *glx_extensions;
- GjsContext *gjs_context;
+
+ /* We will only get swap events if Cogl is using GLX */
+ if (cogl_renderer_get_winsys_id (renderer) != COGL_WINSYS_ID_GLX)
+ return FALSE;
screen = meta_plugin_get_screen (plugin);
display = meta_screen_get_display (screen);
xdisplay = meta_display_get_xdisplay (display);
- glXQueryExtension (xdisplay,
- &shell_plugin->glx_error_base,
- &shell_plugin->glx_event_base);
+ query_extensions_string =
+ (void *) cogl_get_proc_address ("glXQueryExtensionsString");
+ query_extension =
+ (void *) cogl_get_proc_address ("glXQueryExtension");
+
+ query_extension (xdisplay,
+ &shell_plugin->glx_error_base,
+ &shell_plugin->glx_event_base);
+
+ glx_extensions =
+ query_extensions_string (xdisplay,
+ meta_screen_get_screen_number (screen));
+
+ return strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
+}
+
+static void
+gnome_shell_plugin_start (MetaPlugin *plugin)
+{
+ GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
+ GError *error = NULL;
+ int status;
+ GjsContext *gjs_context;
+ ClutterBackend *backend;
+
+ backend = clutter_get_default_backend ();
+ shell_plugin->cogl_context = clutter_backend_get_cogl_context (backend);
- glx_extensions = glXQueryExtensionsString (xdisplay,
- meta_screen_get_screen_number (screen));
- shell_plugin->have_swap_event = strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
+ shell_plugin->have_swap_event =
+ gnome_shell_plugin_has_swap_event (shell_plugin);
shell_perf_log_define_event (shell_perf_log_get_default (),
"glx.swapComplete",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]