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. Nothing in the Gnome Shell plugin now directly uses symbols from libGL so we don't need to link to it. This helps to avoid problems linking against two GL APIs when cogl is using a non-GL driver such as GLES2. https://bugzilla.gnome.org/show_bug.cgi?id=693225
This commit is contained in:
parent
b1051365fa
commit
b8a8edc513
@ -53,7 +53,7 @@ if $PKG_CONFIG --exists gstreamer-1.0 '>=' $GSTREAMER_MIN_VERSION ; then
|
|||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
build_recorder=true
|
build_recorder=true
|
||||||
recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11 gtk+-3.0"
|
recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11 gtk+-3.0"
|
||||||
PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0 xfixes gl)
|
PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0 xfixes)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
@ -88,7 +88,6 @@ PKG_CHECK_MODULES(GNOME_SHELL, gio-unix-2.0 >= $GIO_MIN_VERSION
|
|||||||
libgnome-menu-3.0 >= $GNOME_MENUS_REQUIRED_VERSION
|
libgnome-menu-3.0 >= $GNOME_MENUS_REQUIRED_VERSION
|
||||||
$recorder_modules
|
$recorder_modules
|
||||||
gdk-x11-3.0 libsoup-2.4
|
gdk-x11-3.0 libsoup-2.4
|
||||||
gl
|
|
||||||
clutter-x11-1.0 >= $CLUTTER_MIN_VERSION
|
clutter-x11-1.0 >= $CLUTTER_MIN_VERSION
|
||||||
clutter-glx-1.0 >= $CLUTTER_MIN_VERSION
|
clutter-glx-1.0 >= $CLUTTER_MIN_VERSION
|
||||||
libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_MIN_VERSION
|
libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_MIN_VERSION
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define CLUTTER_ENABLE_EXPERIMENTAL_API
|
||||||
|
#define COGL_ENABLE_EXPERIMENTAL_API
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <clutter/x11/clutter-x11.h>
|
#include <clutter/x11/clutter-x11.h>
|
||||||
#include <GL/glx.h>
|
|
||||||
#include <GL/glxext.h>
|
|
||||||
#include <gjs/gjs.h>
|
#include <gjs/gjs.h>
|
||||||
#include <meta/display.h>
|
#include <meta/display.h>
|
||||||
#include <meta/meta-plugin.h>
|
#include <meta/meta-plugin.h>
|
||||||
@ -99,6 +99,7 @@ struct _GnomeShellPlugin
|
|||||||
int glx_error_base;
|
int glx_error_base;
|
||||||
int glx_event_base;
|
int glx_event_base;
|
||||||
guint have_swap_event : 1;
|
guint have_swap_event : 1;
|
||||||
|
CoglContext *cogl_context;
|
||||||
|
|
||||||
ShellGlobal *global;
|
ShellGlobal *global;
|
||||||
};
|
};
|
||||||
@ -139,30 +140,59 @@ gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gnome_shell_plugin_start (MetaPlugin *plugin)
|
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;
|
MetaScreen *screen;
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
GError *error = NULL;
|
|
||||||
int status;
|
|
||||||
const char *glx_extensions;
|
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);
|
screen = meta_plugin_get_screen (plugin);
|
||||||
display = meta_screen_get_display (screen);
|
display = meta_screen_get_display (screen);
|
||||||
|
|
||||||
xdisplay = meta_display_get_xdisplay (display);
|
xdisplay = meta_display_get_xdisplay (display);
|
||||||
|
|
||||||
glXQueryExtension (xdisplay,
|
query_extensions_string =
|
||||||
&shell_plugin->glx_error_base,
|
(void *) cogl_get_proc_address ("glXQueryExtensionsString");
|
||||||
&shell_plugin->glx_event_base);
|
query_extension =
|
||||||
|
(void *) cogl_get_proc_address ("glXQueryExtension");
|
||||||
|
|
||||||
glx_extensions = glXQueryExtensionsString (xdisplay,
|
query_extension (xdisplay,
|
||||||
meta_screen_get_screen_number (screen));
|
&shell_plugin->glx_error_base,
|
||||||
shell_plugin->have_swap_event = strstr (glx_extensions, "GLX_INTEL_swap_event") != NULL;
|
&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);
|
||||||
|
|
||||||
|
shell_plugin->have_swap_event =
|
||||||
|
gnome_shell_plugin_has_swap_event (shell_plugin);
|
||||||
|
|
||||||
shell_perf_log_define_event (shell_perf_log_get_default (),
|
shell_perf_log_define_event (shell_perf_log_get_default (),
|
||||||
"glx.swapComplete",
|
"glx.swapComplete",
|
||||||
|
Loading…
Reference in New Issue
Block a user