From 7ce481bf6996b2d99314311bf68afc6bd703c480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 4 Aug 2021 09:59:50 +0200 Subject: [PATCH] egl: Add eglQueryDisplayAttribEXT() helper To be used to fetch the EGLDevice used for an EGL display. Part-of: --- src/backends/meta-egl.c | 23 +++++++++++++++++++++++ src/backends/meta-egl.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/src/backends/meta-egl.c b/src/backends/meta-egl.c index ab9913524..0563b55b5 100644 --- a/src/backends/meta-egl.c +++ b/src/backends/meta-egl.c @@ -72,6 +72,8 @@ struct _MetaEgl PFNEGLQUERYDMABUFFORMATSEXTPROC eglQueryDmaBufFormatsEXT; PFNEGLQUERYDMABUFMODIFIERSEXTPROC eglQueryDmaBufModifiersEXT; + + PFNEGLQUERYDISPLAYATTRIBEXTPROC eglQueryDisplayAttribEXT; }; G_DEFINE_TYPE (MetaEgl, meta_egl, G_TYPE_OBJECT) @@ -1097,6 +1099,25 @@ meta_egl_query_dma_buf_modifiers (MetaEgl *egl, return TRUE; } +gboolean +meta_egl_query_display_attrib (MetaEgl *egl, + EGLDisplay display, + EGLint attribute, + EGLAttrib *value, + GError **error) +{ + if (!is_egl_proc_valid (egl->eglQueryDisplayAttribEXT, error)) + return FALSE; + + if (!egl->eglQueryDisplayAttribEXT (display, attribute, value)) + { + set_egl_error (error); + return FALSE; + } + + return TRUE; +} + #define GET_EGL_PROC_ADDR(proc) \ egl->proc = (void *) eglGetProcAddress (#proc); @@ -1136,6 +1157,8 @@ meta_egl_constructed (GObject *object) GET_EGL_PROC_ADDR (eglQueryDmaBufFormatsEXT); GET_EGL_PROC_ADDR (eglQueryDmaBufModifiersEXT); + + GET_EGL_PROC_ADDR (eglQueryDisplayAttribEXT); } #undef GET_EGL_PROC_ADDR diff --git a/src/backends/meta-egl.h b/src/backends/meta-egl.h index e108e714a..83405b46a 100644 --- a/src/backends/meta-egl.h +++ b/src/backends/meta-egl.h @@ -269,4 +269,10 @@ gboolean meta_egl_query_dma_buf_modifiers (MetaEgl *egl, EGLint *num_formats, GError **error); +gboolean meta_egl_query_display_attrib (MetaEgl *egl, + EGLDisplay display, + EGLint attribute, + EGLAttrib *value, + GError **error); + #endif /* META_EGL_H */