Mesa (master): egl: Return the same EGL Display for the same native display .
Brian Paul
brianp at kemper.freedesktop.org
Fri Jul 17 17:57:22 UTC 2009
Module: Mesa
Branch: master
Commit: be9d1ab171b1b29108c781af84dd500707a12925
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be9d1ab171b1b29108c781af84dd500707a12925
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Thu Jul 16 21:21:56 2009 -0700
egl: Return the same EGL Display for the same native display.
The latest revision of the spec explicitly requires the same handle to
be returned for the same native display.
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
---
src/egl/main/eglapi.c | 9 ++++++---
src/egl/main/egldisplay.c | 24 ++++++++++++++++++++++++
src/egl/main/egldisplay.h | 4 ++++
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index eaee9fa..f0a6f7f 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -51,9 +51,12 @@ eglGetDisplay(NativeDisplayType nativeDisplay)
{
_EGLDisplay *dpy;
_eglInitGlobals();
- dpy = _eglNewDisplay(nativeDisplay);
- if (dpy)
- _eglLinkDisplay(dpy);
+ dpy = _eglFindDisplay(nativeDisplay);
+ if (!dpy) {
+ dpy = _eglNewDisplay(nativeDisplay);
+ if (dpy)
+ _eglLinkDisplay(dpy);
+ }
return _eglGetDisplayHandle(dpy);
}
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index a30e810..1f1f41e 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -97,6 +97,30 @@ _eglLookupDisplay(EGLDisplay dpy)
/**
+ * Find the display corresponding to the specified native display id in all
+ * linked displays.
+ */
+_EGLDisplay *
+_eglFindDisplay(NativeDisplayType nativeDisplay)
+{
+ EGLuint key = _eglHashFirstEntry(_eglGlobal.Displays);
+
+ /* Walk the hash table. Should switch to list if it is a problem. */
+ while (key) {
+ _EGLDisplay *dpy = (_EGLDisplay *)
+ _eglHashLookup(_eglGlobal.Displays, key);
+ assert(dpy);
+
+ if (dpy->NativeDisplay == nativeDisplay)
+ return dpy;
+ key = _eglHashNextEntry(_eglGlobal.Displays, key);
+ }
+
+ return NULL;
+}
+
+
+/**
* Free all the data hanging of an _EGLDisplay object, but not
* the object itself.
*/
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index ac285f5..0a6003f 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -52,6 +52,10 @@ extern _EGLDisplay *
_eglLookupDisplay(EGLDisplay dpy);
+extern _EGLDisplay *
+_eglFindDisplay(NativeDisplayType nativeDisplay);
+
+
extern void
_eglCleanupDisplay(_EGLDisplay *disp);
More information about the mesa-commit
mailing list