3 * Functions related to EGLDisplay.
9 #include "eglcontext.h"
10 #include "egldisplay.h"
11 #include "egldriver.h"
12 #include "eglglobals.h"
14 #include "eglstring.h"
18 * Allocate a new _EGLDisplay object for the given nativeDisplay handle.
19 * We'll also try to determine the device driver name at this time.
21 * Note that nativeDisplay may be an X Display ptr, or a string.
24 _eglNewDisplay(NativeDisplayType nativeDisplay
)
26 _EGLDisplay
*dpy
= (_EGLDisplay
*) calloc(1, sizeof(_EGLDisplay
));
28 EGLuint key
= _eglHashGenKey(_eglGlobal
.Displays
);
30 dpy
->Handle
= (EGLDisplay
) key
;
31 _eglHashInsert(_eglGlobal
.Displays
, key
, dpy
);
33 dpy
->NativeDisplay
= nativeDisplay
;
34 #if defined(_EGL_PLATFORM_X)
35 dpy
->Xdpy
= (Display
*) nativeDisplay
;
38 dpy
->DriverName
= _eglChooseDriver(dpy
);
39 if (!dpy
->DriverName
) {
49 * Return the public handle for an internal _EGLDisplay.
50 * This is the inverse of _eglLookupDisplay().
53 _eglGetDisplayHandle(_EGLDisplay
*display
)
56 return display
->Handle
;
58 return EGL_NO_DISPLAY
;
63 * Return the _EGLDisplay object that corresponds to the given public/
64 * opaque display handle.
65 * This is the inverse of _eglGetDisplayHandle().
68 _eglLookupDisplay(EGLDisplay dpy
)
70 EGLuint key
= (EGLuint
) dpy
;
71 if (!_eglGlobal
.Displays
)
73 return (_EGLDisplay
*) _eglHashLookup(_eglGlobal
.Displays
, key
);
78 _eglSaveDisplay(_EGLDisplay
*dpy
)
80 EGLuint key
= _eglHashGenKey(_eglGlobal
.Displays
);
83 dpy
->Handle
= (EGLDisplay
) key
;
85 _eglHashInsert(_eglGlobal
.Displays
, key
, dpy
);
90 _eglGetCurrentDisplay(void)
92 _EGLContext
*ctx
= _eglGetCurrentContext();
101 * Free all the data hanging of an _EGLDisplay object, but not
105 _eglCleanupDisplay(_EGLDisplay
*disp
)
109 for (i
= 0; i
< disp
->NumConfigs
; i
++) {
110 free(disp
->Configs
[i
]);
113 disp
->Configs
= NULL
;
117 free((void *) disp
->DriverName
);
118 disp
->DriverName
= NULL
;
120 /* driver deletes the _EGLDisplay object */