EGL: Allow vendor libraries to identify platforms for eglGetDisplay. (#124)

EGL: Allow vendor libraries to identify platforms for eglGetDisplay.

Add a new optional function __EGLapiImports::findNativeDisplayPlatform. Vendor
libraries can provide that function to identify the platform for the native
display passed to eglGetDisplay.

Reviewed-by: Emil Velikov emil.velikov@collabora.com
This commit is contained in:
Kyle Brenneman 2017-06-20 12:50:40 -06:00 committed by GitHub
parent 7751d668e5
commit 71226b013c
2 changed files with 36 additions and 2 deletions

View file

@ -86,7 +86,7 @@ extern "C" {
* will still work.
*/
#define EGL_VENDOR_ABI_MAJOR_VERSION ((uint32_t) 0)
#define EGL_VENDOR_ABI_MINOR_VERSION ((uint32_t) 0)
#define EGL_VENDOR_ABI_MINOR_VERSION ((uint32_t) 1)
#define EGL_VENDOR_ABI_VERSION ((EGL_VENDOR_ABI_MAJOR_VERSION << 16) | EGL_VENDOR_ABI_MINOR_VERSION)
static inline uint32_t EGL_VENDOR_ABI_GET_MAJOR_VERSION(uint32_t version)
{
@ -388,6 +388,30 @@ typedef struct __EGLapiImportsRec {
*/
void (*patchThreadAttach)(void);
/*!
* (OPTIONAL) Tries to determine the platform type for a native display.
*
* If the vendor library provides this function, then libglvnd will call it
* to determine which platform to use for a native display handle in
* eglGetDisplay.
*
* If no vendor library identifies the platform, then libglvnd will fall
* back to its own platform detection logic.
*
* Libglvnd can call this function for any native display handle except
* \c EGL_DEFAULT_DISPLAY.
*
* No matter what the value of \p native_display, the vendor library must
* not crash, and must not return a false match. If the vendor library
* can't identify the display, then it must return \c EGL_NONE.
*
* In particular, that means that a vendor library must not return any sort
* of default or fallback platform.
*
* \param native_display The native display handle passed to eglGetDisplay.
* \return Either a platform type enum or EGL_NONE.
*/
EGLenum (* findNativeDisplayPlatform) (void *native_display);
} __EGLapiImports;
/*****************************************************************************/

View file

@ -212,7 +212,17 @@ static EGLenum GuessPlatformType(EGLNativeDisplayType display_id)
struct glvnd_list *vendorList = __eglLoadVendors();
__EGLvendorInfo *vendor;
// First, see if this is a valid EGLDisplayEXT handle.
// First, see if any of the vendor libraries can identify the display.
glvnd_list_for_each_entry(vendor, vendorList, entry) {
if (vendor->eglvc.findNativeDisplayPlatform != NULL) {
EGLenum platform = vendor->eglvc.findNativeDisplayPlatform((void *) display_id);
if (platform != EGL_NONE) {
return platform;
}
}
}
// Next, see if this is a valid EGLDisplayEXT handle.
if (__eglGetVendorFromDevice((EGLDeviceEXT) display_id)) {
return EGL_PLATFORM_DEVICE_EXT;
}