3 * Functions related to EGLDisplay.
9 #include "eglcontext.h"
10 #include "egldisplay.h"
11 #include "egldriver.h"
12 #include "eglglobals.h"
17 my_strdup(const char *s
)
21 char *s2
= malloc(l
+ 1);
31 * Allocate a new _EGLDisplay object for the given nativeDisplay handle.
32 * We'll also try to determine the device driver name at this time.
35 _eglNewDisplay(NativeDisplayType nativeDisplay
)
37 _EGLDisplay
*dpy
= (_EGLDisplay
*) calloc(1, sizeof(_EGLDisplay
));
39 EGLuint key
= _eglHashGenKey(_eglGlobal
.Displays
);
41 dpy
->Handle
= (EGLDisplay
) key
;
42 _eglHashInsert(_eglGlobal
.Displays
, key
, dpy
);
44 dpy
->NativeDisplay
= nativeDisplay
;
45 #if defined(_EGL_PLATFORM_X)
46 dpy
->Xdpy
= (Display
*) nativeDisplay
;
49 dpy
->DriverName
= my_strdup(_eglChooseDriver(dpy
));
50 if (!dpy
->DriverName
) {
60 * Return the public handle for an internal _EGLDisplay.
61 * This is the inverse of _eglLookupDisplay().
64 _eglGetDisplayHandle(_EGLDisplay
*display
)
67 return display
->Handle
;
69 return EGL_NO_DISPLAY
;
74 * Return the _EGLDisplay object that corresponds to the given public/
75 * opaque display handle.
76 * This is the inverse of _eglGetDisplayHandle().
79 _eglLookupDisplay(EGLDisplay dpy
)
81 EGLuint key
= (EGLuint
) dpy
;
82 _EGLDisplay
*d
= (_EGLDisplay
*) _eglHashLookup(_eglGlobal
.Displays
, key
);
88 _eglSaveDisplay(_EGLDisplay
*dpy
)
90 EGLuint key
= _eglHashGenKey(_eglGlobal
.Displays
);
93 dpy
->Handle
= (EGLDisplay
) key
;
95 _eglHashInsert(_eglGlobal
.Displays
, key
, dpy
);
100 _eglGetCurrentDisplay(void)
102 _EGLContext
*ctx
= _eglGetCurrentContext();
111 _eglCleanupDisplay(_EGLDisplay
*disp
)
115 free((void *) disp
->DriverName
);
116 /* driver deletes _EGLDisplay */