[gtk/wip/matthiasc/shared-glyph-cache] Move shared context creation to the frontend
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/shared-glyph-cache] Move shared context creation to the frontend
- Date: Tue, 4 Jun 2019 02:53:50 +0000 (UTC)
commit 09ce4f67224889a37c43019d4ccb374538519fe1
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jun 4 01:59:03 2019 +0000
Move shared context creation to the frontend
And use it for both X11 and Wayland. This makes
the shared glyph cache work for both X11/GL and
Wayland/GL.
gdk/gdkinternals.h | 2 ++
gdk/gdksurface.c | 39 ++++++++++++++++++++++++++++++++++++++
gdk/wayland/gdkglcontext-wayland.c | 5 ++++-
gdk/x11/gdkglcontext-x11.c | 8 +++++---
4 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 143ed59529..13b139f5ce 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -274,6 +274,8 @@ void gdk_surface_move_resize (GdkSurface *surface,
gint width,
gint height);
+GdkGLContext *gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
+
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 082918d895..34ebb0fd4c 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1110,6 +1110,45 @@ gdk_surface_get_state (GdkSurface *surface)
return surface->state;
}
+GdkGLContext *
+gdk_surface_get_shared_data_gl_context (GdkSurface *surface)
+{
+ static int in_shared_data_creation;
+ GdkDisplay *display;
+ GdkGLContext *context;
+
+ if (in_shared_data_creation)
+ return NULL;
+
+ in_shared_data_creation = 1;
+
+ display = gdk_surface_get_display (surface);
+ context = (GdkGLContext *)g_object_get_data (G_OBJECT (display), "shared_data_gl_context");
+ if (context == NULL)
+ {
+ GError *error = NULL;
+ context = GDK_SURFACE_GET_CLASS (surface)->create_gl_context (surface, FALSE, NULL, &error);
+ if (context == NULL)
+ {
+ g_warning ("Failed to create shared context: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ gdk_gl_context_realize (context, &error);
+ if (context == NULL)
+ {
+ g_warning ("Failed to realize shared context: %s", error->message);
+ g_clear_error (&error);
+ }
+
+
+ g_object_set_data (G_OBJECT (display), "shared_data_gl_context", context);
+ }
+
+ in_shared_data_creation = 0;
+
+ return context;
+}
GdkGLContext *
gdk_surface_get_paint_gl_context (GdkSurface *surface,
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 4fbcf89852..2390e8a504 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -48,6 +48,9 @@ ensure_shared_data_context (GdkSurface *surface)
GdkDisplay *display;
GdkGLContext *context;
+ if (in_shared_data_creation)
+ return NULL;
+
in_shared_data_creation = 1;
display = gdk_surface_get_display (surface);
@@ -85,7 +88,7 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
- GdkGLContext *shared_data_context = in_shared_data_creation ? NULL : ensure_shared_data_context
(gdk_gl_context_get_surface (context));
+ GdkGLContext *shared_data_context = gdk_surface_get_shared_data_gl_context (gdk_gl_context_get_surface
(context));
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index b95a18517c..1385713609 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -576,6 +576,7 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
Display *dpy;
DrawableInfo *info;
GdkGLContext *share;
+ GdkGLContext *shared_data_context;
GdkSurface *surface;
gboolean debug_bit, compat_bit, legacy_bit, es_bit;
int major, minor, flags;
@@ -586,6 +587,7 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
context_x11 = GDK_X11_GL_CONTEXT (context);
display_x11 = GDK_X11_DISPLAY (display);
share = gdk_gl_context_get_shared_context (context);
+ shared_data_context = gdk_surface_get_shared_data_gl_context (surface);
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
@@ -625,7 +627,7 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
if (legacy_bit && !GDK_X11_DISPLAY (display)->has_glx_create_context)
{
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating legacy GL context on request"));
- context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share);
+ context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share ? share :
shared_data_context);
}
else
{
@@ -650,14 +652,14 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating GL3 context"));
context_x11->glx_context = create_gl3_context (display,
context_x11->glx_config,
- share,
+ share ? share : shared_data_context,
profile, flags, major, minor);
/* Fall back to legacy in case the GL3 context creation failed */
if (context_x11->glx_context == NULL)
{
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating fallback legacy context"));
- context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share);
+ context_x11->glx_context = create_legacy_context (display, context_x11->glx_config, share ? share
: shared_data_context);
legacy_bit = TRUE;
es_bit = FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]