From 1ed1027e886980b9b0f48fa6bfcf3d6e209c7787 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 13:45:41 -0600 Subject: assorted changes to compile with new EGL 1.4 headers (untested) --- src/egl/main/eglsurface.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 874f318e96..cd5d9757f9 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -207,25 +207,27 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, void _eglSaveSurface(_EGLSurface *surf) { + EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); assert(surf); assert(!surf->Handle); - surf->Handle = _eglHashGenKey(_eglGlobal.Contexts); + surf->Handle = (EGLSurface) key; assert(surf->Handle); - _eglHashInsert(_eglGlobal.Surfaces, surf->Handle, surf); + _eglHashInsert(_eglGlobal.Surfaces, key, surf); } void _eglRemoveSurface(_EGLSurface *surf) { - _eglHashRemove(_eglGlobal.Surfaces, surf->Handle); + _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle); } _EGLSurface * _eglLookupSurface(EGLSurface surf) { - _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, surf); + _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, + (EGLuint) surf); return c; } @@ -439,7 +441,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) { _EGLSurface *surf = _eglLookupSurface(surface); if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, surface); + _eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surface); if (surf->IsBound) { surf->DeletePending = EGL_TRUE; } -- cgit v1.2.3 From 209a557574b9833da3d6ac299c83f4cddfff6910 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:17:40 -0600 Subject: fix typo: s/Contexts/Surfaces/ --- src/egl/main/eglsurface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index cd5d9757f9..134afa7cbd 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -207,7 +207,7 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, void _eglSaveSurface(_EGLSurface *surf) { - EGLuint key = _eglHashGenKey(_eglGlobal.Contexts); + EGLuint key = _eglHashGenKey(_eglGlobal.Surfaces); assert(surf); assert(!surf->Handle); surf->Handle = (EGLSurface) key; -- cgit v1.2.3 From 721ba15bf4596b2e9589e7656005b387724875c3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 May 2008 14:33:54 -0600 Subject: added _eglGet*Handle() functions These are the inverse of the _eglLookup*() functions. Returns the public handle for a private surface/config/display/etc. Removes glapi.c's direct access of private fields. --- src/egl/main/eglapi.c | 15 +++------------ src/egl/main/eglconfig.c | 12 ++++++++++++ src/egl/main/eglconfig.h | 4 ++++ src/egl/main/egldisplay.c | 15 +++++++++++++++ src/egl/main/egldisplay.h | 4 ++++ src/egl/main/eglsurface.c | 20 ++++++++++++++++++++ src/egl/main/eglsurface.h | 4 ++++ 7 files changed, 62 insertions(+), 12 deletions(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 4df31cc03f..e4eec26de0 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -53,10 +53,7 @@ eglGetDisplay(NativeDisplayType displayName) _EGLDisplay *dpy; _eglInitGlobals(); dpy = _eglNewDisplay(displayName); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; + return _eglGetDisplayHandle(dpy); } @@ -269,10 +266,7 @@ EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { _EGLDisplay *dpy = _eglGetCurrentDisplay(); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; + return _eglGetDisplayHandle(dpy); } @@ -288,10 +282,7 @@ EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { _EGLSurface *s = _eglGetCurrentSurface(readdraw); - if (s) - return s->Handle; - else - return EGL_NO_SURFACE; + return _eglGetSurfaceHandle(s); } diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index a74cd23113..1b49f7afd9 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -101,8 +101,20 @@ _eglInitConfig(_EGLConfig *config, EGLint id) } +/** + * Return the public handle for an internal _EGLConfig. + * This is the inverse of _eglLookupConfig(). + */ +EGLConfig +_eglGetConfigHandle(_EGLConfig *config) +{ + return config ? config->Handle : 0; +} + + /** * Given an EGLConfig handle, return the corresponding _EGLConfig object. + * This is the inverse of _eglGetConfigHandle(). */ _EGLConfig * _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h index 88e44dfc7d..4a80612980 100644 --- a/src/egl/main/eglconfig.h +++ b/src/egl/main/eglconfig.h @@ -27,6 +27,10 @@ extern void _eglInitConfig(_EGLConfig *config, EGLint id); +extern EGLConfig +_eglGetConfigHandle(_EGLConfig *config); + + extern _EGLConfig * _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config); diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 59d0bd3dc3..fd24f22273 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -39,9 +39,24 @@ _eglNewDisplay(NativeDisplayType displayName) } +/** + * 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) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 1a03fdd4ad..fe7b788455 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -24,6 +24,10 @@ extern _EGLDisplay * _eglNewDisplay(NativeDisplayType displayName); +EGLDisplay +_eglGetDisplayHandle(_EGLDisplay *display); + + extern _EGLDisplay * _eglLookupDisplay(EGLDisplay dpy); diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 134afa7cbd..1dbb12ecfe 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -223,6 +223,26 @@ _eglRemoveSurface(_EGLSurface *surf) } + +/** + * Return the public handle for an internal _EGLSurface. + * This is the inverse of _eglLookupSurface(). + */ +EGLSurface +_eglGetSurfaceHandle(_EGLSurface *surface) +{ + if (surface) + return surface->Handle; + else + return EGL_NO_SURFACE; +} + + +/** + * Return the private _EGLSurface which corresponds to a public EGLSurface + * handle. + * This is the inverse of _eglGetSurfaceHandle(). + */ _EGLSurface * _eglLookupSurface(EGLSurface surf) { diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index 79abeca0b2..df1e70122e 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -51,6 +51,10 @@ extern void _eglRemoveSurface(_EGLSurface *surf); +extern EGLSurface +_eglGetSurfaceHandle(_EGLSurface *surface); + + extern _EGLSurface * _eglLookupSurface(EGLSurface surf); -- cgit v1.2.3 From 274dd381a30072ecb8341cfc41e63bb6e39419ac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 May 2008 11:40:48 -0600 Subject: egl: fix width/height tests --- src/egl/main/eglsurface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 1dbb12ecfe..796d62f2b9 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -175,7 +175,7 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, } } - if (width <= 0 || height <= 0) { + if (width < 0 || height < 0) { _eglError(EGL_BAD_ATTRIBUTE, func); return EGL_FALSE; } -- cgit v1.2.3 From fbd6e86b8f3c9bdeae7581d8d852b4df66e4b42c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 20 Jun 2008 10:20:25 -0600 Subject: egl: implment EGL_LARGEST_PBUFFER query --- src/egl/main/egldriver.h | 2 ++ src/egl/main/eglsurface.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 7827ca3ae3..4066c6ec1d 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -39,6 +39,8 @@ struct _egl_driver _EGLAPI API; /**< EGL API dispatch table */ _EGLExtensions Extensions; + + int LargestPbuffer; }; diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 796d62f2b9..3777049ca6 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -8,6 +8,7 @@ #include #include "eglcontext.h" #include "eglconfig.h" +#include "egldriver.h" #include "eglglobals.h" #include "eglhash.h" #include "egllog.h" @@ -319,7 +320,9 @@ _eglQuerySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, case EGL_CONFIG_ID: *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); return EGL_TRUE; - /*XXX case EGL_LARGEST_PBUFFER:*/ + case EGL_LARGEST_PBUFFER: + *value = drv->LargestPbuffer; + return EGL_TRUE; case EGL_SURFACE_TYPE: *value = surface->Type; return EGL_TRUE; -- cgit v1.2.3 From b36f90657370296b45c27d33d60c89fa31dc1d76 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 1 Sep 2008 13:08:12 -0600 Subject: egl: additional error checking in _eglBind/ReleaseTexImage() --- src/egl/main/eglsurface.c | 75 +++++++++++++++++++++++++++++++++++++++-------- src/egl/main/eglsurface.h | 1 + 2 files changed, 64 insertions(+), 12 deletions(-) (limited to 'src/egl/main/eglsurface.c') diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 3777049ca6..6905acac50 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -61,6 +61,12 @@ _eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, return EGL_FALSE; } + if ((GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) & type) == 0) { + /* The config can't be used to create a surface of this type */ + _eglError(EGL_BAD_CONFIG, func); + return EGL_FALSE; + } + /* * Parse attribute list. Different kinds of surfaces support different * attributes. @@ -277,12 +283,7 @@ _eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) /* Basically just do error checking here. Drivers have to do the * actual buffer swap. */ - _EGLContext *context = _eglGetCurrentContext(); _EGLSurface *surface = _eglLookupSurface(draw); - if (context && context->DrawSurface != surface) { - _eglError(EGL_BAD_SURFACE, "eglSwapBuffers"); - return EGL_FALSE; - } if (surface == NULL) { _eglError(EGL_BAD_SURFACE, "eglSwapBuffers"); return EGL_FALSE; @@ -484,7 +485,8 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) * Default fallback routine - drivers might override this. */ EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attribute, EGLint value) +_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint attribute, EGLint value) { _EGLSurface *surface = _eglLookupSurface(surf); @@ -506,18 +508,67 @@ _eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attri EGLBoolean -_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) +_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint buffer) { - /* XXX unfinished */ - return EGL_FALSE; + /* Just do basic error checking and return success/fail. + * Drivers must implement the real stuff. + */ + _EGLSurface *surface = _eglLookupSurface(surf); + + if (!surface || surface->Type != EGL_PBUFFER_BIT) { + _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + return EGL_FALSE; + } + + if (surface->TextureFormat == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + + if (buffer != EGL_BACK_BUFFER) { + _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + return EGL_FALSE; + } + + surface->BoundToTexture = EGL_TRUE; + + return EGL_TRUE; } EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) +_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, + EGLint buffer) { - /* XXX unfinished */ - return EGL_FALSE; + /* Just do basic error checking and return success/fail. + * Drivers must implement the real stuff. + */ + _EGLSurface *surface = _eglLookupSurface(surf); + + if (!surface || surface->Type != EGL_PBUFFER_BIT) { + _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + return EGL_FALSE; + } + + if (surface->TextureFormat == EGL_NO_TEXTURE) { + _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + return EGL_FALSE; + } + + if (buffer != EGL_BACK_BUFFER) { + _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + return EGL_FALSE; + } + + if (!surface->BoundToTexture) { + _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + return EGL_FALSE; + } + + surface->BoundToTexture = EGL_FALSE; + + return EGL_TRUE; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index df1e70122e..50f965b5cb 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -16,6 +16,7 @@ struct _egl_surface /* May need reference counting here */ EGLBoolean IsBound; EGLBoolean DeletePending; + EGLBoolean BoundToTexture; EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ EGLint Width, Height; -- cgit v1.2.3