diff options
author | Brian Paul <[email protected]> | 2009-02-10 16:44:02 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-02-10 16:44:02 -0700 |
commit | 5340b6dff73a0a23531ce2a5f28fba8303adab6e (patch) | |
tree | b141fc3648568dd8b941c966059e6ed32a8bd0ad /src/egl/main/egldisplay.c | |
parent | 9fd26daec24f21dbe17afcb2e2ab272667ee9a69 (diff) | |
parent | ee4c921b65fb76998711f3c40330505cbc49a0e0 (diff) |
Merge commit 'origin/gallium-master-merge'
This is the big merge of the gallium-0.2 branch into master.
gallium-master-merge was just the staging area for it.
Both gallium-0.2 and gallium-master-merge are considered closed now.
Conflicts:
progs/demos/Makefile
src/mesa/main/state.c
src/mesa/main/texenvprogram.c
Diffstat (limited to 'src/egl/main/egldisplay.c')
-rw-r--r-- | src/egl/main/egldisplay.c | 102 |
1 files changed, 76 insertions, 26 deletions
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 074a85bf26b..47a2323eafb 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -1,52 +1,88 @@ + +/** + * Functions related to EGLDisplay. + */ + +#include <assert.h> #include <stdlib.h> #include <string.h> #include "eglcontext.h" #include "egldisplay.h" +#include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" - - -static char * -my_strdup(const char *s) -{ - int l = strlen(s); - char *s2 = malloc(l + 1); - strcpy(s2, s); - return s2; -} +#include "eglstring.h" /** - * We're assuming that the NativeDisplayType parameter is actually - * a string. - * Return a new _EGLDisplay object for the given displayName + * Allocate a new _EGLDisplay object for the given nativeDisplay handle. + * We'll also try to determine the device driver name at this time. + * + * Note that nativeDisplay may be an X Display ptr, or a string. */ _EGLDisplay * -_eglNewDisplay(NativeDisplayType displayName) +_eglNewDisplay(NativeDisplayType nativeDisplay) { _EGLDisplay *dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { - dpy->Handle = _eglHashGenKey(_eglGlobal.Displays); - _eglHashInsert(_eglGlobal.Displays, dpy->Handle, dpy); - if (displayName) - dpy->Name = my_strdup(displayName); - else - dpy->Name = NULL; - dpy->Driver = NULL; /* this gets set later */ + EGLuint key = _eglHashGenKey(_eglGlobal.Displays); + + dpy->Handle = (EGLDisplay) key; + _eglHashInsert(_eglGlobal.Displays, key, dpy); + + dpy->NativeDisplay = nativeDisplay; +#if defined(_EGL_PLATFORM_X) + dpy->Xdpy = (Display *) nativeDisplay; +#endif + + dpy->DriverName = _eglChooseDriver(dpy); + if (!dpy->DriverName) { + free(dpy); + return NULL; + } } return dpy; } /** + * Return the public handle for an internal _EGLDisplay. + * This is the inverse of _eglLookupDisplay(). + */ +EGLDisplay +_eglGetDisplayHandle(_EGLDisplay *display) +{ + if (display) + return display->Handle; + else + return EGL_NO_DISPLAY; +} + + +/** * Return the _EGLDisplay object that corresponds to the given public/ * opaque display handle. + * This is the inverse of _eglGetDisplayHandle(). */ _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy) { - _EGLDisplay *d = (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, dpy); - return d; + EGLuint key = (EGLuint) dpy; + if (!_eglGlobal.Displays) + return NULL; + return (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key); +} + + +void +_eglSaveDisplay(_EGLDisplay *dpy) +{ + EGLuint key = _eglHashGenKey(_eglGlobal.Displays); + assert(dpy); + assert(!dpy->Handle); + dpy->Handle = (EGLDisplay) key; + assert(dpy->Handle); + _eglHashInsert(_eglGlobal.Displays, key, dpy); } @@ -61,11 +97,25 @@ _eglGetCurrentDisplay(void) } +/** + * Free all the data hanging of an _EGLDisplay object, but not + * the object itself. + */ void _eglCleanupDisplay(_EGLDisplay *disp) { - /* XXX incomplete */ + EGLint i; + + for (i = 0; i < disp->NumConfigs; i++) { + free(disp->Configs[i]); + } free(disp->Configs); - free(disp->Name); - /* driver deletes _EGLDisplay */ + disp->Configs = NULL; + + /* XXX incomplete */ + + free((void *) disp->DriverName); + disp->DriverName = NULL; + + /* driver deletes the _EGLDisplay object */ } |