Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 1 | From f83fcf1991afad6d9c15546b2ccd775dad4e314c Mon Sep 17 00:00:00 2001 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2 | From: Jussi Kukkonen <jussi.kukkonen@intel.com> |
| 3 | Date: Tue, 21 Jun 2016 15:11:39 +0300 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 4 | Subject: [PATCH] Add --disable-opengl configure option |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | |
| 6 | --disable-opengl will remove the dependency on libepoxy and on the |
| 7 | OpenGL APIs. This is useful for those who want to keep using gtk+3 |
| 8 | without the "opengl" distro feature. |
| 9 | |
| 10 | GtkGLArea is still part of the API (it just doesn't work) even when |
| 11 | OpenGL is disabled. GdkX11GLContext was removed from the Gtk API |
| 12 | completely: that object exposes GL API elements so it had to be at |
| 13 | the very least modified. |
| 14 | |
| 15 | The patch is _not_ great from a maintenance point of view and |
| 16 | modifying the library API is also a fairly nasty thing to do. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | Next long term release (4.0) will require alternative solutions |
| 18 | as it actually will depend on OpenGL. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | |
| 20 | Upstream-Status: Inappropriate [Evil eye expected from upstream] |
| 21 | Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 23 | --- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | configure.ac | 13 ++++- |
| 25 | demos/gtk-demo/glarea.c | 14 ++++++ |
| 26 | docs/tools/Makefile.am | 9 +++- |
| 27 | docs/tools/widgets.c | 4 +- |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 28 | gdk/Makefile.am | 8 ++- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | gdk/gdkdisplay.c | 4 +- |
| 30 | gdk/gdkgl.c | 10 ++++ |
| 31 | gdk/gdkglcontext.c | 6 +++ |
| 32 | gdk/gdkwindow.c | 13 +++++ |
| 33 | gdk/x11/Makefile.am | 30 +++++++++-- |
| 34 | gdk/x11/gdkdisplay-x11.c | 6 ++- |
| 35 | gdk/x11/gdkscreen-x11.c | 5 ++ |
| 36 | gdk/x11/gdkwindow-x11.c | 4 ++ |
| 37 | gdk/x11/gdkx-autocleanups.h | 2 + |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | gdk/x11/{gdkx.h => gdkx-with-gl-context.h} | 1 - |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 39 | gdk/x11/gdkx-without-gl-context.h | 58 ++++++++++++++++++++++ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 40 | gtk/Makefile.am | 2 +- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | gtk/gtkglarea.c | 20 +++++++- |
| 42 | gtk/inspector/general.c | 6 +++ |
| 43 | tests/Makefile.am | 10 ++-- |
| 44 | testsuite/gtk/objects-finalize.c | 2 + |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 45 | 21 files changed, 208 insertions(+), 19 deletions(-) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 46 | rename gdk/x11/{gdkx.h => gdkx-with-gl-context.h} (98%) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | create mode 100644 gdk/x11/gdkx-without-gl-context.h |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 48 | |
| 49 | diff --git a/configure.ac b/configure.ac |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 50 | index bd651bb..b4c061f 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | --- a/configure.ac |
| 52 | +++ b/configure.ac |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 53 | @@ -346,6 +346,15 @@ AC_ARG_ENABLE(cloudproviders, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | [AS_HELP_STRING([--enable-cloudproviders], |
| 55 | [enable libcloudproviders integration])], |
| 56 | [cloudproviders_set=yes]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 57 | +AC_ARG_ENABLE(opengl, |
| 58 | + [AS_HELP_STRING([--enable-opengl], |
| 59 | + [When enabled, Gtk+ will use libepoxy and exposes GtkGLArea widget ])]) |
| 60 | +AS_IF([test "x$enable_opengl" != "xno"], [ |
| 61 | + AC_DEFINE([HAVE_OPENGL], [1], [libepoxy and opengl APIs are available at buildtime]) |
| 62 | + EPOXY_PACKAGES="epoxy >= epoxy_required_version" |
| 63 | +]) |
| 64 | +AM_CONDITIONAL([HAVE_OPENGL],[test "x$enable_opengl" != "xno"]) |
| 65 | + |
| 66 | AC_ARG_ENABLE(glx, |
| 67 | [AS_HELP_STRING([--enable-glx], |
| 68 | [When enabled Gdk will try to initialize GLX])]) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 69 | @@ -1345,7 +1354,7 @@ CFLAGS="$saved_cflags" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 70 | LDFLAGS="$saved_ldflags" |
| 71 | |
| 72 | GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 73 | -GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends epoxy >= epoxy_required_version $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version" |
| 74 | +GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends $EPOXY_PACKAGES $CLOUDPROVIDER_PACKAGES $PROFILER_PACKAGES fribidi >= fribidi_required_version" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 75 | |
| 76 | PKG_CHECK_MODULES(GDK_DEP, $GDK_PACKAGES $GDK_PRIVATE_PACKAGES) |
| 77 | GDK_DEP_LIBS="$GDK_EXTRA_LIBS $GDK_DEP_LIBS $MATH_LIB" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 78 | @@ -1379,7 +1388,7 @@ fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 79 | PKG_CHECK_MODULES(ATK, $ATK_PACKAGES) |
| 80 | |
| 81 | GTK_PACKAGES="atk >= atk_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version gdk-pixbuf-2.0 >= gdk_pixbuf_required_version gio-2.0 >= glib_required_version" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 82 | -GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES epoxy >= epoxy_required_version fribidi >= fribidi_required_version" |
| 83 | +GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $EPOXY_PACKAGES fribidi >= fribidi_required_version" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 84 | if test "x$enable_x11_backend" = xyes -o "x$enable_wayland_backend" = xyes; then |
| 85 | GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2" |
| 86 | fi |
| 87 | diff --git a/demos/gtk-demo/glarea.c b/demos/gtk-demo/glarea.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 88 | index b51e4ae..82409c7 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 89 | --- a/demos/gtk-demo/glarea.c |
| 90 | +++ b/demos/gtk-demo/glarea.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 91 | @@ -3,9 +3,12 @@ |
| 92 | * GtkGLArea is a widget that allows custom drawing using OpenGL calls. |
| 93 | */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 94 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 95 | +#include "config.h" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 96 | #include <math.h> |
| 97 | #include <gtk/gtk.h> |
| 98 | +#if HAVE_OPENGL |
| 99 | #include <epoxy/gl.h> |
| 100 | +#endif |
| 101 | |
| 102 | static GtkWidget *demo_window = NULL; |
| 103 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 104 | @@ -23,6 +26,8 @@ enum { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 105 | /* Rotation angles on each axis */ |
| 106 | static float rotation_angles[N_AXIS] = { 0.0 }; |
| 107 | |
| 108 | +#ifdef HAVE_OPENGL |
| 109 | + |
| 110 | /* The object we are drawing */ |
| 111 | static const GLfloat vertex_data[] = { |
| 112 | 0.f, 0.5f, 0.f, 1.f, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 113 | @@ -215,6 +220,7 @@ compute_mvp (float *res, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 114 | static GLuint position_buffer; |
| 115 | static GLuint program; |
| 116 | static GLuint mvp_location; |
| 117 | +#endif |
| 118 | |
| 119 | /* We need to set up our state when we realize the GtkGLArea widget */ |
| 120 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | @@ -241,8 +247,10 @@ realize (GtkWidget *widget) |
| 122 | fragment_path = "/glarea/glarea-gl.fs.glsl"; |
| 123 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 124 | |
| 125 | +#ifdef HAVE_OPENGL |
| 126 | init_buffers (&position_buffer, NULL); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 127 | init_shaders (vertex_path, fragment_path, &program, &mvp_location); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 128 | +#endif |
| 129 | } |
| 130 | |
| 131 | /* We should tear down the state when unrealizing */ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 132 | @@ -254,10 +262,13 @@ unrealize (GtkWidget *widget) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 133 | if (gtk_gl_area_get_error (GTK_GL_AREA (widget)) != NULL) |
| 134 | return; |
| 135 | |
| 136 | +#ifdef HAVE_OPENGL |
| 137 | glDeleteBuffers (1, &position_buffer); |
| 138 | glDeleteProgram (program); |
| 139 | +#endif |
| 140 | } |
| 141 | |
| 142 | +#ifdef HAVE_OPENGL |
| 143 | static void |
| 144 | draw_triangle (void) |
| 145 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 146 | @@ -290,6 +301,7 @@ draw_triangle (void) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 147 | glBindBuffer (GL_ARRAY_BUFFER, 0); |
| 148 | glUseProgram (0); |
| 149 | } |
| 150 | +#endif |
| 151 | |
| 152 | static gboolean |
| 153 | render (GtkGLArea *area, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 154 | @@ -298,6 +310,7 @@ render (GtkGLArea *area, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 155 | if (gtk_gl_area_get_error (area) != NULL) |
| 156 | return FALSE; |
| 157 | |
| 158 | +#ifdef HAVE_OPENGL |
| 159 | /* Clear the viewport */ |
| 160 | glClearColor (0.5, 0.5, 0.5, 1.0); |
| 161 | glClear (GL_COLOR_BUFFER_BIT); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 162 | @@ -307,6 +320,7 @@ render (GtkGLArea *area, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 163 | |
| 164 | /* Flush the contents of the pipeline */ |
| 165 | glFlush (); |
| 166 | +#endif |
| 167 | |
| 168 | return TRUE; |
| 169 | } |
| 170 | diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 171 | index bec43e3..189e8fc 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 172 | --- a/docs/tools/Makefile.am |
| 173 | +++ b/docs/tools/Makefile.am |
| 174 | @@ -9,13 +9,18 @@ AM_CPPFLAGS = \ |
| 175 | $(GTK_DEBUG_FLAGS) \ |
| 176 | $(GTK_DEP_CFLAGS) |
| 177 | |
| 178 | +if HAVE_OPENGL |
| 179 | +GEARS_LDADD = $(top_builddir)/tests/gtkgears.o |
| 180 | +endif |
| 181 | + |
| 182 | DEPS = \ |
| 183 | - $(top_builddir)/gtk/libgtk-3.la |
| 184 | + $(top_builddir)/gtk/libgtk-3.la \ |
| 185 | + $(GEARS_LDADD) |
| 186 | |
| 187 | LDADDS = \ |
| 188 | $(top_builddir)/gtk/libgtk-3.la \ |
| 189 | $(top_builddir)/gdk/libgdk-3.la \ |
| 190 | - $(top_builddir)/tests/gtkgears.o \ |
| 191 | + $(GEARS_LDADD) \ |
| 192 | $(GTK_DEP_LIBS) \ |
| 193 | $(GDK_DEP_LIBS) \ |
| 194 | -lm |
| 195 | diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c |
| 196 | index 932daf1..54239d6 100644 |
| 197 | --- a/docs/tools/widgets.c |
| 198 | +++ b/docs/tools/widgets.c |
| 199 | @@ -1526,9 +1526,11 @@ create_gl_area (void) |
| 200 | widget = gtk_frame_new (NULL); |
| 201 | gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN); |
| 202 | |
| 203 | +#ifdef HAVE_OPENGL |
| 204 | gears = gtk_gears_new (); |
| 205 | gtk_container_add (GTK_CONTAINER (widget), gears); |
| 206 | - |
| 207 | +#endif |
| 208 | + |
| 209 | info = new_widget_info ("glarea", widget, MEDIUM); |
| 210 | |
| 211 | return info; |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 212 | diff --git a/gdk/Makefile.am b/gdk/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 213 | index 479d6a1..7edbee8 100644 |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 214 | --- a/gdk/Makefile.am |
| 215 | +++ b/gdk/Makefile.am |
| 216 | @@ -274,7 +274,6 @@ x11_introspection_files = \ |
| 217 | x11/gdkeventsource.c \ |
| 218 | x11/gdkeventtranslator.c \ |
| 219 | x11/gdkgeometry-x11.c \ |
| 220 | - x11/gdkglcontext-x11.c \ |
| 221 | x11/gdkkeys-x11.c \ |
| 222 | x11/gdkmain-x11.c \ |
| 223 | x11/gdkmonitor-x11.c \ |
| 224 | @@ -300,7 +299,6 @@ x11_introspection_files = \ |
| 225 | x11/gdkx11display.h \ |
| 226 | x11/gdkx11displaymanager.h \ |
| 227 | x11/gdkx11dnd.h \ |
| 228 | - x11/gdkx11glcontext.h \ |
| 229 | x11/gdkx11keys.h \ |
| 230 | x11/gdkx11monitor.h \ |
| 231 | x11/gdkx11property.h \ |
| 232 | @@ -310,6 +308,12 @@ x11_introspection_files = \ |
| 233 | x11/gdkx11visual.h \ |
| 234 | x11/gdkx11window.h |
| 235 | |
| 236 | +if HAVE_OPENGL |
| 237 | +x11_introspection_files += \ |
| 238 | + x11/gdkglcontext-x11.c \ |
| 239 | + x11/gdkx11glcontext.h |
| 240 | +endif |
| 241 | + |
| 242 | GdkX11-3.0.gir: libgdk-3.la Gdk-3.0.gir Makefile |
| 243 | GdkX11_3_0_gir_SCANNERFLAGS = \ |
| 244 | --identifier-prefix=Gdk \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 245 | diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 246 | index 240c99f..9eb49bf 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 247 | --- a/gdk/gdkdisplay.c |
| 248 | +++ b/gdk/gdkdisplay.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 249 | @@ -2419,7 +2419,9 @@ gboolean |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 250 | gdk_display_make_gl_context_current (GdkDisplay *display, |
| 251 | GdkGLContext *context) |
| 252 | { |
| 253 | - return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 254 | + if (GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current) |
| 255 | + return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); |
| 256 | + return FALSE; |
| 257 | } |
| 258 | |
| 259 | GdkRenderingMode |
| 260 | diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 261 | index 933e204..1767508 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 262 | --- a/gdk/gdkgl.c |
| 263 | +++ b/gdk/gdkgl.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 264 | @@ -26,7 +26,9 @@ |
| 265 | # include "win32/gdkwin32.h" |
| 266 | #endif |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 267 | |
| 268 | +#ifdef HAVE_OPENGL |
| 269 | #include <epoxy/gl.h> |
| 270 | +#endif |
| 271 | #include <math.h> |
| 272 | #include <string.h> |
| 273 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 274 | @@ -40,6 +42,7 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 275 | g_object_ref (window), g_object_unref); |
| 276 | } |
| 277 | |
| 278 | +#ifdef HAVE_OPENGL |
| 279 | static const char * |
| 280 | get_vertex_type_name (int type) |
| 281 | { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 282 | @@ -212,6 +215,7 @@ use_texture_rect_program (GdkGLContextPaintData *paint_data) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 283 | glUseProgram (paint_data->current_program->program); |
| 284 | } |
| 285 | } |
| 286 | +#endif |
| 287 | |
| 288 | void |
| 289 | gdk_gl_texture_quads (GdkGLContext *paint_context, |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 290 | @@ -220,6 +224,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 291 | GdkTexturedQuad *quads, |
| 292 | gboolean flip_colors) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 293 | { |
| 294 | +#ifdef HAVE_OPENGL |
| 295 | GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context); |
| 296 | GdkGLContextProgram *program; |
| 297 | GdkWindow *window = gdk_gl_context_get_window (paint_context); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 298 | @@ -293,6 +298,7 @@ gdk_gl_texture_quads (GdkGLContext *paint_context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 299 | |
| 300 | glDisableVertexAttribArray (program->position_location); |
| 301 | glDisableVertexAttribArray (program->uv_location); |
| 302 | +#endif |
| 303 | } |
| 304 | |
| 305 | /* x,y,width,height describes a rectangle in the gl render buffer |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 306 | @@ -341,6 +347,7 @@ gdk_cairo_draw_from_gl (cairo_t *cr, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 307 | int width, |
| 308 | int height) |
| 309 | { |
| 310 | +#ifdef HAVE_OPENGL |
| 311 | GdkGLContext *paint_context; |
| 312 | cairo_surface_t *image; |
| 313 | cairo_matrix_t matrix; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 314 | @@ -718,6 +725,7 @@ out: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 315 | if (clip_region) |
| 316 | cairo_region_destroy (clip_region); |
| 317 | |
| 318 | +#endif |
| 319 | } |
| 320 | |
| 321 | /* This is always called with the paint context current */ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 322 | @@ -725,6 +733,7 @@ void |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 323 | gdk_gl_texture_from_surface (cairo_surface_t *surface, |
| 324 | cairo_region_t *region) |
| 325 | { |
| 326 | +#ifdef HAVE_OPENGL |
| 327 | GdkGLContext *paint_context; |
| 328 | cairo_surface_t *image; |
| 329 | double device_x_offset, device_y_offset; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 330 | @@ -825,4 +834,5 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 331 | |
| 332 | glDisable (GL_SCISSOR_TEST); |
| 333 | glDeleteTextures (1, &texture_id); |
| 334 | +#endif |
| 335 | } |
| 336 | diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 337 | index dfbed63..556f0a3 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 338 | --- a/gdk/gdkglcontext.c |
| 339 | +++ b/gdk/gdkglcontext.c |
| 340 | @@ -85,7 +85,9 @@ |
| 341 | #include "gdkintl.h" |
| 342 | #include "gdk-private.h" |
| 343 | |
| 344 | +#ifdef HAVE_OPENGL |
| 345 | #include <epoxy/gl.h> |
| 346 | +#endif |
| 347 | |
| 348 | typedef struct { |
| 349 | GdkDisplay *display; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 350 | @@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 351 | int height, |
| 352 | guint texture_target) |
| 353 | { |
| 354 | +#ifdef HAVE_OPENGL |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 355 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 356 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 357 | g_return_if_fail (GDK_IS_GL_CONTEXT (context)); |
| 358 | @@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, |
| 359 | glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride)); |
| 360 | } |
| 361 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 362 | +#endif |
| 363 | } |
| 364 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 365 | static gboolean |
| 366 | @@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 367 | static void |
| 368 | gdk_gl_context_check_extensions (GdkGLContext *context) |
| 369 | { |
| 370 | +#ifdef HAVE_OPENGL |
| 371 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); |
| 372 | gboolean has_npot, has_texture_rectangle; |
| 373 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 374 | @@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 375 | priv->use_texture_rectangle ? "yes" : "no")); |
| 376 | |
| 377 | priv->extensions_checked = TRUE; |
| 378 | +#endif |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 383 | index 6ae0f86..4e48a2a 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 384 | --- a/gdk/gdkwindow.c |
| 385 | +++ b/gdk/gdkwindow.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 386 | @@ -45,7 +45,9 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 387 | |
| 388 | #include <math.h> |
| 389 | |
| 390 | +#ifdef HAVE_OPENGL |
| 391 | #include <epoxy/gl.h> |
| 392 | +#endif |
| 393 | |
| 394 | /* for the use of round() */ |
| 395 | #include "fallback-c89.c" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 396 | @@ -2844,6 +2846,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 397 | { |
| 398 | GError *internal_error = NULL; |
| 399 | |
| 400 | +#ifndef HAVE_OPENGL |
| 401 | + g_set_error_literal (error, GDK_GL_ERROR, |
| 402 | + GDK_GL_ERROR_NOT_AVAILABLE, |
| 403 | + _("GL support disabled with --disable-opengl")); |
| 404 | + return NULL; |
| 405 | +#endif |
| 406 | + |
| 407 | if (_gdk_gl_flags & GDK_GL_DISABLE) |
| 408 | { |
| 409 | g_set_error_literal (error, GDK_GL_ERROR, |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 410 | @@ -2979,6 +2988,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 411 | } |
| 412 | else |
| 413 | { |
| 414 | +#ifdef HAVE_OPENGL |
| 415 | gdk_gl_context_make_current (context); |
| 416 | /* With gl we always need a surface to combine the gl |
| 417 | drawing with the native drawing. */ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 418 | @@ -2993,6 +3003,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 419 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| 420 | |
| 421 | glViewport (0, 0, ww, wh); |
| 422 | +#endif |
| 423 | } |
| 424 | } |
| 425 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 426 | @@ -3056,6 +3067,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 427 | |
| 428 | gdk_gl_context_make_current (window->gl_paint_context); |
| 429 | |
| 430 | +#ifdef HAVE_OPENGL |
| 431 | if (!cairo_region_is_empty (opaque_region)) |
| 432 | gdk_gl_texture_from_surface (window->current_paint.surface, |
| 433 | opaque_region); |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 434 | @@ -3066,6 +3078,7 @@ gdk_window_end_paint_internal (GdkWindow *window) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 435 | window->current_paint.need_blend_region); |
| 436 | glDisable(GL_BLEND); |
| 437 | } |
| 438 | +#endif |
| 439 | |
| 440 | cairo_region_destroy (opaque_region); |
| 441 | |
| 442 | diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 443 | index 32b1f24..6352313 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 444 | --- a/gdk/x11/Makefile.am |
| 445 | +++ b/gdk/x11/Makefile.am |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 446 | @@ -40,8 +40,6 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 447 | gdkeventtranslator.c \ |
| 448 | gdkeventtranslator.h \ |
| 449 | gdkgeometry-x11.c \ |
| 450 | - gdkglcontext-x11.c \ |
| 451 | - gdkglcontext-x11.h \ |
| 452 | gdkkeys-x11.c \ |
| 453 | gdkmain-x11.c \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 454 | gdkmonitor-x11.c \ |
| 455 | @@ -56,14 +54,32 @@ libgdk_x11_la_SOURCES = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 456 | gdkwindow-x11.h \ |
| 457 | gdkxftdefaults.c \ |
| 458 | gdkxid.c \ |
| 459 | - gdkx.h \ |
| 460 | gdkprivate-x11.h \ |
| 461 | xsettings-client.h \ |
| 462 | xsettings-client.c |
| 463 | |
| 464 | +if HAVE_OPENGL |
| 465 | +libgdk_x11_la_SOURCES += \ |
| 466 | + gdkglcontext-x11.c \ |
| 467 | + gdkglcontext-x11.h |
| 468 | +endif |
| 469 | + |
| 470 | libgdkinclude_HEADERS = \ |
| 471 | gdkx.h |
| 472 | |
| 473 | +if HAVE_OPENGL |
| 474 | +GDKX_HEADER = gdkx-with-gl-context.h |
| 475 | +else |
| 476 | +GDKX_HEADER = gdkx-without-gl-context.h |
| 477 | +endif |
| 478 | + |
| 479 | +BUILT_SOURCES = gdkx.h |
| 480 | + |
| 481 | +.PHONY: gdkx.h |
| 482 | +gdkx.h: |
| 483 | + $(AM_V_GEN) cd $(srcdir) \ |
| 484 | + && (cmp -s $(GDKX_HEADER) gdkx.h || cp $(GDKX_HEADER) gdkx.h ) |
| 485 | + |
| 486 | libgdkx11include_HEADERS = \ |
| 487 | gdkx-autocleanups.h \ |
| 488 | gdkx11applaunchcontext.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 489 | @@ -77,7 +93,6 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 490 | gdkx11display.h \ |
| 491 | gdkx11displaymanager.h \ |
| 492 | gdkx11dnd.h \ |
| 493 | - gdkx11glcontext.h \ |
| 494 | gdkx11keys.h \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 495 | gdkx11monitor.h \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 496 | gdkx11property.h \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 497 | @@ -87,10 +102,17 @@ libgdkx11include_HEADERS = \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 498 | gdkx11visual.h \ |
| 499 | gdkx11window.h |
| 500 | |
| 501 | +if HAVE_OPENGL |
| 502 | +libgdkx11include_HEADERS += gdkx11glcontext.h |
| 503 | +endif |
| 504 | + |
| 505 | # We need to include all these C files here since the conditionals |
| 506 | # don't seem to be correctly expanded for the dist files. |
| 507 | EXTRA_DIST += \ |
| 508 | + gdkx.h \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 509 | gdksettings.c \ |
| 510 | meson.build |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 511 | |
| 512 | +MAINTAINERCLEANFILES = gdkx.h |
| 513 | + |
| 514 | -include $(top_srcdir)/git.mk |
| 515 | diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 516 | index 817944e..e7a2947 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 517 | --- a/gdk/x11/gdkdisplay-x11.c |
| 518 | +++ b/gdk/x11/gdkdisplay-x11.c |
| 519 | @@ -37,7 +37,9 @@ |
| 520 | #include "gdkdisplay-x11.h" |
| 521 | #include "gdkprivate-x11.h" |
| 522 | #include "gdkscreen-x11.h" |
| 523 | +#ifdef HAVE_OPENGL |
| 524 | #include "gdkglcontext-x11.h" |
| 525 | +#endif |
| 526 | #include "gdk-private.h" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 527 | #include "gdkprofilerprivate.h" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 528 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 529 | @@ -3188,7 +3190,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 530 | display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list; |
| 531 | display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target; |
| 532 | |
| 533 | - display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; |
| 534 | +#ifdef HAVE_OPENGL |
| 535 | + display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; |
| 536 | +#endif |
| 537 | |
| 538 | display_class->get_default_seat = gdk_x11_display_get_default_seat; |
| 539 | |
| 540 | diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 541 | index 8939ae9..931bff9 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 542 | --- a/gdk/x11/gdkscreen-x11.c |
| 543 | +++ b/gdk/x11/gdkscreen-x11.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 544 | @@ -1723,3 +1723,8 @@ gdk_x11_screen_get_current_desktop (GdkScreen *screen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 545 | { |
| 546 | return get_netwm_cardinal_property (screen, "_NET_CURRENT_DESKTOP"); |
| 547 | } |
| 548 | + |
| 549 | +#ifndef HAVE_OPENGL |
| 550 | +/* Function from in gdk/x11/gdkglcontext-x11.c */ |
| 551 | +void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen) {} |
| 552 | +#endif |
| 553 | diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 554 | index 1fe7b90..d23a347 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 555 | --- a/gdk/x11/gdkwindow-x11.c |
| 556 | +++ b/gdk/x11/gdkwindow-x11.c |
| 557 | @@ -36,7 +36,9 @@ |
| 558 | #include "gdkasync.h" |
| 559 | #include "gdkeventsource.h" |
| 560 | #include "gdkdisplay-x11.h" |
| 561 | +#ifdef HAVE_OPENGL |
| 562 | #include "gdkglcontext-x11.h" |
| 563 | +#endif |
| 564 | #include "gdkprivate-x11.h" |
| 565 | #include "gdk-private.h" |
| 566 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 567 | @@ -5861,7 +5863,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 568 | impl_class->set_opaque_region = gdk_x11_window_set_opaque_region; |
| 569 | impl_class->set_shadow_width = gdk_x11_window_set_shadow_width; |
| 570 | impl_class->show_window_menu = gdk_x11_window_show_window_menu; |
| 571 | +#ifdef HAVE_OPENGL |
| 572 | impl_class->create_gl_context = gdk_x11_window_create_gl_context; |
| 573 | impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame; |
| 574 | +#endif |
| 575 | impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size; |
| 576 | } |
| 577 | diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h |
| 578 | index edb0ea7..a317d61 100644 |
| 579 | --- a/gdk/x11/gdkx-autocleanups.h |
| 580 | +++ b/gdk/x11/gdkx-autocleanups.h |
| 581 | @@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref) |
| 582 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref) |
| 583 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref) |
| 584 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref) |
| 585 | +#ifdef HAVE_OPENGL |
| 586 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref) |
| 587 | +#endif |
| 588 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref) |
| 589 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref) |
| 590 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 591 | diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx-with-gl-context.h |
| 592 | similarity index 98% |
| 593 | rename from gdk/x11/gdkx.h |
| 594 | rename to gdk/x11/gdkx-with-gl-context.h |
| 595 | index 1f64bcc..ae05fa6 100644 |
| 596 | --- a/gdk/x11/gdkx.h |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 597 | +++ b/gdk/x11/gdkx-with-gl-context.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 598 | @@ -45,7 +45,6 @@ |
| 599 | #include <gdk/x11/gdkx11dnd.h> |
| 600 | #include <gdk/x11/gdkx11glcontext.h> |
| 601 | #include <gdk/x11/gdkx11keys.h> |
| 602 | -#include <gdk/x11/gdkx11monitor.h> |
| 603 | #include <gdk/x11/gdkx11property.h> |
| 604 | #include <gdk/x11/gdkx11screen.h> |
| 605 | #include <gdk/x11/gdkx11selection.h> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 606 | diff --git a/gdk/x11/gdkx-without-gl-context.h b/gdk/x11/gdkx-without-gl-context.h |
| 607 | new file mode 100644 |
| 608 | index 0000000..c9e2617 |
| 609 | --- /dev/null |
| 610 | +++ b/gdk/x11/gdkx-without-gl-context.h |
| 611 | @@ -0,0 +1,58 @@ |
| 612 | +/* GDK - The GIMP Drawing Kit |
| 613 | + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 614 | + * |
| 615 | + * This library is free software; you can redistribute it and/or |
| 616 | + * modify it under the terms of the GNU Lesser General Public |
| 617 | + * License as published by the Free Software Foundation; either |
| 618 | + * version 2 of the License, or (at your option) any later version. |
| 619 | + * |
| 620 | + * This library is distributed in the hope that it will be useful, |
| 621 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 622 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 623 | + * Lesser General Public License for more details. |
| 624 | + * |
| 625 | + * You should have received a copy of the GNU Lesser General Public |
| 626 | + * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 627 | + */ |
| 628 | + |
| 629 | +/* |
| 630 | + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS |
| 631 | + * file for a list of people on the GTK+ Team. See the ChangeLog |
| 632 | + * files for a list of changes. These files are distributed with |
| 633 | + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |
| 634 | + */ |
| 635 | + |
| 636 | +#ifndef __GDK_X_H__ |
| 637 | +#define __GDK_X_H__ |
| 638 | + |
| 639 | +#include <gdk/gdk.h> |
| 640 | + |
| 641 | +#include <X11/Xlib.h> |
| 642 | +#include <X11/Xutil.h> |
| 643 | + |
| 644 | +#define __GDKX_H_INSIDE__ |
| 645 | + |
| 646 | +#include <gdk/x11/gdkx11applaunchcontext.h> |
| 647 | +#include <gdk/x11/gdkx11cursor.h> |
| 648 | +#include <gdk/x11/gdkx11device.h> |
| 649 | +#include <gdk/x11/gdkx11device-core.h> |
| 650 | +#include <gdk/x11/gdkx11device-xi2.h> |
| 651 | +#include <gdk/x11/gdkx11devicemanager.h> |
| 652 | +#include <gdk/x11/gdkx11devicemanager-core.h> |
| 653 | +#include <gdk/x11/gdkx11devicemanager-xi2.h> |
| 654 | +#include <gdk/x11/gdkx11display.h> |
| 655 | +#include <gdk/x11/gdkx11displaymanager.h> |
| 656 | +#include <gdk/x11/gdkx11dnd.h> |
| 657 | +#include <gdk/x11/gdkx11keys.h> |
| 658 | +#include <gdk/x11/gdkx11property.h> |
| 659 | +#include <gdk/x11/gdkx11screen.h> |
| 660 | +#include <gdk/x11/gdkx11selection.h> |
| 661 | +#include <gdk/x11/gdkx11utils.h> |
| 662 | +#include <gdk/x11/gdkx11visual.h> |
| 663 | +#include <gdk/x11/gdkx11window.h> |
| 664 | + |
| 665 | +#include <gdk/x11/gdkx-autocleanups.h> |
| 666 | + |
| 667 | +#undef __GDKX_H_INSIDE__ |
| 668 | + |
| 669 | +#endif /* __GDK_X_H__ */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 670 | diff --git a/gtk/Makefile.am b/gtk/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 671 | index eaca473..99352d1 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 672 | --- a/gtk/Makefile.am |
| 673 | +++ b/gtk/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 674 | @@ -1449,7 +1449,7 @@ gtktypefuncs.inc: stamp-gtktypebuiltins.h stamp-gtkprivatetypebuiltins.h $(top_s |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 675 | ${CPP} $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) xgen-gtfsrc.c | \ |
| 676 | $(GREP) -o '\bg[td]k_[a-zA-Z0-9_]*_get_type\b' | \ |
| 677 | sort | uniq | \ |
| 678 | - $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; }' >> xgen-gtf \ |
| 679 | + $(SED) '{ s/^/*tp++ = /; s/$$/();/; s/^.*\(gdk_x11\|gtk_plug_\|gtk_socket_\).*$$/#ifdef GDK_WINDOWING_X11\n&\n#endif/; s/^.*gdk_x11_gl.*$$/#ifdef HAVE_OPENGL\n&\n#endif/; }' >> xgen-gtf \ |
| 680 | && cp xgen-gtf $@ && rm -f xgen-gtf |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 681 | $(srcdir)/gtktestutils.c: gtktypefuncs.inc |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 682 | |
| 683 | diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 684 | index 9a56443..7de0db2 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 685 | --- a/gtk/gtkglarea.c |
| 686 | +++ b/gtk/gtkglarea.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 687 | @@ -29,7 +29,9 @@ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 688 | #include "gtkprivate.h" |
| 689 | #include "gtkrender.h" |
| 690 | |
| 691 | +#ifdef HAVE_OPENGL |
| 692 | #include <epoxy/gl.h> |
| 693 | +#endif |
| 694 | |
| 695 | /** |
| 696 | * SECTION:gtkglarea |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 697 | @@ -369,9 +371,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 698 | static void |
| 699 | gtk_gl_area_resize (GtkGLArea *area, int width, int height) |
| 700 | { |
| 701 | +#ifdef HAVE_OPENGL |
| 702 | glViewport (0, 0, width, height); |
| 703 | +#endif |
| 704 | } |
| 705 | |
| 706 | +#ifdef HAVE_OPENGL |
| 707 | /* |
| 708 | * Creates all the buffer objects needed for rendering the scene |
| 709 | */ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 710 | @@ -483,6 +488,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 711 | |
| 712 | priv->needs_render = TRUE; |
| 713 | } |
| 714 | +#endif |
| 715 | |
| 716 | /** |
| 717 | * gtk_gl_area_attach_buffers: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 718 | @@ -501,6 +507,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 719 | void |
| 720 | gtk_gl_area_attach_buffers (GtkGLArea *area) |
| 721 | { |
| 722 | +#ifdef HAVE_OPENGL |
| 723 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 724 | |
| 725 | g_return_if_fail (GTK_IS_GL_AREA (area)); |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 726 | @@ -533,11 +540,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 727 | glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, |
| 728 | GL_RENDERBUFFER_EXT, priv->depth_stencil_buffer); |
| 729 | } |
| 730 | +#endif |
| 731 | } |
| 732 | |
| 733 | static void |
| 734 | gtk_gl_area_delete_buffers (GtkGLArea *area) |
| 735 | { |
| 736 | +#ifdef HAVE_OPENGL |
| 737 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 738 | |
| 739 | if (priv->context == NULL) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 740 | @@ -569,6 +578,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 741 | glDeleteFramebuffersEXT (1, &priv->frame_buffer); |
| 742 | priv->frame_buffer = 0; |
| 743 | } |
| 744 | +#endif |
| 745 | } |
| 746 | |
| 747 | static void |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 748 | @@ -679,6 +689,7 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 749 | GtkGLArea *area = GTK_GL_AREA (widget); |
| 750 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); |
| 751 | gboolean unused; |
| 752 | +#ifdef HAVE_OPENGL |
| 753 | int w, h, scale; |
| 754 | GLenum status; |
| 755 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 756 | @@ -690,7 +701,6 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 757 | gtk_widget_get_allocated_height (widget)); |
| 758 | return FALSE; |
| 759 | } |
| 760 | - |
| 761 | if (priv->context == NULL) |
| 762 | return FALSE; |
| 763 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 764 | @@ -736,6 +746,14 @@ gtk_gl_area_draw (GtkWidget *widget, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | return TRUE; |
| 768 | +#else |
| 769 | + if (priv->error != NULL) |
| 770 | + gtk_gl_area_draw_error_screen (area, |
| 771 | + cr, |
| 772 | + gtk_widget_get_allocated_width (widget), |
| 773 | + gtk_widget_get_allocated_height (widget)); |
| 774 | + return FALSE; |
| 775 | +#endif |
| 776 | } |
| 777 | |
| 778 | static gboolean |
| 779 | diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 780 | index c241ec8..24576dd 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 781 | --- a/gtk/inspector/general.c |
| 782 | +++ b/gtk/inspector/general.c |
| 783 | @@ -33,8 +33,10 @@ |
| 784 | |
| 785 | #ifdef GDK_WINDOWING_X11 |
| 786 | #include "x11/gdkx.h" |
| 787 | +#ifdef HAVE_OPENGL |
| 788 | #include <epoxy/glx.h> |
| 789 | #endif |
| 790 | +#endif |
| 791 | |
| 792 | #ifdef GDK_WINDOWING_WIN32 |
| 793 | #include "win32/gdkwin32.h" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 794 | @@ -196,6 +198,7 @@ add_label_row (GtkInspectorGeneral *gen, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 795 | gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label); |
| 796 | } |
| 797 | |
| 798 | +#ifdef HAVE_OPENGL |
| 799 | #ifdef GDK_WINDOWING_X11 |
| 800 | static void |
| 801 | append_glx_extension_row (GtkInspectorGeneral *gen, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 802 | @@ -205,6 +208,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen, |
| 803 | add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 804 | } |
| 805 | #endif |
| 806 | +#endif |
| 807 | |
| 808 | #ifdef GDK_WINDOWING_WAYLAND |
| 809 | static void |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 810 | @@ -254,6 +258,7 @@ wayland_get_display (struct wl_display *wl_display) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 811 | static void |
| 812 | init_gl (GtkInspectorGeneral *gen) |
| 813 | { |
| 814 | +#ifdef HAVE_OPENGL |
| 815 | #ifdef GDK_WINDOWING_X11 |
| 816 | if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) |
| 817 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 818 | @@ -280,6 +285,7 @@ init_gl (GtkInspectorGeneral *gen) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 819 | } |
| 820 | else |
| 821 | #endif |
| 822 | +#endif |
| 823 | #ifdef GDK_WINDOWING_WAYLAND |
| 824 | if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) |
| 825 | { |
| 826 | diff --git a/tests/Makefile.am b/tests/Makefile.am |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 827 | index ee1e8b5..e6c6502 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 828 | --- a/tests/Makefile.am |
| 829 | +++ b/tests/Makefile.am |
| 830 | @@ -80,8 +80,6 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
| 831 | testfullscreen \ |
| 832 | testgeometry \ |
| 833 | testgiconpixbuf \ |
| 834 | - testglarea \ |
| 835 | - testglblending \ |
| 836 | testgrid \ |
| 837 | testgtk \ |
| 838 | testheaderbar \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 839 | @@ -172,12 +170,18 @@ noinst_PROGRAMS = $(TEST_PROGS) \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 840 | testactionbar \ |
| 841 | testwindowsize \ |
| 842 | testpopover \ |
| 843 | - gdkgears \ |
| 844 | listmodel \ |
| 845 | testpopup \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 846 | testpopupat \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 847 | $(NULL) |
| 848 | |
| 849 | +if HAVE_OPENGL |
| 850 | +noinst_PROGRAMS += |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 851 | + testglarea \ |
| 852 | + testglblending \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 853 | + gdkgears |
| 854 | +endif |
| 855 | + |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 856 | if USE_WAYLAND |
| 857 | noinst_PROGRAMS += testforeign |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 858 | endif |
| 859 | diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 860 | index 24540e3..e0f863a 100644 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 861 | --- a/testsuite/gtk/objects-finalize.c |
| 862 | +++ b/testsuite/gtk/objects-finalize.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 863 | @@ -116,7 +116,9 @@ main (int argc, char **argv) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 864 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE && |
| 865 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 && |
| 866 | all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER && |
| 867 | +#ifdef HAVE_OPENGL |
| 868 | all_types[i] != GDK_TYPE_X11_GL_CONTEXT && |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 869 | +#endif |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 870 | #endif |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 871 | /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */ |
| 872 | all_types[i] != GDK_TYPE_PIXBUF_LOADER && |