diff options
author | Chia-I Wu <olv@lunarg.com> | 2010-07-31 00:00:49 +0800 |
---|---|---|
committer | Chia-I Wu <olv@lunarg.com> | 2010-07-31 17:49:32 +0800 |
commit | 6c7e0b95a4a16d268aa3ca74c5c8407779533314 (patch) | |
tree | 533bf5ee540c5bc55518d39c424db8f0ed28a0a4 /src/egl/main | |
parent | 3cc471e429675e82fcc37c6efa2c5e880d811b84 (diff) |
egl: Add checks for EGL_MESA_screen_surface.
This allows Mesa EGL to be compiled with eglext.h that does not define
EGL_MESA_screen_surface.
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/eglconfig.c | 2 | ||||
-rw-r--r-- | src/egl/main/eglcurrent.c | 3 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 1 | ||||
-rw-r--r-- | src/egl/main/eglglobals.c | 1 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 2 | ||||
-rw-r--r-- | src/egl/main/eglmode.c | 6 | ||||
-rw-r--r-- | src/egl/main/eglmode.h | 6 | ||||
-rw-r--r-- | src/egl/main/eglscreen.c | 19 | ||||
-rw-r--r-- | src/egl/main/eglscreen.h | 6 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 66 |
10 files changed, 91 insertions, 21 deletions
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index a9af320097..ea8e47d02b 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -314,8 +314,10 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) EGL_VG_ALPHA_FORMAT_PRE_BIT | EGL_MULTISAMPLE_RESOLVE_BOX_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; +#ifdef EGL_MESA_screen_surface if (conf->Display->Extensions.MESA_screen_surface) mask |= EGL_SCREEN_BIT_MESA; +#endif break; case EGL_RENDERABLE_TYPE: case EGL_CONFORMANT: diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index c697bf796d..a207159cd8 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -1,6 +1,5 @@ #include <stdlib.h> #include <string.h> -#include "eglglobals.h" #include "egllog.h" #include "eglmutex.h" #include "eglcurrent.h" @@ -300,12 +299,14 @@ _eglError(EGLint errCode, const char *msg) case EGL_BAD_SURFACE: s = "EGL_BAD_SURFACE"; break; +#ifdef EGL_MESA_screen_surface case EGL_BAD_SCREEN_MESA: s = "EGL_BAD_SCREEN_MESA"; break; case EGL_BAD_MODE_MESA: s = "EGL_BAD_MODE_MESA"; break; +#endif default: s = "other"; } diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 1e3d7d24aa..8fc9e792b0 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -14,7 +14,6 @@ #include "egldefines.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" #include "egllog.h" #include "eglmisc.h" #include "eglmode.h" diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 725a25eca6..52eebb07f6 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -11,7 +11,6 @@ struct _egl_global _eglGlobal = { &_eglGlobalMutex, /* Mutex */ NULL, /* DisplayList */ - 1, /* FreeScreenHandle */ 2, /* NumAtExitCalls */ { /* default AtExitCalls, called in reverse order */ diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index e8bf5416e2..c3771a8ef1 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -16,8 +16,6 @@ struct _egl_global /* the list of all displays */ _EGLDisplay *DisplayList; - EGLScreenMESA FreeScreenHandle; - EGLint NumAtExitCalls; void (*AtExitCalls[10])(void); }; diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 859e9318b4..37594cdb42 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -10,6 +10,9 @@ #include "eglstring.h" +#ifdef EGL_MESA_screen_surface + + #define MIN2(A, B) (((A) < (B)) ? (A) : (B)) @@ -353,3 +356,6 @@ _eglQueryModeStringMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *m) { return m->Name; } + + +#endif /* EGL_MESA_screen_surface */ diff --git a/src/egl/main/eglmode.h b/src/egl/main/eglmode.h index a089a5e194..9167cbc4b9 100644 --- a/src/egl/main/eglmode.h +++ b/src/egl/main/eglmode.h @@ -4,6 +4,9 @@ #include "egltypedefs.h" +#ifdef EGL_MESA_screen_surface + + #define EGL_NO_MODE_MESA 0 @@ -54,4 +57,7 @@ extern const char * _eglQueryModeStringMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *m); +#endif /* EGL_MESA_screen_surface */ + + #endif /* EGLMODE_INCLUDED */ diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 8f96fd935c..8b8966f3ff 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -16,7 +16,6 @@ #include <string.h> #include "egldisplay.h" -#include "eglglobals.h" #include "eglcurrent.h" #include "eglmode.h" #include "eglconfig.h" @@ -25,6 +24,14 @@ #include "eglmutex.h" +#ifdef EGL_MESA_screen_surface + + +/* ugh, no atomic op? */ +static _EGL_DECLARE_MUTEX(_eglNextScreenHandleMutex); +static EGLScreenMESA _eglNextScreenHandle = 1; + + /** * Return a new screen handle/ID. * NOTE: we never reuse these! @@ -33,10 +40,10 @@ static EGLScreenMESA _eglAllocScreenHandle(void) { EGLScreenMESA s; - - _eglLockMutex(_eglGlobal.Mutex); - s = _eglGlobal.FreeScreenHandle++; - _eglUnlockMutex(_eglGlobal.Mutex); + + _eglLockMutex(&_eglNextScreenHandleMutex); + s = _eglNextScreenHandle++; + _eglUnlockMutex(&_eglNextScreenHandleMutex); return s; } @@ -263,3 +270,5 @@ _eglDestroyScreen(_EGLScreen *scrn) free(scrn); } + +#endif /* EGL_MESA_screen_surface */ diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h index 0fd71f71fc..3db20478ad 100644 --- a/src/egl/main/eglscreen.h +++ b/src/egl/main/eglscreen.h @@ -5,6 +5,9 @@ #include "egltypedefs.h" +#ifdef EGL_MESA_screen_surface + + /** * Per-screen information. * Note that an EGL screen doesn't have a size. A screen may be set to @@ -86,4 +89,7 @@ PUBLIC void _eglDestroyScreen(_EGLScreen *scrn); +#endif /* EGL_MESA_screen_surface */ + + #endif /* EGLSCREEN_INCLUDED */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index d46bdb0672..52f5c240c6 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -30,6 +30,50 @@ _eglClampSwapInterval(_EGLSurface *surf, EGLint interval) } +#ifdef EGL_MESA_screen_surface +static EGLint +_eglParseScreenSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) +{ + EGLint i, err = EGL_SUCCESS; + + if (!attrib_list) + return EGL_SUCCESS; + + for (i = 0; attrib_list[i] != EGL_NONE; i++) { + EGLint attr = attrib_list[i++]; + EGLint val = attrib_list[i]; + + switch (attr) { + case EGL_WIDTH: + if (val < 0) { + err = EGL_BAD_PARAMETER; + break; + } + surf->Width = val; + break; + case EGL_HEIGHT: + if (val < 0) { + err = EGL_BAD_PARAMETER; + break; + } + surf->Height = val; + break; + default: + err = EGL_BAD_ATTRIBUTE; + break; + } + + if (err != EGL_SUCCESS) { + _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr); + break; + } + } + + return err; +} +#endif /* EGL_MESA_screen_surface */ + + /** * Parse the list of surface attributes and return the proper error code. */ @@ -44,6 +88,11 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) if (!attrib_list) return EGL_SUCCESS; +#ifdef EGL_MESA_screen_surface + if (type == EGL_SCREEN_BIT_MESA) + return _eglParseScreenSurfaceAttribList(surf, attrib_list); +#endif + if (dpy->Extensions.NOK_texture_from_pixmap) texture_type |= EGL_PIXMAP_BIT; @@ -52,12 +101,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) EGLint val = attrib_list[i]; switch (attr) { - /* common (except for screen surfaces) attributes */ + /* common attributes */ case EGL_VG_COLORSPACE: - if (type == EGL_SCREEN_BIT_MESA) { - err = EGL_BAD_ATTRIBUTE; - break; - } switch (val) { case EGL_VG_COLORSPACE_sRGB: case EGL_VG_COLORSPACE_LINEAR: @@ -71,10 +116,6 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->VGColorspace = val; break; case EGL_VG_ALPHA_FORMAT: - if (type == EGL_SCREEN_BIT_MESA) { - err = EGL_BAD_ATTRIBUTE; - break; - } switch (val) { case EGL_VG_ALPHA_FORMAT_NONPRE: case EGL_VG_ALPHA_FORMAT_PRE: @@ -101,7 +142,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) break; /* pbuffer surface attributes */ case EGL_WIDTH: - if (type != EGL_PBUFFER_BIT && type != EGL_SCREEN_BIT_MESA) { + if (type != EGL_PBUFFER_BIT) { err = EGL_BAD_ATTRIBUTE; break; } @@ -112,7 +153,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) surf->Width = val; break; case EGL_HEIGHT: - if (type != EGL_PBUFFER_BIT && type != EGL_SCREEN_BIT_MESA) { + if (type != EGL_PBUFFER_BIT) { err = EGL_BAD_ATTRIBUTE; break; } @@ -129,6 +170,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) } surf->LargestPbuffer = !!val; break; + /* for eglBindTexImage */ case EGL_TEXTURE_FORMAT: if (!(type & texture_type)) { err = EGL_BAD_ATTRIBUTE; @@ -210,10 +252,12 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, case EGL_PBUFFER_BIT: func = "eglCreatePBufferSurface"; break; +#ifdef EGL_MESA_screen_surface case EGL_SCREEN_BIT_MESA: func = "eglCreateScreenSurface"; renderBuffer = EGL_SINGLE_BUFFER; /* XXX correct? */ break; +#endif default: _eglLog(_EGL_WARNING, "Bad type in _eglInitSurface"); return EGL_FALSE; |