[gtk/wip/otte/gleanup: 1/2] x11: Move the EGL display into the private struct
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/gleanup: 1/2] x11: Move the EGL display into the private struct
- Date: Wed, 9 Jun 2021 12:15:33 +0000 (UTC)
commit 893e130155e8b6b6d012400004ccfa74a936571b
Author: Benjamin Otte <otte redhat com>
Date: Mon Jun 7 14:30:29 2021 +0200
x11: Move the EGL display into the private struct
There's no need to use g_object_set_data() for it.
We can also stop caching it elsewhere because we know the display has
it.
gdk/x11/gdkdisplay-x11.h | 2 ++
gdk/x11/gdkglcontext-egl.c | 30 ++++++++++++------------------
2 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index db48411091..a88a728112 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -137,6 +137,8 @@ struct _GdkX11Display
int glx_event_base;
/* EGL information */
+ /* We use gpointer here so we don't have to pull in EGL headers (which glx doesn't like) */
+ /* EGLDisplay */ gpointer egl_display;
int egl_version;
/* Translation between X server time and system-local monotonic time */
diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c
index 8d4dff9483..fd6109f0a3 100644
--- a/gdk/x11/gdkglcontext-egl.c
+++ b/gdk/x11/gdkglcontext-egl.c
@@ -35,7 +35,6 @@ struct _GdkX11GLContextEGL
{
GdkX11GLContext parent_instance;
- EGLDisplay egl_display;
EGLConfig egl_config;
EGLContext egl_context;
};
@@ -99,17 +98,16 @@ drawable_info_free (gpointer data)
gpointer
gdk_x11_display_get_egl_display (GdkDisplay *display)
{
- EGLDisplay edpy = NULL;
+ GdkX11Display *self = GDK_X11_DISPLAY (display);
Display *dpy;
g_return_val_if_fail (GDK_IS_X11_DISPLAY (display), NULL);
- if (GDK_X11_DISPLAY (display)->have_glx)
+ if (!self->have_egl)
return NULL;
- edpy = g_object_get_data (G_OBJECT (display), "-gdk-x11-egl-display");
- if (edpy != NULL)
- return edpy;
+ if (self->egl_display)
+ return self->egl_display;
dpy = gdk_x11_display_get_xdisplay (display);
@@ -119,10 +117,10 @@ gdk_x11_display_get_egl_display (GdkDisplay *display)
(void *) eglGetProcAddress ("eglGetPlatformDisplay");
if (getPlatformDisplay != NULL)
- edpy = getPlatformDisplay (EGL_PLATFORM_X11_KHR, dpy, NULL);
+ self->egl_display = getPlatformDisplay (EGL_PLATFORM_X11_KHR, dpy, NULL);
- if (edpy != NULL)
- goto out;
+ if (self->egl_display != NULL)
+ return self->egl_display;
}
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
@@ -131,19 +129,15 @@ gdk_x11_display_get_egl_display (GdkDisplay *display)
(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
if (getPlatformDisplay)
- edpy = getPlatformDisplay (EGL_PLATFORM_X11_EXT, dpy, NULL);
+ self->egl_display = getPlatformDisplay (EGL_PLATFORM_X11_EXT, dpy, NULL);
- if (edpy != NULL)
- goto out;
+ if (self->egl_display != NULL)
+ return self->egl_display;
}
- edpy = eglGetDisplay ((EGLNativeDisplayType) dpy);
-
-out:
- if (edpy != NULL)
- g_object_set_data (G_OBJECT (display), "-gdk-x11-egl-display", edpy);
+ self->egl_display = eglGetDisplay ((EGLNativeDisplayType) dpy);
- return edpy;
+ return self->egl_display;
}
static XVisualInfo *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]