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 <rfoss@kernel.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26131>
This commit is contained in:
Robert Foss
2023-12-07 15:52:20 +01:00
committed by Marge Bot
parent cda9980f96
commit 208894c94f
+17
View File
@@ -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);