[gtk/wip/otte/gl-hdr: 2/7] egl: Move extension checks to GdkDisplay
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/gl-hdr: 2/7] egl: Move extension checks to GdkDisplay
- Date: Tue, 5 Oct 2021 23:49:46 +0000 (UTC)
commit a04b8fb68c8e74a80cd910d7ad1d87adb0227669
Author: Benjamin Otte <otte redhat com>
Date: Wed Oct 6 00:48:33 2021 +0200
egl: Move extension checks to GdkDisplay
We check the same extensions anyway, so no need to duplicate the code.
gdk/gdkdisplay.c | 6 +++++-
gdk/gdkdisplayprivate.h | 6 +++++-
gdk/wayland/gdkdisplay-wayland.h | 5 -----
gdk/wayland/gdkglcontext-wayland.c | 15 ++-------------
gdk/x11/gdkdisplay-x11.c | 5 -----
gdk/x11/gdkdisplay-x11.h | 4 ----
gdk/x11/gdkglcontext-egl.c | 6 ++----
7 files changed, 14 insertions(+), 33 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 398e191a12..c3aed432a1 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1694,6 +1694,11 @@ gdk_display_init_egl (GdkDisplay *self,
return FALSE;
}
+ self->have_egl_buffer_age =
+ epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_buffer_age");
+ self->have_egl_swap_buffers_with_damage =
+ epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_swap_buffers_with_damage");
+
GDK_DISPLAY_NOTE (self, OPENGL, {
char *ext = describe_extensions (priv->egl_display);
char *cfg = describe_egl_config (priv->egl_display, priv->egl_config);
@@ -1713,7 +1718,6 @@ gdk_display_init_egl (GdkDisplay *self,
g_free (ext);
});
-
gdk_profiler_end_mark (start_time, "init EGL", NULL);
return TRUE;
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index dd0b1359b2..8c92f42679 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -92,6 +92,8 @@ struct _GdkDisplay
guint double_click_time; /* Maximum time between clicks in msecs */
guint double_click_distance; /* Maximum distance between clicks in pixels */
+ GList *seats;
+
#ifdef GDK_RENDERING_VULKAN
VkInstance vk_instance;
VkDebugReportCallbackEXT vk_debug_callback;
@@ -103,7 +105,9 @@ struct _GdkDisplay
guint vulkan_refcount;
#endif /* GDK_RENDERING_VULKAN */
- GList *seats;
+ /* egl info */
+ guint have_egl_buffer_age : 1;
+ guint have_egl_swap_buffers_with_damage : 1;
};
struct _GdkDisplayClass
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index 265bcd1883..e4924fb6f9 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -149,11 +149,6 @@ struct _GdkWaylandDisplay
GListStore *monitors;
gint64 last_bell_time_ms;
-
- /* egl info */
-
- guint have_egl_buffer_age : 1;
- guint have_egl_swap_buffers_with_damage : 1;
};
struct _GdkWaylandDisplayClass
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 3eafebe1b4..896bcc6d5b 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -208,12 +208,11 @@ static cairo_region_t *
gdk_wayland_gl_context_get_damage (GdkGLContext *context)
{
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
- GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLSurface egl_surface;
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
int buffer_age = 0;
- if (display_wayland->have_egl_buffer_age)
+ if (display->have_egl_buffer_age)
{
egl_surface = gdk_surface_get_egl_surface (surface);
gdk_gl_context_make_current (context);
@@ -298,7 +297,6 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkSurface *surface = gdk_gl_context_get_surface (context);
GdkDisplay *display = gdk_surface_get_display (surface);
- GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLSurface egl_surface;
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
@@ -310,7 +308,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_request_frame (surface);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "swap buffers");
- if (display_wayland->have_egl_swap_buffers_with_damage)
+ if (display->have_egl_swap_buffers_with_damage)
{
EGLint stack_rects[4 * 4]; /* 4 rects */
EGLint *heap_rects = NULL;
@@ -391,7 +389,6 @@ gdk_wayland_display_init_gl (GdkDisplay *display,
GError **error)
{
GdkWaylandDisplay *self = GDK_WAYLAND_DISPLAY (display);
- EGLDisplay egl_display;
if (!gdk_display_init_egl (display,
EGL_PLATFORM_WAYLAND_EXT,
@@ -408,14 +405,6 @@ gdk_wayland_display_init_gl (GdkDisplay *display,
return NULL;
}
- egl_display = gdk_display_get_egl_display (display);
-
- self->have_egl_buffer_age =
- epoxy_has_egl_extension (egl_display, "EGL_EXT_buffer_age");
-
- self->have_egl_swap_buffers_with_damage =
- epoxy_has_egl_extension (egl_display, "EGL_EXT_swap_buffers_with_damage");
-
return g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
"display", display,
NULL);
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 499bbd86f3..84a45dc814 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -2995,11 +2995,6 @@ gdk_x11_display_init_gl_backend (GdkX11Display *self,
self->egl_version = epoxy_egl_version (egl_display);
- self->has_egl_buffer_age =
- epoxy_has_egl_extension (egl_display, "EGL_EXT_buffer_age");
- self->has_egl_swap_buffers_with_damage =
- epoxy_has_egl_extension (egl_display, "EGL_EXT_swap_buffers_with_damage");
-
return TRUE;
}
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index 6ebca4bd29..654a708231 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -155,10 +155,6 @@ struct _GdkX11Display
guint has_glx_visual_rating : 1;
guint has_glx_create_es2_context : 1;
guint has_async_glx_swap_buffers : 1;
-
- /* EGL extensions we check */
- guint has_egl_buffer_age : 1;
- guint has_egl_swap_buffers_with_damage : 1;
};
struct _GdkX11DisplayClass
diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c
index 12ad03502e..1c83e50850 100644
--- a/gdk/x11/gdkglcontext-egl.c
+++ b/gdk/x11/gdkglcontext-egl.c
@@ -78,7 +78,6 @@ gdk_x11_gl_context_egl_end_frame (GdkDrawContext *draw_context,
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkSurface *surface = gdk_gl_context_get_surface (context);
GdkDisplay *display = gdk_surface_get_display (surface);
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
EGLSurface egl_surface;
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->end_frame (draw_context, painted);
@@ -88,7 +87,7 @@ gdk_x11_gl_context_egl_end_frame (GdkDrawContext *draw_context,
egl_surface = gdk_surface_get_egl_surface (surface);
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "x11", "swap buffers");
- if (display_x11->has_egl_swap_buffers_with_damage)
+ if (display->have_egl_swap_buffers_with_damage)
{
int i, j, n_rects = cairo_region_num_rectangles (painted);
int surface_height = gdk_surface_get_height (surface);
@@ -187,9 +186,8 @@ static cairo_region_t *
gdk_x11_gl_context_egl_get_damage (GdkGLContext *context)
{
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- if (display_x11->has_egl_buffer_age)
+ if (display->have_egl_buffer_age)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
EGLSurface egl_surface;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]