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