Commit 82196a20 by Nicolas Capens

When X11 is unavailable, default to a headless display.

Bug 20104157 Change-Id: Idc6cbadc69921b3fa5c299ffe8ad4d2442d0478f Reviewed-on: https://swiftshader-review.googlesource.com/2901Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent f1f00304
#define MAJOR_VERSION 3
#define MINOR_VERSION 2
#define BUILD_VERSION 8
#define BUILD_REVISION 47658
#define BUILD_VERSION 9
#define BUILD_REVISION 47659
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -31,6 +31,11 @@ LibX11exports::LibX11exports(void *libX11, void *libXext)
LibX11exports *LibX11::operator->()
{
return loadExports();
}
LibX11exports *LibX11::loadExports()
{
static void *libX11 = nullptr;
static void *libXext = nullptr;
static LibX11exports *libX11exports = nullptr;
......@@ -38,8 +43,12 @@ LibX11exports *LibX11::operator->()
if(!libX11)
{
libX11 = loadLibrary("libX11.so");
libXext = loadLibrary("libXext.so");
libX11exports = new LibX11exports(libX11, libXext);
if(libX11)
{
libXext = loadLibrary("libXext.so");
libX11exports = new LibX11exports(libX11, libXext);
}
}
return libX11exports;
......
......@@ -38,7 +38,15 @@ struct LibX11exports
class LibX11
{
public:
operator bool()
{
return loadExports();
}
LibX11exports *operator->();
private:
LibX11exports *loadExports();
};
extern LibX11 libX11;
......
......@@ -44,7 +44,14 @@ egl::Display *Display::getPlatformDisplay(EGLenum platform, EGLNativeDisplayType
if(platform == EGL_UNKNOWN) // Default
{
#if defined(__unix__)
platform = EGL_PLATFORM_X11_EXT;
if(libX11)
{
platform = EGL_PLATFORM_X11_EXT;
}
else
{
platform = EGL_PLATFORM_GBM_KHR;
}
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment