diff --git a/tests/dummy/EGL_dummy.c b/tests/dummy/EGL_dummy.c index 501fae4..602fe20 100644 --- a/tests/dummy/EGL_dummy.c +++ b/tests/dummy/EGL_dummy.c @@ -38,6 +38,7 @@ enum DI_eglTestDispatchDisplay, DI_eglTestDispatchDevice, DI_eglTestDispatchCurrent, + DI_eglTestReturnDevice, DI_COUNT, }; @@ -82,6 +83,11 @@ static EGLint failNextMakeCurrentError = EGL_NONE; static EGLDEBUGPROCKHR debugCallbackFunc = NULL; static EGLBoolean debugCallbackEnabled = EGL_TRUE; +// The EGLDeviceEXT handle values have to be pointers, so just use the +// address of an array element for each EGLDeviceEXT handle. +static const char EGL_DEVICE_HANDLES[DUMMY_EGL_MAX_DEVICE_COUNT]; +static EGLint deviceCount = DUMMY_EGL_DEVICE_COUNT; + static DummyThreadState *GetThreadState(void) { DummyThreadState *thr = (DummyThreadState *) @@ -144,18 +150,14 @@ static DummyEGLDisplay *LookupEGLDisplay(EGLDisplay dpy) static EGLDeviceEXT GetEGLDevice(EGLint index) { - // The EGLDeviceEXT handle values have to be pointers, so just use the - // address of an array element for each EGLDeviceEXT handle. - static const char EGL_DEVICE_HANDLES[DUMMY_EGL_DEVICE_COUNT]; - - assert(index >= 0 && index < DUMMY_EGL_DEVICE_COUNT); + assert(index >= 0 && index < DUMMY_EGL_MAX_DEVICE_COUNT); return (EGLDeviceEXT) (EGL_DEVICE_HANDLES + index); } static EGLBoolean IsEGLDeviceValid(EGLDeviceEXT dev) { int i; - for (i=0; i= 0 && index < deviceCount); + return GetEGLDevice(index); +} + static void *dispatch_eglTestDispatchDisplay(EGLDisplay dpy, EGLint command, EGLAttrib param); static void *dispatch_eglTestDispatchDevice(EGLDeviceEXT dpy, EGLint command, EGLAttrib param); static void *dispatch_eglTestDispatchCurrent(EGLint command, EGLAttrib param); +static EGLDeviceEXT dispatch_eglTestReturnDevice(EGLDisplay dpy, EGLint index); static struct { const char *name; @@ -626,6 +635,7 @@ static struct { PROC_ENTRY(eglTestDispatchDisplay), PROC_ENTRY(eglTestDispatchDevice), PROC_ENTRY(eglTestDispatchCurrent), + PROC_ENTRY(eglTestReturnDevice), #undef PROC_ENTRY }; @@ -697,6 +707,24 @@ static void *dispatch_eglTestDispatchCurrent(EGLint command, EGLAttrib param) } } +static EGLDeviceEXT dispatch_eglTestReturnDevice(EGLDisplay dpy, EGLint index) +{ + __EGLvendorInfo *vendor; + pfn_eglTestReturnDevice func; + EGLDeviceEXT ret; + + apiExports->threadInit(); + vendor = apiExports->getVendorFromDisplay(dpy); + func = (pfn_eglTestReturnDevice) FetchVendorFunc(vendor, DI_eglTestReturnDevice, EGL_BAD_DISPLAY); + if (func != NULL) { + ret = func(dpy, index); + } else { + ret = NULL; + } + apiExports->setVendorForDevice(ret, vendor); + return ret; +} + static const struct { const char *name; @@ -791,6 +819,12 @@ static EGLBoolean dummyGetSupportsAPI(EGLenum api) } } +PUBLIC void DummySetDeviceCount(EGLint count) +{ + assert(count >= 0 && count <= DUMMY_EGL_MAX_DEVICE_COUNT); + deviceCount = count; +} + PUBLIC EGLBoolean __egl_Main(uint32_t version, const __EGLapiExports *exports, __EGLvendorInfo *vendor, __EGLapiImports *imports) diff --git a/tests/dummy/EGL_dummy.h b/tests/dummy/EGL_dummy.h index 59a74f3..e478ef3 100644 --- a/tests/dummy/EGL_dummy.h +++ b/tests/dummy/EGL_dummy.h @@ -56,11 +56,20 @@ #define DUMMY_VENDOR_NAME_1 "dummy1" /** - * The number of devices that each dummy vendor library exposes. This is used - * to figure out which vendor library should be behind each device. + * The number of devices that each dummy vendor library exposes by default. + * This is used to figure out which vendor library should be behind each + * device. */ #define DUMMY_EGL_DEVICE_COUNT 2 +/** + * The maximum number of devices that each dummy vendor library can expose. + * + * This is used to test adding a device after the initial eglQueryDevicesEXT + * call. + */ +#define DUMMY_EGL_MAX_DEVICE_COUNT 3 + /** * A platform enum to select a vendor library by name. * The native display should be a pointer to a string with the vendor name. @@ -111,4 +120,19 @@ typedef void * (* pfn_eglTestDispatchDevice) (EGLDeviceEXT dev, EGLint command, */ typedef void * (* pfn_eglTestDispatchCurrent) (EGLint command, EGLAttrib param); +/** + * Returns an EGLDeviceEXT handle from the vendor library. + * + * This is used to test returning a device that wasn't listed in a call to + * eglQueryDevicesEXT. + */ +typedef EGLDeviceEXT (* pfn_eglTestReturnDevice) (EGLDisplay dpy, EGLint index); + +/** + * Changes the number of EGLDeviceEXT handles that the dummy library exposes. + * + * This function has to be looked up using dlsym, not eglGetProcAddress. + */ +typedef void (* pfn_DummySetDeviceCount) (EGLint count); + #endif // EGL_DUMMY_H