summaryrefslogtreecommitdiffstats
path: root/src/egl/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-12-10 17:54:00 +0000
committerBrian Paul <[email protected]>2005-12-10 17:54:00 +0000
commit48822796339cb4a55714dc3f1abbe379562ec538 (patch)
tree83a6ab54af6a26242b0176f82d67c7c0e66ff776 /src/egl/main
parentb04dd5c58763039a564c50b5e3c0bbc9755e7f72 (diff)
Some initial per-thread support.
Rename eglShowSurfaceMESA to eglShowScreenSurfaceMESA.
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglapi.c11
-rw-r--r--src/egl/main/eglapi.h4
-rw-r--r--src/egl/main/eglcontext.c7
-rw-r--r--src/egl/main/egldriver.c2
-rw-r--r--src/egl/main/eglglobals.c24
-rw-r--r--src/egl/main/eglglobals.h23
-rw-r--r--src/egl/main/eglsurface.c2
-rw-r--r--src/egl/main/egltypedefs.h2
8 files changed, 53 insertions, 22 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index a31b252311c..f898ba59fbe 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -300,8 +300,9 @@ eglGetCurrentSurface(EGLint readdraw)
EGLint APIENTRY
eglGetError(void)
{
- EGLint e = _eglGlobal.LastError;
- _eglGlobal.LastError = EGL_SUCCESS;
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+ EGLint e = t->LastError;
+ t->LastError = EGL_SUCCESS;
return e;
}
@@ -351,7 +352,7 @@ void (* APIENTRY eglGetProcAddress(const char *procname))()
{ "eglCopyContextMESA", (_EGLProc) eglCopyContextMESA },
{ "eglGetScreensMESA", (_EGLProc) eglGetScreensMESA },
{ "eglCreateScreenSurfaceMESA", (_EGLProc) eglCreateScreenSurfaceMESA },
- { "eglShowSurfaceMESA", (_EGLProc) eglShowSurfaceMESA },
+ { "eglShowScreenSurfaceMESA", (_EGLProc) eglShowScreenSurfaceMESA },
{ "eglScreenPositionMESA", (_EGLProc) eglScreenPositionMESA },
{ "eglQueryScreenMESA", (_EGLProc) eglQueryScreenMESA },
{ "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA },
@@ -444,10 +445,10 @@ eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attri
EGLBoolean
-eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode)
+eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode)
{
_EGLDriver *drv = _eglLookupDriver(dpy);
- return drv->API.ShowSurfaceMESA(drv, dpy, screen, surface, mode);
+ return drv->API.ShowScreenSurfaceMESA(drv, dpy, screen, surface, mode);
}
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index dad653af97e..f11080be1c0 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -47,7 +47,7 @@ typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLMo
typedef EGLBoolean (*CopyContextMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
typedef EGLBoolean (*GetScreensMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
typedef EGLSurface (*CreateScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-typedef EGLBoolean (*ShowSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA mode);
+typedef EGLBoolean (*ShowScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA mode);
typedef EGLBoolean (*ScreenPositionMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
typedef EGLBoolean (*QueryScreenMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
@@ -95,7 +95,7 @@ struct _egl_api
CopyContextMESA_t CopyContextMESA;
GetScreensMESA_t GetScreensMESA;
CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA;
- ShowSurfaceMESA_t ShowSurfaceMESA;
+ ShowScreenSurfaceMESA_t ShowScreenSurfaceMESA;
ScreenPositionMESA_t ScreenPositionMESA;
QueryScreenMESA_t QueryScreenMESA;
QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index b760ebcb40a..07b63e9b112 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -87,8 +87,8 @@ _eglLookupContext(EGLContext ctx)
_EGLContext *
_eglGetCurrentContext(void)
{
- /* XXX this should be per-thread someday */
- return _eglGlobal.CurrentContext;
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+ return t->CurrentContext;
}
@@ -176,6 +176,7 @@ EGLBoolean
_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
EGLSurface r, EGLContext context)
{
+ _EGLThreadInfo *t = _eglGetCurrentThread();
_EGLContext *ctx = _eglLookupContext(context);
_EGLSurface *draw = _eglLookupSurface(d);
_EGLSurface *read = _eglLookupSurface(r);
@@ -250,7 +251,7 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
read->IsBound = EGL_TRUE;
}
- _eglGlobal.CurrentContext = ctx;
+ t->CurrentContext = ctx;
return EGL_TRUE;
}
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 2b9034dbcfb..fd7e00778e1 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -187,7 +187,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
drv->API.GetModeAttribMESA = _eglGetModeAttribMESA;
drv->API.GetScreensMESA = _eglGetScreensMESA;
drv->API.CreateScreenSurfaceMESA = _eglCreateScreenSurfaceMESA;
- drv->API.ShowSurfaceMESA = _eglShowSurfaceMESA;
+ drv->API.ShowScreenSurfaceMESA = _eglShowScreenSurfaceMESA;
drv->API.ScreenPositionMESA = _eglScreenPositionMESA;
drv->API.QueryScreenMESA = _eglQueryScreenMESA;
drv->API.QueryScreenSurfaceMESA = _eglQueryScreenSurfaceMESA;
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index a1b10c7a12f..a17968e7ff2 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -2,7 +2,7 @@
#include "eglglobals.h"
-struct _egl_global _eglGlobal = { EGL_FALSE };
+struct _egl_global _eglGlobal = { .Initialized = EGL_FALSE };
/**
@@ -17,9 +17,10 @@ _eglInitGlobals(void)
_eglGlobal.Contexts = _eglNewHashTable();
_eglGlobal.Surfaces = _eglNewHashTable();
_eglGlobal.FreeScreenHandle = 1;
- _eglGlobal.CurrentContext = EGL_NO_CONTEXT;
- _eglGlobal.LastError = EGL_SUCCESS;
_eglGlobal.Initialized = EGL_TRUE;
+ /* XXX temporary */
+ _eglGlobal.ThreadInfo.CurrentContext = EGL_NO_CONTEXT;
+ _eglGlobal.ThreadInfo.LastError = EGL_SUCCESS;
}
}
@@ -37,6 +38,18 @@ _eglDestroyGlobals(void)
}
+/**
+ * Return pointer to calling thread's _EGLThreadInfo object.
+ * Create a new one if needed.
+ * Should never return NULL.
+ */
+_EGLThreadInfo *
+_eglGetCurrentThread(void)
+{
+ /* XXX temporary */
+ return &_eglGlobal.ThreadInfo;
+}
+
/**
* Record EGL error code.
@@ -44,10 +57,11 @@ _eglDestroyGlobals(void)
void
_eglError(EGLint errCode, const char *msg)
{
+ _EGLThreadInfo *t = _eglGetCurrentThread();
const char *s;
- if (_eglGlobal.LastError == EGL_SUCCESS) {
- _eglGlobal.LastError = errCode;
+ if (t->LastError == EGL_SUCCESS) {
+ t->LastError = errCode;
switch (errCode) {
case EGL_BAD_ACCESS:
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index 1a6f12d174e..44b4626c583 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -5,6 +5,19 @@
#include "eglhash.h"
+/**
+ * Per-thread info
+ */
+struct _egl_thread_info
+{
+ EGLint LastError;
+ _EGLContext *CurrentContext;
+};
+
+
+/**
+ * Global library data
+ */
struct _egl_global
{
EGLBoolean Initialized;
@@ -15,10 +28,8 @@ struct _egl_global
EGLScreenMESA FreeScreenHandle;
- EGLint LastError;
-
- /* XXX this should be per-thread someday */
- _EGLContext *CurrentContext;
+ /* XXX temporary */
+ _EGLThreadInfo ThreadInfo;
};
@@ -33,6 +44,10 @@ extern void
_eglDestroyGlobals(void);
+extern _EGLThreadInfo *
+_eglGetCurrentThread(void);
+
+
extern void
_eglError(EGLint errCode, const char *msg);
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 82f47f116b6..4606168cf32 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -1,7 +1,5 @@
/**
* Surface-related functions.
- *
- * See the eglcontext.c file for comments that also apply here.
*/
diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h
index d963ba50e50..fa8cb496f8d 100644
--- a/src/egl/main/egltypedefs.h
+++ b/src/egl/main/egltypedefs.h
@@ -23,6 +23,8 @@ typedef struct _egl_screen _EGLScreen;
typedef struct _egl_surface _EGLSurface;
+typedef struct _egl_thread_info _EGLThreadInfo;
+
typedef void (*_EGLProc)();