Module: Mesa
Branch: main
Commit: 208894c94f92b3d837bc57fff7002635cc2230cf
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=208894c94f92b3d837bc57fff7002635cc2230cf

Author: Robert Foss <rf...@kernel.org>
Date:   Thu Dec  7 15:52:20 2023 +0100

egl: Add _eglHasAttrib() function

Provide a simple function for checking if an EGLDisplay
is using a specific EGLAttrib.

This can be useful when trying to inhibit platform behavior
depending on the EGLAttribs provided.

Signed-off-by: Robert Foss <rf...@kernel.org>
Reviewed-by: Adam Jackson <a...@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26131>

---

 src/egl/main/egldisplay.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index ea75cd33d95..330eb198ecb 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -257,6 +257,23 @@ _eglGetDisplayHandle(_EGLDisplay *disp)
    return (EGLDisplay)((disp) ? disp : EGL_NO_DISPLAY);
 }
 
+static inline EGLBoolean
+_eglHasAttrib(_EGLDisplay *disp, EGLAttrib attrib)
+{
+   EGLAttrib *attribs = disp->Options.Attribs;
+
+   if (!attribs) {
+      return EGL_FALSE;
+   }
+
+   for (int i = 0; attribs[i] != EGL_NONE; i += 2) {
+      if (attrib == attribs[i]) {
+         return EGL_TRUE;
+      }
+   }
+   return EGL_FALSE;
+}
+
 extern void
 _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *disp);
 

Reply via email to