[gnome-control-center/wip/hadess/switcheroo-renderers: 5/6] info: Add helper to print the GL/GLES renderer
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/hadess/switcheroo-renderers: 5/6] info: Add helper to print the GL/GLES renderer
- Date: Tue, 5 Nov 2019 15:39:19 +0000 (UTC)
commit 5d56eacc5d8360f33f0f8187bcbb96c328abcd8a
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 5 16:28:21 2019 +0100
info: Add helper to print the GL/GLES renderer
This is a simplification of code that used to be in
gnome-session-check-accelerated.
meson.build | 2 +
.../gnome-control-center-print-renderer.c | 61 ++++++++++++++++++++++
panels/info-overview/meson.build | 10 ++++
3 files changed, 73 insertions(+)
---
diff --git a/meson.build b/meson.build
index 2ffa24b74..fd9b2c9d9 100644
--- a/meson.build
+++ b/meson.build
@@ -133,6 +133,7 @@ upower_glib_dep = dependency('upower-glib', version: '>= 0.99.8')
gudev_dep = dependency('gudev-1.0')
x11_dep = dependency('x11')
xi_dep = dependency('xi', version: '>= 1.2')
+epoxy_dep = dependency('epoxy')
m_dep = cc.find_library('m')
@@ -239,6 +240,7 @@ if gnome_session_libexecdir == ''
gnome_session_libexecdir = control_center_libexecdir
endif
+
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
diff --git a/panels/info-overview/gnome-control-center-print-renderer.c
b/panels/info-overview/gnome-control-center-print-renderer.c
new file mode 100644
index 000000000..ba5a11b48
--- /dev/null
+++ b/panels/info-overview/gnome-control-center-print-renderer.c
@@ -0,0 +1,61 @@
+/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */
+/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */
+/*
+ * Copyright (C) 2019 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
+ *
+ * Author:
+ * Bastien Nocera <hadess hadess net>
+ * Matthias Clasen <mclasen redhat com>
+ */
+
+#include <gtk/gtk.h>
+#include <epoxy/gl.h>
+
+static char *
+get_gtk_gles_renderer (void)
+{
+ GtkWidget *win;
+ GdkGLContext *context;
+ char *renderer = NULL;
+
+ win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_realize (win);
+ context = gdk_window_create_gl_context (gtk_widget_get_window (win), NULL);
+ if (!context)
+ return NULL;
+ gdk_gl_context_make_current (context);
+ renderer = g_strdup ((char *) glGetString (GL_RENDERER));
+ gdk_gl_context_clear_current ();
+ g_object_unref (context);
+
+ return renderer;
+}
+
+int
+main (int argc, char **argv)
+{
+ char *renderer_string = NULL;
+
+ gtk_init (NULL, NULL);
+
+ renderer_string = get_gtk_gles_renderer ();
+ if (renderer_string) {
+ g_print ("%s", renderer_string);
+ return 0;
+ }
+ return 1;
+}
diff --git a/panels/info-overview/meson.build b/panels/info-overview/meson.build
index 562a83ce8..ff75e791e 100644
--- a/panels/info-overview/meson.build
+++ b/panels/info-overview/meson.build
@@ -54,3 +54,13 @@ info_panel_lib = static_library(
c_args: cflags
)
panels_libs += info_panel_lib
+
+executable(
+ 'gnome-control-center-print-renderer',
+ 'gnome-control-center-print-renderer.c',
+ include_directories: [ top_inc ],
+ dependencies: [ deps, epoxy_dep ],
+ c_args: cflags,
+ install: true,
+ install_dir: control_center_libexecdir,
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]