diff options
Diffstat (limited to 'meta/recipes-gnome/gtk+/gtk+3/opengl.patch')
-rw-r--r-- | meta/recipes-gnome/gtk+/gtk+3/opengl.patch | 738 |
1 files changed, 738 insertions, 0 deletions
diff --git a/meta/recipes-gnome/gtk+/gtk+3/opengl.patch b/meta/recipes-gnome/gtk+/gtk+3/opengl.patch new file mode 100644 index 0000000000..8f2feb0ee7 --- /dev/null +++ b/meta/recipes-gnome/gtk+/gtk+3/opengl.patch | |||
@@ -0,0 +1,738 @@ | |||
1 | From 4a0716f04fb25b51b08e994bd5a900b2e7f7fed5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Jussi Kukkonen <jussi.kukkonen@intel.com> | ||
3 | Date: Fri, 16 Oct 2015 16:35:16 +0300 | ||
4 | Subject: [PATCH] Do not try to initialize GL without libGL | ||
5 | |||
6 | _gdk_x11_screen_update_visuals_for_gl() will end up calling epoxys | ||
7 | GLX api which will exit() if libGL.so.1 is not present. We do not | ||
8 | want that to happen and we don't want every app to have to set | ||
9 | "GDK_GL=disabled" environment variable: so use #ifdef set based on | ||
10 | opengl distro feature. | ||
11 | |||
12 | Upstream is not interested in the fix as it is: Either epoxy should be | ||
13 | fixed (to not exit) or GTK+ possibly could do some additional probing | ||
14 | before calling epoxy APIs. | ||
15 | |||
16 | Upstream-Status: Denied | ||
17 | Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> | ||
18 | --- | ||
19 | demos/gtk-demo/meson.build | 5 ++++- | ||
20 | docs/tools/meson.build | 7 +++++-- | ||
21 | docs/tools/widgets.c | 6 +++++- | ||
22 | gdk/gdkconfig.h.meson | 1 + | ||
23 | gdk/gdkdisplay.c | 4 ++++ | ||
24 | gdk/gdkgl.c | 10 ++++++++++ | ||
25 | gdk/gdkglcontext.c | 6 ++++++ | ||
26 | gdk/gdkwindow.c | 13 +++++++++++++ | ||
27 | gdk/meson.build | 8 +++++++- | ||
28 | gdk/x11/gdkdisplay-x11.c | 6 +++++- | ||
29 | gdk/x11/gdkvisual-x11.c | 5 +++++ | ||
30 | gdk/x11/gdkwindow-x11.c | 4 ++++ | ||
31 | gdk/x11/gdkx-autocleanups.h | 2 ++ | ||
32 | gdk/x11/gdkx.h | 2 ++ | ||
33 | gdk/x11/meson.build | 7 +++++-- | ||
34 | gtk/gtkglarea.c | 19 +++++++++++++++++++ | ||
35 | gtk/inspector/general.c | 6 ++++++ | ||
36 | meson.build | 17 ++++++++++++++--- | ||
37 | meson_options.txt | 2 ++ | ||
38 | tests/meson.build | 9 +++++++-- | ||
39 | testsuite/gtk/objects-finalize.c | 2 ++ | ||
40 | 21 files changed, 128 insertions(+), 13 deletions(-) | ||
41 | |||
42 | diff --git a/demos/gtk-demo/meson.build b/demos/gtk-demo/meson.build | ||
43 | index 252da16d05..4b57cff6ac 100644 | ||
44 | --- a/demos/gtk-demo/meson.build | ||
45 | +++ b/demos/gtk-demo/meson.build | ||
46 | @@ -28,7 +28,6 @@ demos = files([ | ||
47 | 'fishbowl.c', | ||
48 | 'foreigndrawing.c', | ||
49 | 'gestures.c', | ||
50 | - 'glarea.c', | ||
51 | 'headerbar.c', | ||
52 | 'hypertext.c', | ||
53 | 'iconview.c', | ||
54 | @@ -87,6 +86,10 @@ elif harfbuzz_dep.found() and pangoft_dep.found() | ||
55 | gtkdemo_deps += [harfbuzz_dep, pangoft_dep] | ||
56 | endif | ||
57 | |||
58 | +if opengl_enabled | ||
59 | + demos += files('glarea.c') | ||
60 | +endif | ||
61 | + | ||
62 | if os_unix | ||
63 | demos += files('pagesetup.c') | ||
64 | endif | ||
65 | diff --git a/docs/tools/meson.build b/docs/tools/meson.build | ||
66 | index 05621ee7ed..3d0a333b32 100644 | ||
67 | --- a/docs/tools/meson.build | ||
68 | +++ b/docs/tools/meson.build | ||
69 | @@ -2,10 +2,13 @@ if x11_enabled | ||
70 | doc_shooter_sources = [ | ||
71 | 'shadow.c', | ||
72 | 'shooter.c', | ||
73 | - 'widgets.c', | ||
74 | - '../../tests/gtkgears.c', | ||
75 | + 'widgets.c' | ||
76 | ] | ||
77 | |||
78 | + if opengl_enabled | ||
79 | + doc_shooter_sources += ['../../tests/gtkgears.c'] | ||
80 | + endif | ||
81 | + | ||
82 | doc_shooter = executable('doc-shooter', doc_shooter_sources, | ||
83 | include_directories: [ confinc, gdkinc, gtkinc, testinc, ], | ||
84 | dependencies: libgtk_dep) | ||
85 | diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c | ||
86 | index 932daf1746..348807e133 100644 | ||
87 | --- a/docs/tools/widgets.c | ||
88 | +++ b/docs/tools/widgets.c | ||
89 | @@ -8,7 +8,9 @@ | ||
90 | #include <X11/Xatom.h> | ||
91 | #include <gdkx.h> | ||
92 | #include "widgets.h" | ||
93 | +#ifdef HAVE_OPENGL | ||
94 | #include "gtkgears.h" | ||
95 | +#endif | ||
96 | |||
97 | #define SMALL_WIDTH 240 | ||
98 | #define SMALL_HEIGHT 75 | ||
99 | @@ -1526,9 +1528,11 @@ create_gl_area (void) | ||
100 | widget = gtk_frame_new (NULL); | ||
101 | gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN); | ||
102 | |||
103 | +#ifdef HAVE_OPENGL | ||
104 | gears = gtk_gears_new (); | ||
105 | gtk_container_add (GTK_CONTAINER (widget), gears); | ||
106 | - | ||
107 | +#endif | ||
108 | + | ||
109 | info = new_widget_info ("glarea", widget, MEDIUM); | ||
110 | |||
111 | return info; | ||
112 | diff --git a/gdk/gdkconfig.h.meson b/gdk/gdkconfig.h.meson | ||
113 | index 7db19e0470..088651bafa 100644 | ||
114 | --- a/gdk/gdkconfig.h.meson | ||
115 | +++ b/gdk/gdkconfig.h.meson | ||
116 | @@ -15,6 +15,7 @@ G_BEGIN_DECLS | ||
117 | #mesondefine GDK_WINDOWING_WAYLAND | ||
118 | #mesondefine GDK_WINDOWING_WIN32 | ||
119 | #mesondefine GDK_WINDOWING_QUARTZ | ||
120 | +#mesondefine GDK_WITH_OPENGL | ||
121 | |||
122 | G_END_DECLS | ||
123 | |||
124 | diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c | ||
125 | index 748f54860c..04ef2c09d4 100644 | ||
126 | --- a/gdk/gdkdisplay.c | ||
127 | +++ b/gdk/gdkdisplay.c | ||
128 | @@ -2420,7 +2420,11 @@ gboolean | ||
129 | gdk_display_make_gl_context_current (GdkDisplay *display, | ||
130 | GdkGLContext *context) | ||
131 | { | ||
132 | +#ifdef HAVE_OPENGL | ||
133 | return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context); | ||
134 | +#else | ||
135 | + return FALSE; | ||
136 | +#endif | ||
137 | } | ||
138 | |||
139 | GdkRenderingMode | ||
140 | diff --git a/gdk/gdkgl.c b/gdk/gdkgl.c | ||
141 | index 9690077cc2..55f85ef605 100644 | ||
142 | --- a/gdk/gdkgl.c | ||
143 | +++ b/gdk/gdkgl.c | ||
144 | @@ -21,8 +21,9 @@ | ||
145 | #include "gdkglcontextprivate.h" | ||
146 | |||
147 | #include "gdkinternals.h" | ||
148 | - | ||
149 | +#ifdef HAVE_OPENGL | ||
150 | #include <epoxy/gl.h> | ||
151 | +#endif | ||
152 | #include <math.h> | ||
153 | #include <string.h> | ||
154 | |||
155 | @@ -36,6 +37,7 @@ | ||
156 | g_object_ref (window), g_object_unref); | ||
157 | } | ||
158 | |||
159 | +#ifdef HAVE_OPENGL | ||
160 | static const char * | ||
161 | get_vertex_type_name (int type) | ||
162 | { | ||
163 | @@ -208,6 +210,7 @@ | ||
164 | glUseProgram (paint_data->current_program->program); | ||
165 | } | ||
166 | } | ||
167 | +#endif | ||
168 | |||
169 | void | ||
170 | gdk_gl_texture_quads (GdkGLContext *paint_context, | ||
171 | @@ -216,6 +219,7 @@ | ||
172 | GdkTexturedQuad *quads, | ||
173 | gboolean flip_colors) | ||
174 | { | ||
175 | +#ifdef HAVE_OPENGL | ||
176 | GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context); | ||
177 | GdkGLContextProgram *program; | ||
178 | GdkWindow *window = gdk_gl_context_get_window (paint_context); | ||
179 | @@ -289,6 +293,7 @@ | ||
180 | |||
181 | glDisableVertexAttribArray (program->position_location); | ||
182 | glDisableVertexAttribArray (program->uv_location); | ||
183 | +#endif | ||
184 | } | ||
185 | |||
186 | /* x,y,width,height describes a rectangle in the gl render buffer | ||
187 | @@ -337,6 +342,7 @@ | ||
188 | int width, | ||
189 | int height) | ||
190 | { | ||
191 | +#ifdef HAVE_OPENGL | ||
192 | GdkGLContext *paint_context, *current_context; | ||
193 | cairo_surface_t *image; | ||
194 | cairo_matrix_t matrix; | ||
195 | @@ -703,6 +709,7 @@ | ||
196 | if (clip_region) | ||
197 | cairo_region_destroy (clip_region); | ||
198 | |||
199 | +#endif | ||
200 | } | ||
201 | |||
202 | /* This is always called with the paint context current */ | ||
203 | @@ -710,6 +717,7 @@ | ||
204 | gdk_gl_texture_from_surface (cairo_surface_t *surface, | ||
205 | cairo_region_t *region) | ||
206 | { | ||
207 | +#ifdef HAVE_OPENGL | ||
208 | GdkGLContext *paint_context; | ||
209 | cairo_surface_t *image; | ||
210 | double device_x_offset, device_y_offset; | ||
211 | @@ -810,4 +818,5 @@ | ||
212 | |||
213 | glDisable (GL_SCISSOR_TEST); | ||
214 | glDeleteTextures (1, &texture_id); | ||
215 | +#endif | ||
216 | } | ||
217 | diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c | ||
218 | index 3b23639e1c..1f04f8e0b2 100644 | ||
219 | --- a/gdk/gdkglcontext.c | ||
220 | +++ b/gdk/gdkglcontext.c | ||
221 | @@ -85,7 +85,9 @@ | ||
222 | #include "gdkintl.h" | ||
223 | #include "gdk-private.h" | ||
224 | |||
225 | +#ifdef HAVE_OPENGL | ||
226 | #include <epoxy/gl.h> | ||
227 | +#endif | ||
228 | |||
229 | typedef struct { | ||
230 | GdkDisplay *display; | ||
231 | @@ -243,6 +245,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, | ||
232 | int height, | ||
233 | guint texture_target) | ||
234 | { | ||
235 | +#ifdef HAVE_OPENGL | ||
236 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); | ||
237 | |||
238 | g_return_if_fail (GDK_IS_GL_CONTEXT (context)); | ||
239 | @@ -286,6 +289,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context, | ||
240 | glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride)); | ||
241 | } | ||
242 | } | ||
243 | +#endif | ||
244 | } | ||
245 | |||
246 | static gboolean | ||
247 | @@ -774,6 +778,7 @@ gdk_gl_context_realize (GdkGLContext *context, | ||
248 | static void | ||
249 | gdk_gl_context_check_extensions (GdkGLContext *context) | ||
250 | { | ||
251 | +#ifdef HAVE_OPENGL | ||
252 | GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context); | ||
253 | gboolean has_npot, has_texture_rectangle; | ||
254 | |||
255 | @@ -853,6 +858,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context) | ||
256 | priv->use_texture_rectangle ? "yes" : "no")); | ||
257 | |||
258 | priv->extensions_checked = TRUE; | ||
259 | +#endif | ||
260 | } | ||
261 | |||
262 | /** | ||
263 | diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c | ||
264 | index 727b0cf1f4..d4d91b0d16 100644 | ||
265 | --- a/gdk/gdkwindow.c | ||
266 | +++ b/gdk/gdkwindow.c | ||
267 | @@ -45,7 +45,9 @@ | ||
268 | |||
269 | #include <math.h> | ||
270 | |||
271 | +#ifdef HAVE_OPENGL | ||
272 | #include <epoxy/gl.h> | ||
273 | +#endif | ||
274 | |||
275 | /* for the use of round() */ | ||
276 | #include "fallback-c89.c" | ||
277 | @@ -2844,6 +2846,13 @@ gdk_window_get_paint_gl_context (GdkWindow *window, | ||
278 | { | ||
279 | GError *internal_error = NULL; | ||
280 | |||
281 | +#ifndef HAVE_OPENGL | ||
282 | + g_set_error_literal (error, GDK_GL_ERROR, | ||
283 | + GDK_GL_ERROR_NOT_AVAILABLE, | ||
284 | + _("GL support disabled with --disable-opengl")); | ||
285 | + return NULL; | ||
286 | +#endif | ||
287 | + | ||
288 | if (_gdk_gl_flags & GDK_GL_DISABLE) | ||
289 | { | ||
290 | g_set_error_literal (error, GDK_GL_ERROR, | ||
291 | @@ -2979,6 +2988,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, | ||
292 | } | ||
293 | else | ||
294 | { | ||
295 | +#ifdef HAVE_OPENGL | ||
296 | gdk_gl_context_make_current (context); | ||
297 | /* With gl we always need a surface to combine the gl | ||
298 | drawing with the native drawing. */ | ||
299 | @@ -2993,6 +3003,7 @@ gdk_window_begin_paint_internal (GdkWindow *window, | ||
300 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
301 | |||
302 | glViewport (0, 0, ww, wh); | ||
303 | +#endif | ||
304 | } | ||
305 | } | ||
306 | |||
307 | @@ -3056,6 +3067,7 @@ gdk_window_end_paint_internal (GdkWindow *window) | ||
308 | |||
309 | gdk_gl_context_make_current (window->gl_paint_context); | ||
310 | |||
311 | +#ifdef HAVE_OPENGL | ||
312 | if (!cairo_region_is_empty (opaque_region)) | ||
313 | gdk_gl_texture_from_surface (window->current_paint.surface, | ||
314 | opaque_region); | ||
315 | @@ -3066,6 +3078,7 @@ gdk_window_end_paint_internal (GdkWindow *window) | ||
316 | window->current_paint.need_blend_region); | ||
317 | glDisable(GL_BLEND); | ||
318 | } | ||
319 | +#endif | ||
320 | |||
321 | cairo_region_destroy (opaque_region); | ||
322 | |||
323 | diff --git a/gdk/meson.build b/gdk/meson.build | ||
324 | index 4bb1bf2b6c..64172b8d3e 100644 | ||
325 | --- a/gdk/meson.build | ||
326 | +++ b/gdk/meson.build | ||
327 | @@ -56,7 +56,6 @@ gdk_gir_public_headers = files( | ||
328 | 'gdkdrawingcontext.h', | ||
329 | 'gdkevents.h', | ||
330 | 'gdkframetimings.h', | ||
331 | - 'gdkglcontext.h', | ||
332 | 'gdkkeys.h', | ||
333 | 'gdkkeysyms.h', | ||
334 | 'gdkmain.h', | ||
335 | @@ -78,6 +77,12 @@ gdk_gir_public_headers = files( | ||
336 | 'gdkwindow.h', | ||
337 | ) | ||
338 | gdk_nogir_public_headers = [files('gdkkeysyms-compat.h')] | ||
339 | +if opengl_enabled | ||
340 | +gdk_gir_public_headers += files('gdkglcontext.h') | ||
341 | +else | ||
342 | +gdk_nogir_public_headers += files('gdkglcontext.h') | ||
343 | +endif | ||
344 | + | ||
345 | gdk_public_headers = gdk_gir_public_headers + gdk_nogir_public_headers | ||
346 | install_headers(gdk_public_headers, subdir : 'gtk-3.0/gdk') | ||
347 | |||
348 | @@ -166,6 +171,7 @@ gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled) | ||
349 | gdkconfig_cdata.set('GDK_WINDOWING_WIN32', win32_enabled) | ||
350 | gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled) | ||
351 | gdkconfig_cdata.set('GDK_WINDOWING_QUARTZ', quartz_enabled) | ||
352 | +gdkconfig_cdata.set('GDK_WITH_OPENGL', opengl_enabled) | ||
353 | |||
354 | gdkconfig = configure_file( | ||
355 | input : 'gdkconfig.h.meson', | ||
356 | diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c | ||
357 | index 7e08f472cc..30fd7b6089 100644 | ||
358 | --- a/gdk/x11/gdkdisplay-x11.c | ||
359 | +++ b/gdk/x11/gdkdisplay-x11.c | ||
360 | @@ -37,7 +37,9 @@ | ||
361 | #include "gdkdisplay-x11.h" | ||
362 | #include "gdkprivate-x11.h" | ||
363 | #include "gdkscreen-x11.h" | ||
364 | +#ifdef HAVE_OPENGL | ||
365 | #include "gdkglcontext-x11.h" | ||
366 | +#endif | ||
367 | #include "gdk-private.h" | ||
368 | #include "gdkprofilerprivate.h" | ||
369 | |||
370 | @@ -3191,7 +3193,9 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class) | ||
371 | display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list; | ||
372 | display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target; | ||
373 | |||
374 | - display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; | ||
375 | +#ifdef HAVE_OPENGL | ||
376 | + display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current; | ||
377 | +#endif | ||
378 | |||
379 | display_class->get_default_seat = gdk_x11_display_get_default_seat; | ||
380 | |||
381 | diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c | ||
382 | index 81479d81f4..3c8c5c02ff 100644 | ||
383 | --- a/gdk/x11/gdkvisual-x11.c | ||
384 | +++ b/gdk/x11/gdkvisual-x11.c | ||
385 | @@ -306,7 +306,12 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen) | ||
386 | /* If GL is available we want to pick better default/rgba visuals, | ||
387 | as we care about glx details such as alpha/depth/stencil depth, | ||
388 | stereo and double buffering */ | ||
389 | + /* update_visuals_for_gl() will end up calling epoxy GLX api which | ||
390 | + will exit if libgl is not there: so only do this if we know GL | ||
391 | + is available */ | ||
392 | +#ifdef HAVE_GLX | ||
393 | _gdk_x11_screen_update_visuals_for_gl (screen); | ||
394 | +#endif | ||
395 | } | ||
396 | |||
397 | gint | ||
398 | diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c | ||
399 | index 194bc82e29..0302bb68d4 100644 | ||
400 | --- a/gdk/x11/gdkwindow-x11.c | ||
401 | +++ b/gdk/x11/gdkwindow-x11.c | ||
402 | @@ -36,7 +36,9 @@ | ||
403 | #include "gdkasync.h" | ||
404 | #include "gdkeventsource.h" | ||
405 | #include "gdkdisplay-x11.h" | ||
406 | +#ifdef HAVE_OPENGL | ||
407 | #include "gdkglcontext-x11.h" | ||
408 | +#endif | ||
409 | #include "gdkprivate-x11.h" | ||
410 | #include "gdk-private.h" | ||
411 | |||
412 | @@ -5888,7 +5890,9 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass) | ||
413 | impl_class->set_opaque_region = gdk_x11_window_set_opaque_region; | ||
414 | impl_class->set_shadow_width = gdk_x11_window_set_shadow_width; | ||
415 | impl_class->show_window_menu = gdk_x11_window_show_window_menu; | ||
416 | +#ifdef HAVE_OPENGL | ||
417 | impl_class->create_gl_context = gdk_x11_window_create_gl_context; | ||
418 | impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame; | ||
419 | +#endif | ||
420 | impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size; | ||
421 | } | ||
422 | diff --git a/gdk/x11/gdkx-autocleanups.h b/gdk/x11/gdkx-autocleanups.h | ||
423 | index edb0ea7dbf..a317d61cca 100644 | ||
424 | --- a/gdk/x11/gdkx-autocleanups.h | ||
425 | +++ b/gdk/x11/gdkx-autocleanups.h | ||
426 | @@ -30,7 +30,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DeviceXI2, g_object_unref) | ||
427 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Display, g_object_unref) | ||
428 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DisplayManager, g_object_unref) | ||
429 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11DragContext, g_object_unref) | ||
430 | +#ifdef HAVE_OPENGL | ||
431 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11GLContext, g_object_unref) | ||
432 | +#endif | ||
433 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Keymap, g_object_unref) | ||
434 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Screen, g_object_unref) | ||
435 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkX11Visual, g_object_unref) | ||
436 | diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h | ||
437 | index 1f64bccb6d..4db6c18351 100644 | ||
438 | --- a/gdk/x11/gdkx.h | ||
439 | +++ b/gdk/x11/gdkx.h | ||
440 | @@ -43,7 +43,9 @@ | ||
441 | #include <gdk/x11/gdkx11display.h> | ||
442 | #include <gdk/x11/gdkx11displaymanager.h> | ||
443 | #include <gdk/x11/gdkx11dnd.h> | ||
444 | +#ifdef GDK_WITH_OPENGL | ||
445 | #include <gdk/x11/gdkx11glcontext.h> | ||
446 | +#endif | ||
447 | #include <gdk/x11/gdkx11keys.h> | ||
448 | #include <gdk/x11/gdkx11monitor.h> | ||
449 | #include <gdk/x11/gdkx11property.h> | ||
450 | diff --git a/gdk/x11/meson.build b/gdk/x11/meson.build | ||
451 | index 754ae0a615..0318c83877 100644 | ||
452 | --- a/gdk/x11/meson.build | ||
453 | +++ b/gdk/x11/meson.build | ||
454 | @@ -14,7 +14,6 @@ gdk_x11_sources = files( | ||
455 | 'gdkeventsource.c', | ||
456 | 'gdkeventtranslator.c', | ||
457 | 'gdkgeometry-x11.c', | ||
458 | - 'gdkglcontext-x11.c', | ||
459 | 'gdkkeys-x11.c', | ||
460 | 'gdkmain-x11.c', | ||
461 | 'gdkproperty-x11.c', | ||
462 | @@ -42,7 +41,6 @@ gdk_x11_public_headers = files( | ||
463 | 'gdkx11display.h', | ||
464 | 'gdkx11displaymanager.h', | ||
465 | 'gdkx11dnd.h', | ||
466 | - 'gdkx11glcontext.h', | ||
467 | 'gdkx11keys.h', | ||
468 | 'gdkx11monitor.h', | ||
469 | 'gdkx11property.h', | ||
470 | @@ -53,6 +51,11 @@ gdk_x11_public_headers = files( | ||
471 | 'gdkx11window.h', | ||
472 | ) | ||
473 | |||
474 | +if opengl_enabled | ||
475 | + gdk_x11_sources += files('gdkglcontext-x11.c') | ||
476 | + gdk_x11_public_headers += files('gdkx11glcontext.h') | ||
477 | +endif | ||
478 | + | ||
479 | install_headers(gdk_x11_public_headers, subdir: 'gtk-3.0/gdk/x11/') | ||
480 | install_headers('gdkx.h', subdir: 'gtk-3.0/gdk/') | ||
481 | |||
482 | diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c | ||
483 | index 802303ea9f..6439d7745d 100644 | ||
484 | --- a/gtk/gtkglarea.c | ||
485 | +++ b/gtk/gtkglarea.c | ||
486 | @@ -29,7 +29,9 @@ | ||
487 | #include "gtkprivate.h" | ||
488 | #include "gtkrender.h" | ||
489 | |||
490 | +#ifdef HAVE_OPENGL | ||
491 | #include <epoxy/gl.h> | ||
492 | +#endif | ||
493 | |||
494 | /** | ||
495 | * SECTION:gtkglarea | ||
496 | @@ -369,9 +371,12 @@ gtk_gl_area_real_create_context (GtkGLArea *area) | ||
497 | static void | ||
498 | gtk_gl_area_resize (GtkGLArea *area, int width, int height) | ||
499 | { | ||
500 | +#ifdef HAVE_OPENGL | ||
501 | glViewport (0, 0, width, height); | ||
502 | +#endif | ||
503 | } | ||
504 | |||
505 | +#ifdef HAVE_OPENGL | ||
506 | /* | ||
507 | * Creates all the buffer objects needed for rendering the scene | ||
508 | */ | ||
509 | @@ -483,6 +488,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) | ||
510 | |||
511 | priv->needs_render = TRUE; | ||
512 | } | ||
513 | +#endif | ||
514 | |||
515 | /** | ||
516 | * gtk_gl_area_attach_buffers: | ||
517 | @@ -501,6 +507,7 @@ gtk_gl_area_allocate_buffers (GtkGLArea *area) | ||
518 | void | ||
519 | gtk_gl_area_attach_buffers (GtkGLArea *area) | ||
520 | { | ||
521 | +#ifdef HAVE_OPENGL | ||
522 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); | ||
523 | |||
524 | g_return_if_fail (GTK_IS_GL_AREA (area)); | ||
525 | @@ -533,11 +540,13 @@ gtk_gl_area_attach_buffers (GtkGLArea *area) | ||
526 | glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, | ||
527 | GL_RENDERBUFFER, priv->depth_stencil_buffer); | ||
528 | } | ||
529 | +#endif | ||
530 | } | ||
531 | |||
532 | static void | ||
533 | gtk_gl_area_delete_buffers (GtkGLArea *area) | ||
534 | { | ||
535 | +#ifdef HAVE_OPENGL | ||
536 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); | ||
537 | |||
538 | if (priv->context == NULL) | ||
539 | @@ -569,6 +578,7 @@ gtk_gl_area_delete_buffers (GtkGLArea *area) | ||
540 | glDeleteFramebuffers (1, &priv->frame_buffer); | ||
541 | priv->frame_buffer = 0; | ||
542 | } | ||
543 | +#endif | ||
544 | } | ||
545 | |||
546 | static void | ||
547 | @@ -679,6 +689,7 @@ gtk_gl_area_draw (GtkWidget *widget, | ||
548 | GtkGLArea *area = GTK_GL_AREA (widget); | ||
549 | GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area); | ||
550 | gboolean unused; | ||
551 | +#ifdef HAVE_OPENGL | ||
552 | int w, h, scale; | ||
553 | GLenum status; | ||
554 | |||
555 | @@ -736,6 +747,14 @@ gtk_gl_area_draw (GtkWidget *widget, | ||
556 | } | ||
557 | |||
558 | return TRUE; | ||
559 | +#else | ||
560 | + if (priv->error != NULL) | ||
561 | + gtk_gl_area_draw_error_screen (area, | ||
562 | + cr, | ||
563 | + gtk_widget_get_allocated_width (widget), | ||
564 | + gtk_widget_get_allocated_height (widget)); | ||
565 | + return FALSE; | ||
566 | +#endif | ||
567 | } | ||
568 | |||
569 | static gboolean | ||
570 | diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c | ||
571 | index 4fd0c3039c..a8e59ed077 100644 | ||
572 | --- a/gtk/inspector/general.c | ||
573 | +++ b/gtk/inspector/general.c | ||
574 | @@ -33,8 +33,10 @@ | ||
575 | |||
576 | #ifdef GDK_WINDOWING_X11 | ||
577 | #include "x11/gdkx.h" | ||
578 | +#ifdef HAVE_OPENGL | ||
579 | #include <epoxy/glx.h> | ||
580 | #endif | ||
581 | +#endif | ||
582 | |||
583 | #ifdef GDK_WINDOWING_WIN32 | ||
584 | #include "win32/gdkwin32.h" | ||
585 | @@ -217,6 +219,7 @@ add_label_row (GtkInspectorGeneral *gen, | ||
586 | gtk_size_group_add_widget (GTK_SIZE_GROUP (gen->priv->labels), label); | ||
587 | } | ||
588 | |||
589 | +#ifdef HAVE_OPENGL | ||
590 | #ifdef GDK_WINDOWING_X11 | ||
591 | static void | ||
592 | append_glx_extension_row (GtkInspectorGeneral *gen, | ||
593 | @@ -226,6 +229,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen, | ||
594 | add_check_row (gen, GTK_LIST_BOX (gen->priv->gl_box), ext, epoxy_has_glx_extension (dpy, 0, ext), 0); | ||
595 | } | ||
596 | #endif | ||
597 | +#endif | ||
598 | |||
599 | #ifdef GDK_WINDOWING_WAYLAND | ||
600 | static void | ||
601 | @@ -275,6 +279,7 @@ wayland_get_display (struct wl_display *wl_display) | ||
602 | static void | ||
603 | init_gl (GtkInspectorGeneral *gen) | ||
604 | { | ||
605 | +#ifdef HAVE_OPENGL | ||
606 | #ifdef GDK_WINDOWING_X11 | ||
607 | if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) | ||
608 | { | ||
609 | @@ -301,6 +306,7 @@ init_gl (GtkInspectorGeneral *gen) | ||
610 | } | ||
611 | else | ||
612 | #endif | ||
613 | +#endif | ||
614 | #ifdef GDK_WINDOWING_WAYLAND | ||
615 | if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) | ||
616 | { | ||
617 | diff --git a/meson.build b/meson.build | ||
618 | index aed48fc3f6..bfc33af0f6 100644 | ||
619 | --- a/meson.build | ||
620 | +++ b/meson.build | ||
621 | @@ -137,6 +137,7 @@ wayland_enabled = get_option('wayland_backend') | ||
622 | broadway_enabled = get_option('broadway_backend') | ||
623 | quartz_enabled = get_option('quartz_backend') | ||
624 | win32_enabled = get_option('win32_backend') | ||
625 | +opengl_enabled = get_option('opengl') | ||
626 | |||
627 | os_unix = false | ||
628 | os_linux = false | ||
629 | @@ -430,7 +431,7 @@ pangocairo_dep = dependency('pangocairo', version: cairo_req, | ||
630 | fallback : ['pango', 'libpangocairo_dep']) | ||
631 | pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req, | ||
632 | fallback : ['gdk-pixbuf', 'gdkpixbuf_dep']) | ||
633 | -epoxy_dep = dependency('epoxy', version: epoxy_req, | ||
634 | +epoxy_dep = dependency('epoxy', version: epoxy_req, required: opengl_enabled, | ||
635 | fallback: ['libepoxy', 'libepoxy_dep']) | ||
636 | atk_dep = dependency('atk', version: atk_req, | ||
637 | fallback : ['atk', 'libatk_dep']) | ||
638 | @@ -476,6 +477,10 @@ if tracker3_enabled | ||
639 | endif | ||
640 | endif | ||
641 | |||
642 | +if opengl_enabled | ||
643 | + cdata.set('HAVE_OPENGL', 1) | ||
644 | +endif | ||
645 | + | ||
646 | if iso_codes_dep.found() | ||
647 | cdata.set_quoted('ISO_CODES_PREFIX', iso_codes_dep.get_variable(pkgconfig: 'prefix')) | ||
648 | else | ||
649 | @@ -912,9 +917,15 @@ else | ||
650 | gio_packages = ['gio-2.0', glib_req] | ||
651 | endif | ||
652 | |||
653 | +if opengl_enabled | ||
654 | + epoxy_packages = ['epoxy', epoxy_req] | ||
655 | +else | ||
656 | + epoxy_packages = [] | ||
657 | +endif | ||
658 | + | ||
659 | pkgconf.set('GDK_PRIVATE_PACKAGES', | ||
660 | ' '.join(gio_packages + x11_pkgs + wayland_pkgs + cairo_backends + | ||
661 | - ['epoxy', epoxy_req] + cloudproviders_packages + | ||
662 | + epoxy_packages + cloudproviders_packages + | ||
663 | ['fribidi', fribidi_req])) | ||
664 | |||
665 | gtk_packages = ' '.join([ | ||
666 | @@ -928,7 +939,7 @@ pkgconf.set('GTK_PACKAGES', gtk_packages) | ||
667 | # Requires.private | ||
668 | pc_gdk_extra_libs += cairo_libs | ||
669 | |||
670 | -gtk_private_packages = atk_pkgs + wayland_pkgs + ['epoxy', epoxy_req, 'fribidi', fribidi_req] | ||
671 | +gtk_private_packages = atk_pkgs + wayland_pkgs + epoxy_packages + ['fribidi', fribidi_req] | ||
672 | if wayland_enabled or x11_enabled | ||
673 | gtk_private_packages += ['pangoft2'] | ||
674 | endif | ||
675 | diff --git a/meson_options.txt b/meson_options.txt | ||
676 | index 94099aa01e..8bd096896d 100644 | ||
677 | --- a/meson_options.txt | ||
678 | +++ b/meson_options.txt | ||
679 | @@ -19,6 +19,8 @@ option('profiler', type: 'boolean', value: false, | ||
680 | description : 'Enable profiler support') | ||
681 | option('tracker3', type: 'boolean', value: false, | ||
682 | description : 'Enable Tracker3 filechooser search') | ||
683 | +option('opengl', type: 'boolean', value: true, | ||
684 | + description : 'Enable use of GL') | ||
685 | |||
686 | # Print backends | ||
687 | option('print_backends', type : 'string', value : 'auto', | ||
688 | diff --git a/tests/meson.build b/tests/meson.build | ||
689 | index 586fe2f45e..6ecf317dde 100644 | ||
690 | --- a/tests/meson.build | ||
691 | +++ b/tests/meson.build | ||
692 | @@ -5,7 +5,6 @@ gtk_tests = [ | ||
693 | ['scrolling-performance', ['frame-stats.c', 'variable.c']], | ||
694 | ['blur-performance', ['../gtk/gtkcairoblur.c']], | ||
695 | ['flicker'], | ||
696 | - ['gdkgears', ['gtkgears.c']], | ||
697 | ['listmodel'], | ||
698 | ['motion-compression'], | ||
699 | ['styleexamples'], | ||
700 | @@ -54,7 +53,6 @@ gtk_tests = [ | ||
701 | ['testfullscreen'], | ||
702 | ['testgeometry'], | ||
703 | ['testgiconpixbuf'], | ||
704 | - ['testglblending', ['gtkgears.c']], | ||
705 | ['testgmenu'], | ||
706 | ['testgrid'], | ||
707 | ['testgrouping'], | ||
708 | @@ -137,6 +135,13 @@ if x11_enabled | ||
709 | ] | ||
710 | endif | ||
711 | |||
712 | +if opengl_enabled | ||
713 | + gtk_tests += [ | ||
714 | + ['gdkgears', ['gtkgears.c']], | ||
715 | + ['testglblending', ['gtkgears.c']], | ||
716 | + ] | ||
717 | +endif | ||
718 | + | ||
719 | if os_linux | ||
720 | gtk_tests += [['testfontchooserdialog']] | ||
721 | endif | ||
722 | diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c | ||
723 | index 24540e313f..e0f863ab6a 100644 | ||
724 | --- a/testsuite/gtk/objects-finalize.c | ||
725 | +++ b/testsuite/gtk/objects-finalize.c | ||
726 | @@ -116,7 +116,9 @@ main (int argc, char **argv) | ||
727 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_CORE && | ||
728 | all_types[i] != GDK_TYPE_X11_DEVICE_MANAGER_XI2 && | ||
729 | all_types[i] != GDK_TYPE_X11_DISPLAY_MANAGER && | ||
730 | +#ifdef HAVE_OPENGL | ||
731 | all_types[i] != GDK_TYPE_X11_GL_CONTEXT && | ||
732 | +#endif | ||
733 | #endif | ||
734 | /* Not allowed to finalize a GdkPixbufLoader without calling gdk_pixbuf_loader_close() */ | ||
735 | all_types[i] != GDK_TYPE_PIXBUF_LOADER && | ||
736 | -- | ||
737 | 2.30.2 | ||
738 | |||