Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Do not include egl.h in public headers #38
In file included from /usr/include/X11/Xlib.h:44, from /usr/include/EGL/eglplatform.h:124, from /usr/include/EGL/egl.h:39, from /home/cgarcia/gnome/include/wpe-fdo-1.0/wpe/initialize-egl.h:37, from /home/cgarcia/gnome/include/wpe-fdo-1.0/wpe/fdo-egl.h:36, from ../../Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp:41, from DerivedSources/WebKit/unified-sources/UnifiedSource-88d1702b-25.cpp:1:
If I am understanding correctly, the “problem” here seems to be that the X11 headers get included. That looks to me as a problem in the EGL headers themselves, or something else (maybe the
I think that the solution suggested in the patch is wrong: code should not make guessed about which one is the actual type of
To give you an example: while
No, that's a common problem with egl. eglplatform.h depends on macros previously defined to decide the native types, and by default X11 is used when non of the conditions are true. We have the same policy in WebKit to not include egl in headers, for the same reason. It's only included in cpp files and defining GBM as a hack, just to ensure that pointer types are used. To ensure wayland is used, we would need to define WL_EGL_PLATFORM in the public header. That could work in this particular case, but it could be problematic, because it's a public header and it's not needed, because we don't really need anything defined in eglplatform.h.
My build failure is only because this header is included in another header defining an enum with 'None' item, and None is defined by XLib.
eglplatform.h defines EGLNativeDisplayType not EGLDisplay. EGLDisplay is defined in egl.h and it's always void* in all platforms AFAIK.
Again, I think you mean EGLNativeDisplayType, we have always forward declared EGLDisplay as void* in WebKit without any issues.
I have been checking around for this a bit. The sanctioned way to ensure that the EGL definitions are correct for usage with Wayland is doing the following:
#include <wayland-egl.h> /* Always BEFORE */ #include <egl.h>
This will handle defining whatever is needed to ensure that only the Wayland headers needed by EGL are included (it does internally some switcheroo with
With the approach suggested above, X11 headers will not be included implicitly.
Right, I mixed
Well, that would be because by chance it just happens to be that all the EGL drivers we have targeted so far use some kind of pointer
Yes, that's what we should do, but not in headers and even less in public ones. That would be a problem for WebKit. In WebKitGTK we build with support for both wayland and X11 at the same time. If this header is included in a shared header X11 will not work anymore. That's why we have separate cpp files for X11 and Wayland and we only include egl there.
Yes, even when desired.
EGLDisplay is not platform specific AFAIK, that's why it's defined in egl.h, not in eglplatform.h.
I don't think it's by chance, it's because EGLDisplay is not platform specific.