diff options
author | David Nusinow <[email protected]> | 2006-10-14 22:42:57 +0000 |
---|---|---|
committer | David Nusinow <[email protected]> | 2006-10-14 22:42:57 +0000 |
commit | 75733e42375e74d990afd2432e3072bc1586305b (patch) | |
tree | 794bc9de497c0befbe4b9b664e7a9fd7c3d6b416 /src/egl/main | |
parent | bc8084da742c20531bb2f935afad522e22381832 (diff) |
Commit diff of 6.5.1-0.2 so we've got a record of it here.mesa-6.5.1-0.2
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/Makefile | 66 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 586 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 119 | ||||
-rw-r--r-- | src/egl/main/eglconfig.c | 638 | ||||
-rw-r--r-- | src/egl/main/eglconfig.h | 67 | ||||
-rw-r--r-- | src/egl/main/eglcontext.c | 276 | ||||
-rw-r--r-- | src/egl/main/eglcontext.h | 71 | ||||
-rw-r--r-- | src/egl/main/egldisplay.c | 71 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 44 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 272 | ||||
-rw-r--r-- | src/egl/main/egldriver.h | 81 | ||||
-rw-r--r-- | src/egl/main/eglglobals.c | 148 | ||||
-rw-r--r-- | src/egl/main/eglglobals.h | 68 | ||||
-rw-r--r-- | src/egl/main/eglhash.c | 347 | ||||
-rw-r--r-- | src/egl/main/eglhash.h | 39 | ||||
-rw-r--r-- | src/egl/main/egllog.c | 57 | ||||
-rw-r--r-- | src/egl/main/egllog.h | 16 | ||||
-rw-r--r-- | src/egl/main/eglmode.c | 431 | ||||
-rw-r--r-- | src/egl/main/eglmode.h | 54 | ||||
-rw-r--r-- | src/egl/main/eglscreen.c | 328 | ||||
-rw-r--r-- | src/egl/main/eglscreen.h | 90 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 530 | ||||
-rw-r--r-- | src/egl/main/eglsurface.h | 117 | ||||
-rw-r--r-- | src/egl/main/egltypedefs.h | 34 |
24 files changed, 0 insertions, 4550 deletions
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile deleted file mode 100644 index 45a4fb39b8b..00000000000 --- a/src/egl/main/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -# src/egl/main/Makefile - -TOP = ../../.. -include $(TOP)/configs/current - - -INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi - -HEADERS = \ - eglconfig.h \ - eglcontext.h \ - egldisplay.h \ - egldriver.h \ - eglglobals.h \ - egllog.h \ - eglhash.h \ - eglmode.h \ - eglscreen.h \ - eglsurface.h - -SOURCES = \ - eglapi.c \ - eglconfig.c \ - eglcontext.c \ - egldisplay.c \ - egldriver.c \ - eglglobals.c \ - egllog.c \ - eglhash.c \ - eglmode.c \ - eglscreen.c \ - eglsurface.c - -OBJECTS = $(SOURCES:.c=.o) - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - - - -default: depend library - - -# EGL Library -library: $(LIB_DIR)/libEGL.so - -$(LIB_DIR)/libEGL.so: $(OBJECTS) - $(TOP)/bin/mklib -o EGL -major 1 -minor 0 \ - -install $(LIB_DIR) -ldl $(OBJECTS) - - - -clean: - rm -f *.o *.so* - rm -f core.* - - -depend: $(SOURCES) $(HEADERS) - @ echo "running $(MKDEP)" - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) > /dev/null - -include depend -# DO NOT DELETE diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c deleted file mode 100644 index bfa580e6c3f..00000000000 --- a/src/egl/main/eglapi.c +++ /dev/null @@ -1,586 +0,0 @@ -/** - * Public EGL API entrypoints - * - * Generally, we use the EGLDisplay parameter as a key to lookup the - * appropriate device driver handle, then jump though the driver's - * dispatch table to handle the function. - * - * That allows us the option of supporting multiple, simultaneous, - * heterogeneous hardware devices in the future. - * - * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are - * opaque handles implemented with 32-bit unsigned integers. - * It's up to the driver function or fallback function to look up the - * handle and get an object. - * By using opaque handles, we leave open the possibility of having - * indirect rendering in the future, like GLX. - * - * - * Notes on naming conventions: - * - * eglFooBar - public EGL function - * EGL_FOO_BAR - public EGL token - * EGLDatatype - public EGL datatype - * - * _eglFooBar - private EGL function - * _EGLDatatype - private EGL datatype, typedef'd struct - * _egl_struct - private EGL struct, non-typedef'd - * - */ - - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "eglcontext.h" -#include "egldisplay.h" -#include "egltypedefs.h" -#include "eglglobals.h" -#include "egldriver.h" -#include "eglsurface.h" - - - -/** - * NOTE: displayName is treated as a string in _eglChooseDriver()!!! - * This will probably change! - * See _eglChooseDriver() for details! - */ -EGLDisplay APIENTRY -eglGetDisplay(NativeDisplayType displayName) -{ - _EGLDisplay *dpy; - _eglInitGlobals(); - dpy = _eglNewDisplay(displayName); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; -} - - -EGLBoolean APIENTRY -eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) -{ - if (dpy) { - _EGLDriver *drv = _eglChooseDriver(dpy); - if (drv) - return drv->API.Initialize(drv, dpy, major, minor); - } - return EGL_FALSE; -} - - -EGLBoolean APIENTRY -eglTerminate(EGLDisplay dpy) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return _eglCloseDriver(drv, dpy); - else - return EGL_FALSE; -} - - -const char * APIENTRY -eglQueryString(EGLDisplay dpy, EGLint name) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.QueryString(drv, dpy, name); - else - return NULL; -} - - -EGLBoolean APIENTRY -eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - /* XXX check drv for null in remaining functions */ - return drv->API.GetConfigs(drv, dpy, configs, config_size, num_config); -} - - -EGLBoolean APIENTRY -eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.ChooseConfig(drv, dpy, attrib_list, configs, config_size, num_config); -} - - -EGLBoolean APIENTRY -eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.GetConfigAttrib(drv, dpy, config, attribute, value); -} - - -EGLContext APIENTRY -eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreateContext(drv, dpy, config, share_list, attrib_list); -} - - -EGLBoolean APIENTRY -eglDestroyContext(EGLDisplay dpy, EGLContext ctx) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.DestroyContext(drv, dpy, ctx); -} - - -EGLBoolean APIENTRY -eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.MakeCurrent(drv, dpy, draw, read, ctx); -} - - -EGLBoolean APIENTRY -eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QueryContext(drv, dpy, ctx, attribute, value); -} - - -EGLSurface APIENTRY -eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreateWindowSurface(drv, dpy, config, window, attrib_list); -} - - -EGLSurface APIENTRY -eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreatePixmapSurface(drv, dpy, config, pixmap, attrib_list); -} - - -EGLSurface APIENTRY -eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreatePbufferSurface(drv, dpy, config, attrib_list); -} - - -EGLBoolean APIENTRY -eglDestroySurface(EGLDisplay dpy, EGLSurface surface) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.DestroySurface(drv, dpy, surface); -} - - -EGLBoolean APIENTRY -eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QuerySurface(drv, dpy, surface, attribute, value); -} - - -EGLBoolean APIENTRY -eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.SurfaceAttrib(drv, dpy, surface, attribute, value); -} - - -EGLBoolean APIENTRY -eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.BindTexImage(drv, dpy, surface, buffer); -} - - -EGLBoolean APIENTRY -eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.ReleaseTexImage(drv, dpy, surface, buffer); -} - - -EGLBoolean APIENTRY -eglSwapInterval(EGLDisplay dpy, EGLint interval) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.SwapInterval(drv, dpy, interval); -} - - -EGLBoolean APIENTRY -eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.SwapBuffers(drv, dpy, draw); -} - - -EGLBoolean APIENTRY -eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CopyBuffers(drv, dpy, surface, target); -} - - -EGLBoolean APIENTRY -eglWaitGL(void) -{ - EGLDisplay dpy = eglGetCurrentDisplay(); - if (dpy != EGL_NO_DISPLAY) { - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.WaitGL(drv, dpy); - } - else - return EGL_FALSE; -} - - -EGLBoolean APIENTRY -eglWaitNative(EGLint engine) -{ - EGLDisplay dpy = eglGetCurrentDisplay(); - if (dpy != EGL_NO_DISPLAY) { - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.WaitNative(drv, dpy, engine); - } - else - return EGL_FALSE; -} - - -EGLDisplay APIENTRY -eglGetCurrentDisplay(void) -{ - _EGLDisplay *dpy = _eglGetCurrentDisplay(); - if (dpy) - return dpy->Handle; - else - return EGL_NO_DISPLAY; -} - - -EGLContext APIENTRY -eglGetCurrentContext(void) -{ - _EGLContext *ctx = _eglGetCurrentContext(); - if (ctx) - return ctx->Handle; - else - return EGL_NO_CONTEXT; -} - - -EGLSurface APIENTRY -eglGetCurrentSurface(EGLint readdraw) -{ - _EGLSurface *s = _eglGetCurrentSurface(readdraw); - if (s) - return s->Handle; - else - return EGL_NO_SURFACE; -} - - -EGLint APIENTRY -eglGetError(void) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - EGLint e = t->LastError; - t->LastError = EGL_SUCCESS; - return e; -} - - -void (* APIENTRY eglGetProcAddress(const char *procname))() -{ - typedef void (*genericFunc)(); - struct name_function { - const char *name; - _EGLProc function; - }; - static struct name_function egl_functions[] = { - /* alphabetical order */ - { "eglBindTexImage", (_EGLProc) eglBindTexImage }, - { "eglChooseConfig", (_EGLProc) eglChooseConfig }, - { "eglCopyBuffers", (_EGLProc) eglCopyBuffers }, - { "eglCreateContext", (_EGLProc) eglCreateContext }, - { "eglCreatePbufferSurface", (_EGLProc) eglCreatePbufferSurface }, - { "eglCreatePixmapSurface", (_EGLProc) eglCreatePixmapSurface }, - { "eglCreateWindowSurface", (_EGLProc) eglCreateWindowSurface }, - { "eglDestroyContext", (_EGLProc) eglDestroyContext }, - { "eglDestroySurface", (_EGLProc) eglDestroySurface }, - { "eglGetConfigAttrib", (_EGLProc) eglGetConfigAttrib }, - { "eglGetConfigs", (_EGLProc) eglGetConfigs }, - { "eglGetCurrentContext", (_EGLProc) eglGetCurrentContext }, - { "eglGetCurrentDisplay", (_EGLProc) eglGetCurrentDisplay }, - { "eglGetCurrentSurface", (_EGLProc) eglGetCurrentSurface }, - { "eglGetDisplay", (_EGLProc) eglGetDisplay }, - { "eglGetError", (_EGLProc) eglGetError }, - { "eglGetProcAddress", (_EGLProc) eglGetProcAddress }, - { "eglInitialize", (_EGLProc) eglInitialize }, - { "eglMakeCurrent", (_EGLProc) eglMakeCurrent }, - { "eglQueryContext", (_EGLProc) eglQueryContext }, - { "eglQueryString", (_EGLProc) eglQueryString }, - { "eglQuerySurface", (_EGLProc) eglQuerySurface }, - { "eglReleaseTexImage", (_EGLProc) eglReleaseTexImage }, - { "eglSurfaceAttrib", (_EGLProc) eglSurfaceAttrib }, - { "eglSwapBuffers", (_EGLProc) eglSwapBuffers }, - { "eglSwapInterval", (_EGLProc) eglSwapInterval }, - { "eglTerminate", (_EGLProc) eglTerminate }, - { "eglWaitGL", (_EGLProc) eglWaitGL }, - { "eglWaitNative", (_EGLProc) eglWaitNative }, - /* Extensions */ -#ifdef EGL_MESA_screen_surface - { "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA }, - { "eglGetModesMESA", (_EGLProc) eglGetModesMESA }, - { "eglGetModeAttribMESA", (_EGLProc) eglGetModeAttribMESA }, - { "eglCopyContextMESA", (_EGLProc) eglCopyContextMESA }, - { "eglGetScreensMESA", (_EGLProc) eglGetScreensMESA }, - { "eglCreateScreenSurfaceMESA", (_EGLProc) eglCreateScreenSurfaceMESA }, - { "eglShowScreenSurfaceMESA", (_EGLProc) eglShowScreenSurfaceMESA }, - { "eglScreenPositionMESA", (_EGLProc) eglScreenPositionMESA }, - { "eglQueryScreenMESA", (_EGLProc) eglQueryScreenMESA }, - { "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA }, - { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA }, - { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA }, -#endif /* EGL_MESA_screen_surface */ -#ifdef EGL_VERSION_1_2 - { "eglBindAPI", (_EGLProc) eglBindAPI }, - { "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer }, - { "eglQueryAPI", (_EGLProc) eglQueryAPI }, - { "eglReleaseThread", (_EGLProc) eglReleaseThread }, - { "eglWaitClient", (_EGLProc) eglWaitClient }, -#endif /* EGL_VERSION_1_2 */ - { NULL, NULL } - }; - EGLint i; - for (i = 0; egl_functions[i].name; i++) { - if (strcmp(egl_functions[i].name, procname) == 0) { - return (genericFunc) egl_functions[i].function; - } - } -#if 0 - /* XXX enable this code someday */ - return (genericFunc) _glapi_get_proc_address(procname); -#else - return NULL; -#endif -} - - -/* - * EGL_MESA_screen extension - */ - -EGLBoolean APIENTRY -eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, - const EGLint *attrib_list, EGLModeMESA *modes, - EGLint modes_size, EGLint *num_modes) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.ChooseModeMESA(drv, dpy, screen, attrib_list, modes, modes_size, num_modes); - else - return EGL_FALSE; -} - - -EGLBoolean APIENTRY -eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.GetModesMESA(drv, dpy, screen, modes, mode_size, num_mode); - else - return EGL_FALSE; -} - - -EGLBoolean APIENTRY -eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.GetModeAttribMESA(drv, dpy, mode, attribute, value); - else - return EGL_FALSE; -} - - -EGLBoolean APIENTRY -eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.CopyContextMESA(drv, dpy, source, dest, mask); - else - return EGL_FALSE; -} - - -EGLBoolean -eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - if (drv) - return drv->API.GetScreensMESA(drv, dpy, screens, max_screens, num_screens); - else - return EGL_FALSE; -} - - -EGLSurface -eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreateScreenSurfaceMESA(drv, dpy, config, attrib_list); -} - - -EGLBoolean -eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.ShowScreenSurfaceMESA(drv, dpy, screen, surface, mode); -} - - -EGLBoolean -eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.ScreenPositionMESA(drv, dpy, screen, x, y); -} - - -EGLBoolean -eglQueryScreenMESA( EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QueryScreenMESA(drv, dpy, screen, attribute, value); -} - - -EGLBoolean -eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QueryScreenSurfaceMESA(drv, dpy, screen, surface); -} - - -EGLBoolean -eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QueryScreenModeMESA(drv, dpy, screen, mode); -} - - -const char * -eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.QueryModeStringMESA(drv, dpy, mode); -} - - -/** - ** EGL 1.2 - **/ - -#ifdef EGL_VERSION_1_2 - -EGLBoolean -eglBindAPI(EGLenum api) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - - switch (api) { - case EGL_OPENGL_ES_API: - if (_eglGlobal.OpenGLESAPISupported) { - t->CurrentAPI = api; - return EGL_TRUE; - } - _eglError(EGL_BAD_PARAMETER, "eglBindAPI"); - return EGL_FALSE; - case EGL_OPENVG_API: - if (_eglGlobal.OpenVGAPISupported) { - t->CurrentAPI = api; - return EGL_TRUE; - } - _eglError(EGL_BAD_PARAMETER, "eglBindAPI"); - return EGL_FALSE; - default: - return EGL_FALSE; - } - return EGL_TRUE; -} - - -EGLSurface -eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, - EGLClientBuffer buffer, EGLConfig config, - const EGLint *attrib_list) -{ - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.CreatePbufferFromClientBuffer(drv, dpy, buftype, buffer, - config, attrib_list); -} - - -EGLenum -eglQueryAPI(void) -{ - /* returns one of EGL_OPENGL_ES_API or EGL_OPENVG_API */ - _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentAPI; -} - - -EGLBoolean -eglReleaseThread(void) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - EGLDisplay dpy = eglGetCurrentDisplay(); - if (dpy) { - _EGLDriver *drv = _eglLookupDriver(dpy); - /* unbind context */ - (void) drv->API.MakeCurrent(drv, dpy, EGL_NO_SURFACE, - EGL_NO_SURFACE, EGL_NO_CONTEXT); - } - _eglDeleteThreadData(t); - return EGL_TRUE; -} - - -EGLBoolean -eglWaitClient(void) -{ - EGLDisplay dpy = eglGetCurrentDisplay(); - if (dpy != EGL_NO_DISPLAY) { - _EGLDriver *drv = _eglLookupDriver(dpy); - return drv->API.WaitClient(drv, dpy); - } - else - return EGL_FALSE; -} - -#endif /* EGL_VERSION_1_2 */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h deleted file mode 100644 index 555aa5dd9ef..00000000000 --- a/src/egl/main/eglapi.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef EGLAPI_INCLUDED -#define EGLAPI_INCLUDED - -/** - * Typedefs for all EGL API entrypoint functions. - */ - - -/* driver funcs */ -typedef EGLBoolean (*Initialize_t)(_EGLDriver *, EGLDisplay dpy, EGLint *major, EGLint *minor); -typedef EGLBoolean (*Terminate_t)(_EGLDriver *, EGLDisplay dpy); - -/* config funcs */ -typedef EGLBoolean (*GetConfigs_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); -typedef EGLBoolean (*ChooseConfig_t)(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); -typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); - -/* context funcs */ -typedef EGLContext (*CreateContext_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list); -typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx); -typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); -typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); - -/* surface funcs */ -typedef EGLSurface (*CreateWindowSurface_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list); -typedef EGLSurface (*CreatePixmapSurface_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list); -typedef EGLSurface (*CreatePbufferSurface_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); -typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface); -typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); -typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); -typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer); -typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer); -typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint interval); -typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw); -typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, NativePixmapType target); - -/* misc funcs */ -typedef const char *(*QueryString_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint name); -typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, EGLDisplay dpy); -typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint engine); - - -#ifdef EGL_MESA_screen_surface -typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes); -typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode); -typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value); -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 (*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); -typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode); -typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode); -#endif /* EGL_MESA_screen_surface */ - - -#ifdef EGL_VERSION_1_2 -typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, EGLDisplay dpy); -typedef EGLSurface (*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); -#endif /* EGL_VERSION_1_2 */ - - - -/** - * The API dispatcher jumps through these functions - */ -struct _egl_api -{ - Initialize_t Initialize; - Terminate_t Terminate; - - GetConfigs_t GetConfigs; - ChooseConfig_t ChooseConfig; - GetConfigAttrib_t GetConfigAttrib; - - CreateContext_t CreateContext; - DestroyContext_t DestroyContext; - MakeCurrent_t MakeCurrent; - QueryContext_t QueryContext; - - CreateWindowSurface_t CreateWindowSurface; - CreatePixmapSurface_t CreatePixmapSurface; - CreatePbufferSurface_t CreatePbufferSurface; - DestroySurface_t DestroySurface; - QuerySurface_t QuerySurface; - SurfaceAttrib_t SurfaceAttrib; - BindTexImage_t BindTexImage; - ReleaseTexImage_t ReleaseTexImage; - SwapInterval_t SwapInterval; - SwapBuffers_t SwapBuffers; - CopyBuffers_t CopyBuffers; - - QueryString_t QueryString; - WaitGL_t WaitGL; - WaitNative_t WaitNative; - - /* EGL_MESA_screen extension */ - ChooseModeMESA_t ChooseModeMESA; - GetModesMESA_t GetModesMESA; - GetModeAttribMESA_t GetModeAttribMESA; - CopyContextMESA_t CopyContextMESA; - GetScreensMESA_t GetScreensMESA; - CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA; - ShowScreenSurfaceMESA_t ShowScreenSurfaceMESA; - ScreenPositionMESA_t ScreenPositionMESA; - QueryScreenMESA_t QueryScreenMESA; - QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA; - QueryScreenModeMESA_t QueryScreenModeMESA; - QueryModeStringMESA_t QueryModeStringMESA; - -#ifdef EGL_VERSION_1_2 - WaitClient_t WaitClient; - CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; -#endif -}; - -#endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c deleted file mode 100644 index c180e30d7fa..00000000000 --- a/src/egl/main/eglconfig.c +++ /dev/null @@ -1,638 +0,0 @@ -/** - * EGL Configuration (pixel format) functions. - */ - - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <assert.h> -#include "eglconfig.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" - - -#define MIN2(A, B) (((A) < (B)) ? (A) : (B)) - - -/** - * Convert an _EGLConfig to a __GLcontextModes object. - * NOTE: This routine may be incomplete - we're only making sure that - * the fields needed by Mesa (for _mesa_create_context/framebuffer) are - * set correctly. - */ -void -_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode) -{ - memset(mode, 0, sizeof(*mode)); - - mode->rgbMode = GL_TRUE; /* no color index */ - mode->colorIndexMode = GL_FALSE; - mode->doubleBufferMode = GL_TRUE; /* always DB for now */ - mode->stereoMode = GL_FALSE; - - mode->redBits = GET_CONFIG_ATTRIB(config, EGL_RED_SIZE); - mode->greenBits = GET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE); - mode->blueBits = GET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE); - mode->alphaBits = GET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE); - mode->rgbBits = GET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE); - - /* no rgba masks - fix? */ - - mode->depthBits = GET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE); - mode->haveDepthBuffer = mode->depthBits > 0; - - mode->stencilBits = GET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE); - mode->haveStencilBuffer = mode->stencilBits > 0; - - /* no accum */ - - mode->level = GET_CONFIG_ATTRIB(config, EGL_LEVEL); - mode->samples = GET_CONFIG_ATTRIB(config, EGL_SAMPLES); - mode->sampleBuffers = GET_CONFIG_ATTRIB(config, EGL_SAMPLE_BUFFERS); - - /* surface type - not really needed */ - mode->visualType = GLX_TRUE_COLOR; - mode->renderType = GLX_RGBA_BIT; -} - - -void -_eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val) -{ - assert(attr >= FIRST_ATTRIB); - assert(attr < FIRST_ATTRIB + MAX_ATTRIBS); - config->Attrib[attr - FIRST_ATTRIB] = val; -} - - -/** - * Init the given _EGLconfig to default values. - * \param id the configuration's ID. - */ -void -_eglInitConfig(_EGLConfig *config, EGLint id) -{ - memset(config, 0, sizeof(*config)); - config->Handle = id; - _eglSetConfigAttrib(config, EGL_CONFIG_ID, id); - _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGB, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_CONFIG_CAVEAT, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_NATIVE_RENDERABLE, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_NATIVE_VISUAL_TYPE, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_MIN_SWAP_INTERVAL, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_MAX_SWAP_INTERVAL, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, - EGL_SCREEN_BIT_MESA | EGL_PBUFFER_BIT | - EGL_PIXMAP_BIT | EGL_WINDOW_BIT); - _eglSetConfigAttrib(config, EGL_TRANSPARENT_TYPE, EGL_NONE); - _eglSetConfigAttrib(config, EGL_TRANSPARENT_RED_VALUE, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_TRANSPARENT_GREEN_VALUE, EGL_DONT_CARE); - _eglSetConfigAttrib(config, EGL_TRANSPARENT_BLUE_VALUE, EGL_DONT_CARE); -#ifdef EGL_VERSION_1_2 - _eglSetConfigAttrib(config, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER); - _eglSetConfigAttrib(config, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT); -#endif /* EGL_VERSION_1_2 */ -} - - -/** - * Given an EGLConfig handle, return the corresponding _EGLConfig object. - */ -_EGLConfig * -_eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config) -{ - EGLint i; - _EGLDisplay *disp = _eglLookupDisplay(dpy); - for (i = 0; i < disp->NumConfigs; i++) { - if (disp->Configs[i].Handle == config) { - return disp->Configs + i; - } - } - return NULL; -} - - -/** - * Add the given _EGLConfig to the given display. - */ -_EGLConfig * -_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config) -{ - _EGLConfig *newConfigs; - EGLint n; - - n = display->NumConfigs; - - newConfigs = (_EGLConfig *) realloc(display->Configs, - (n + 1) * sizeof(_EGLConfig)); - if (newConfigs) { - display->Configs = newConfigs; - display->Configs[n] = *config; /* copy struct */ - display->Configs[n].Handle = n; - display->NumConfigs++; - return display->Configs + n; - } - else { - return NULL; - } -} - - -/** - * Parse the attrib_list to fill in the fields of the given _eglConfig - * Return EGL_FALSE if any errors, EGL_TRUE otherwise. - */ -EGLBoolean -_eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list) -{ - EGLint i; - - /* set all config attribs to EGL_DONT_CARE */ - for (i = 0; i < MAX_ATTRIBS; i++) { - config->Attrib[i] = EGL_DONT_CARE; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - const EGLint attr = attrib_list[i]; - if (attr >= EGL_BUFFER_SIZE && - attr <= EGL_MAX_SWAP_INTERVAL) { - EGLint k = attr - FIRST_ATTRIB; - assert(k >= 0); - assert(k < MAX_ATTRIBS); - config->Attrib[k] = attrib_list[++i]; - } -#ifdef EGL_VERSION_1_2 - else if (attr == EGL_COLOR_BUFFER_TYPE) { - EGLint bufType = attrib_list[++i]; - if (bufType != EGL_RGB_BUFFER && bufType != EGL_LUMINANCE_BUFFER) { - _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); - return EGL_FALSE; - } - _eglSetConfigAttrib(config, EGL_COLOR_BUFFER_TYPE, bufType); - } - else if (attr == EGL_RENDERABLE_TYPE) { - EGLint renType = attrib_list[++i]; - if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT)) { - _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); - return EGL_FALSE; - } - _eglSetConfigAttrib(config, EGL_RENDERABLE_TYPE, renType); - } - else if (attr == EGL_ALPHA_MASK_SIZE || - attr == EGL_LUMINANCE_SIZE) { - EGLint value = attrib_list[++i]; - _eglSetConfigAttrib(config, attr, value); - } -#endif /* EGL_VERSION_1_2 */ - else { - _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); - return EGL_FALSE; - } - } - return EGL_TRUE; -} - - -#define EXACT 1 -#define ATLEAST 2 -#define MASK 3 -#define SMALLER 4 -#define SPECIAL 5 -#define NONE 6 - -struct sort_info { - EGLint Attribute; - EGLint MatchCriteria; - EGLint SortOrder; -}; - -/* This encodes the info from Table 3.5 of the EGL spec, ordered by - * Sort Priority. - * - * XXX To do: EGL 1.2 attribs - */ -static struct sort_info SortInfo[] = { - { EGL_CONFIG_CAVEAT, EXACT, SPECIAL }, - { EGL_RED_SIZE, ATLEAST, SPECIAL }, - { EGL_GREEN_SIZE, ATLEAST, SPECIAL }, - { EGL_BLUE_SIZE, ATLEAST, SPECIAL }, - { EGL_ALPHA_SIZE, ATLEAST, SPECIAL }, - { EGL_BUFFER_SIZE, ATLEAST, SMALLER }, - { EGL_SAMPLE_BUFFERS, ATLEAST, SMALLER }, - { EGL_SAMPLES, ATLEAST, SMALLER }, - { EGL_DEPTH_SIZE, ATLEAST, SMALLER }, - { EGL_STENCIL_SIZE, ATLEAST, SMALLER }, - { EGL_NATIVE_VISUAL_TYPE, EXACT, SPECIAL }, - { EGL_CONFIG_ID, EXACT, SMALLER }, - { EGL_BIND_TO_TEXTURE_RGB, EXACT, NONE }, - { EGL_BIND_TO_TEXTURE_RGBA, EXACT, NONE }, - { EGL_LEVEL, EXACT, NONE }, - { EGL_NATIVE_RENDERABLE, EXACT, NONE }, - { EGL_MAX_SWAP_INTERVAL, EXACT, NONE }, - { EGL_MIN_SWAP_INTERVAL, EXACT, NONE }, - { EGL_SURFACE_TYPE, MASK, NONE }, - { EGL_TRANSPARENT_TYPE, EXACT, NONE }, - { EGL_TRANSPARENT_RED_VALUE, EXACT, NONE }, - { EGL_TRANSPARENT_GREEN_VALUE, EXACT, NONE }, - { EGL_TRANSPARENT_BLUE_VALUE, EXACT, NONE }, - { 0, 0, 0 } -}; - - -/** - * Return EGL_TRUE if the attributes of c meet or exceed the minimums - * specified by min. - */ -static EGLBoolean -_eglConfigQualifies(const _EGLConfig *c, const _EGLConfig *min) -{ - EGLint i; - for (i = 0; SortInfo[i].Attribute != 0; i++) { - const EGLint mv = GET_CONFIG_ATTRIB(min, SortInfo[i].Attribute); - if (mv != EGL_DONT_CARE) { - const EGLint cv = GET_CONFIG_ATTRIB(c, SortInfo[i].Attribute); - if (SortInfo[i].MatchCriteria == EXACT) { - if (cv != mv) { - return EGL_FALSE; - } - } - else if (SortInfo[i].MatchCriteria == ATLEAST) { - if (cv < mv) { - return EGL_FALSE; - } - } - else { - assert(SortInfo[i].MatchCriteria == MASK); - if ((mv & cv) != mv) { - return EGL_FALSE; - } - } - } - } - return EGL_TRUE; -} - - -/** - * Compare configs 'a' and 'b' and return -1 if a belongs before b, - * 1 if a belongs after b, or 0 if they're equal. - * Used by qsort(). - */ -static int -_eglCompareConfigs(const void *a, const void *b) -{ - const _EGLConfig *aConfig = (const _EGLConfig *) a; - const _EGLConfig *bConfig = (const _EGLConfig *) b; - EGLint i; - - for (i = 0; SortInfo[i].Attribute != 0; i++) { - const EGLint aVal = GET_CONFIG_ATTRIB(aConfig, SortInfo[i].Attribute); - const EGLint bVal = GET_CONFIG_ATTRIB(bConfig, SortInfo[i].Attribute); - if (SortInfo[i].SortOrder == SMALLER) { - if (aVal < bVal) - return -1; - else if (aVal > bVal) - return 1; - /* else, continue examining attribute values */ - } - else if (SortInfo[i].SortOrder == SPECIAL) { - if (SortInfo[i].Attribute == EGL_CONFIG_CAVEAT) { - /* values are EGL_NONE, SLOW_CONFIG, or NON_CONFORMANT_CONFIG */ - if (aVal < bVal) - return -1; - else if (aVal > bVal) - return 1; - } - else if (SortInfo[i].Attribute == EGL_RED_SIZE || - SortInfo[i].Attribute == EGL_GREEN_SIZE || - SortInfo[i].Attribute == EGL_BLUE_SIZE || - SortInfo[i].Attribute == EGL_ALPHA_SIZE) { - if (aVal > bVal) - return -1; - else if (aVal < bVal) - return 1; - } - else { - assert(SortInfo[i].Attribute == EGL_NATIVE_VISUAL_TYPE); - if (aVal < bVal) - return -1; - else if (aVal > bVal) - return 1; - } - } - else { - assert(SortInfo[i].SortOrder == NONE); - /* continue examining attribute values */ - } - } - - /* all attributes identical */ - return 0; -} - - -/** - * Typical fallback routine for eglChooseConfig - */ -EGLBoolean -_eglChooseConfig(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list, - EGLConfig *configs, EGLint config_size, EGLint *num_configs) -{ - _EGLDisplay *disp = _eglLookupDisplay(dpy); - _EGLConfig **configList, criteria; - EGLint i, count; - - /* parse the attrib_list to initialize criteria */ - if (!_eglParseConfigAttribs(&criteria, attrib_list)) { - return EGL_FALSE; - } - - /* allocate array of config pointers */ - configList = (_EGLConfig **) malloc(config_size * sizeof(_EGLConfig *)); - if (!configList) { - _eglError(EGL_BAD_CONFIG, "eglChooseConfig(out of memory)"); - return EGL_FALSE; - } - - /* make array of pointers to qualifying configs */ - for (i = count = 0; i < disp->NumConfigs && count < config_size; i++) { - if (_eglConfigQualifies(disp->Configs + i, &criteria)) { - configList[count++] = disp->Configs + i; - } - } - - /* sort array of pointers */ - qsort(configList, count, sizeof(_EGLConfig *), _eglCompareConfigs); - - /* copy config handles to output array */ - for (i = 0; i < count; i++) { - configs[i] = configList[i]->Handle; - } - - free(configList); - - *num_configs = count; - - return EGL_TRUE; -} - - -/** - * Fallback for eglGetConfigAttrib. - */ -EGLBoolean -_eglGetConfigAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint *value) -{ - const _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); - const EGLint k = attribute - FIRST_ATTRIB; - if (k >= 0 && k < MAX_ATTRIBS) { - *value = conf->Attrib[k]; - return EGL_TRUE; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, "eglGetConfigAttrib"); - return EGL_FALSE; - } -} - - -/** - * Fallback for eglGetConfigs. - */ -EGLBoolean -_eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, - EGLint config_size, EGLint *num_config) -{ - _EGLDisplay *disp = _eglLookupDisplay(dpy); - - if (!drv->Initialized) { - _eglError(EGL_NOT_INITIALIZED, "eglGetConfigs"); - return EGL_FALSE; - } - - if (configs) { - EGLint i; - *num_config = MIN2(disp->NumConfigs, config_size); - for (i = 0; i < *num_config; i++) { - configs[i] = disp->Configs[i].Handle; - } - } - else { - /* just return total number of supported configs */ - *num_config = disp->NumConfigs; - } - - return EGL_TRUE; -} - - -/** - * Creates a set of \c __GLcontextModes that a driver will expose. - * - * A set of \c __GLcontextModes will be created based on the supplied - * parameters. The number of modes processed will be 2 * - * \c num_depth_stencil_bits * \c num_db_modes. - * - * For the most part, data is just copied from \c depth_bits, \c stencil_bits, - * \c db_modes, and \c visType into each \c __GLcontextModes element. - * However, the meanings of \c fb_format and \c fb_type require further - * explanation. The \c fb_format specifies which color components are in - * each pixel and what the default order is. For example, \c GL_RGB specifies - * that red, green, blue are available and red is in the "most significant" - * position and blue is in the "least significant". The \c fb_type specifies - * the bit sizes of each component and the actual ordering. For example, if - * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11] - * are the blue value, bits [10:5] are the green value, and bits [4:0] are - * the red value. - * - * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either - * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the - * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or - * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as - * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8 - * still uses 32-bits. - * - * If in doubt, look at the tables used in the function. - * - * \param ptr_to_modes Pointer to a pointer to a linked list of - * \c __GLcontextModes. Upon completion, a pointer to - * the next element to be process will be stored here. - * If the function fails and returns \c GL_FALSE, this - * value will be unmodified, but some elements in the - * linked list may be modified. - * \param fb_format Format of the framebuffer. Currently only \c GL_RGB, - * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported. - * \param fb_type Type of the pixels in the framebuffer. Currently only - * \c GL_UNSIGNED_SHORT_5_6_5, - * \c GL_UNSIGNED_SHORT_5_6_5_REV, - * \c GL_UNSIGNED_INT_8_8_8_8, and - * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported. - * \param depth_bits Array of depth buffer sizes to be exposed. - * \param stencil_bits Array of stencil buffer sizes to be exposed. - * \param num_depth_stencil_bits Number of entries in both \c depth_bits and - * \c stencil_bits. - * \param db_modes Array of buffer swap modes. If an element has a - * value of \c GLX_NONE, then it represents a - * single-buffered mode. Other valid values are - * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and - * \c GLX_SWAP_UNDEFINED_OML. See the - * GLX_OML_swap_method extension spec for more details. - * \param num_db_modes Number of entries in \c db_modes. - * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or - * \c GLX_DIRECT_COLOR. - * - * \returns - * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only - * cause of failure is a bad parameter (i.e., unsupported \c fb_format or - * \c fb_type). - * - * \todo - * There is currently no way to support packed RGB modes (i.e., modes with - * exactly 3 bytes per pixel) or floating-point modes. This could probably - * be done by creating some new, private enums with clever names likes - * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32, - * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it. - */ -GLboolean -_eglFillInConfigs(_EGLConfig * configs, - GLenum fb_format, GLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const GLenum * db_modes, unsigned num_db_modes, - int visType) -{ - static const u_int8_t bits_table[3][4] = { - /* R G B A */ - { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ - { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ - { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */ - }; - - /* The following arrays are all indexed by the fb_type masked with 0x07. - * Given the four supported fb_type values, this results in valid array - * indices of 3, 4, 5, and 7. - */ - static const u_int32_t masks_table_rgb[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000} /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_rgba[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_bgr[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000}, /* 8_8_8_8_REV */ - }; - - static const u_int32_t masks_table_bgra[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */ - }; - - static const u_int8_t bytes_per_pixel[8] = { - 0, 0, 0, 2, 2, 4, 0, 4 - }; - - const u_int8_t * bits; - const u_int32_t * masks; - const int index = fb_type & 0x07; - _EGLConfig *config; - unsigned i; - unsigned j; - unsigned k; - - if ( bytes_per_pixel[index] == 0 ) { - _eglLog(_EGL_INFO, - "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.", - __FUNCTION__, __LINE__, fb_type); - return GL_FALSE; - } - - /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and - * the _REV versions. - * - * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA. - */ - switch ( fb_format ) { - case GL_RGB: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_rgb[index]; - break; - - case GL_RGBA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_rgba[index]; - break; - - case GL_BGR: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_bgr[index]; - break; - - case GL_BGRA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_bgra[index]; - break; - - default: - _eglLog(_EGL_WARNING, - "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.", - __FUNCTION__, __LINE__, fb_format); - return GL_FALSE; - } - - config = configs; - for (k = 0; k < num_depth_stencil_bits; k++) { - for (i = 0; i < num_db_modes; i++) { - for (j = 0; j < 2; j++) { - _eglSetConfigAttrib(config, EGL_RED_SIZE, bits[0]); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, bits[1]); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, bits[2]); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, bits[3]); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, - bits[0] + bits[1] + bits[2] + bits[3]); - - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, stencil_bits[k]); - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, depth_bits[i]); - - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_SCREEN_BIT_MESA | - EGL_PBUFFER_BIT | EGL_PIXMAP_BIT | EGL_WINDOW_BIT); - - config++; - } - } - } - return GL_TRUE; -} diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h deleted file mode 100644 index 1fb976e5b4b..00000000000 --- a/src/egl/main/eglconfig.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef EGLCONFIG_INCLUDED -#define EGLCONFIG_INCLUDED - - -#include "egltypedefs.h" -#include "GL/internal/glcore.h" - - -#define MAX_ATTRIBS 100 -#define FIRST_ATTRIB EGL_BUFFER_SIZE - - -struct _egl_config -{ - EGLConfig Handle; /* the public/opaque handle which names this config */ - EGLint Attrib[MAX_ATTRIBS]; -}; - - -#define SET_CONFIG_ATTRIB(CONF, ATTR, VAL) ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB] = VAL) -#define GET_CONFIG_ATTRIB(CONF, ATTR) ((CONF)->Attrib[(ATTR) - FIRST_ATTRIB]) - - -extern void -_eglInitConfig(_EGLConfig *config, EGLint id); - - -extern _EGLConfig * -_eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config); - - -extern _EGLConfig * -_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config); - - -extern EGLBoolean -_eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list); - - -extern EGLBoolean -_eglChooseConfig(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); - - -extern EGLBoolean -_eglGetConfigAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); - - -extern EGLBoolean -_eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); - - -extern void -_eglSetConfigAttrib(_EGLConfig *config, EGLint attr, EGLint val); - -extern GLboolean -_eglFillInConfigs( _EGLConfig *configs, - GLenum fb_format, GLenum fb_type, - const u_int8_t * depth_bits, const u_int8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const GLenum * db_modes, unsigned num_db_modes, - int visType ); - -extern void -_eglConfigToContextModesRec(const _EGLConfig *config, __GLcontextModes *mode); - - -#endif /* EGLCONFIG_INCLUDED */ diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c deleted file mode 100644 index 374c006dae7..00000000000 --- a/src/egl/main/eglcontext.c +++ /dev/null @@ -1,276 +0,0 @@ -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglhash.h" -#include "eglsurface.h" - - -/** - * Initialize the given _EGLContext object to defaults. - */ -EGLBoolean -_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, - EGLConfig config, const EGLint *attrib_list) -{ - _EGLConfig *conf; - _EGLDisplay *display = _eglLookupDisplay(dpy); - EGLint i; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreateContext"); - return EGL_FALSE; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - } - - memset(ctx, 0, sizeof(_EGLContext)); - ctx->Display = display; - ctx->Config = conf; - ctx->DrawSurface = EGL_NO_SURFACE; - ctx->ReadSurface = EGL_NO_SURFACE; - - return EGL_TRUE; -} - - -/* - * Assign an EGLContext handle to the _EGLContext object then put it into - * the hash table. - */ -void -_eglSaveContext(_EGLContext *ctx) -{ - assert(ctx); - ctx->Handle = _eglHashGenKey(_eglGlobal.Contexts); - _eglHashInsert(_eglGlobal.Contexts, ctx->Handle, ctx); -} - - -/** - * Remove the given _EGLContext object from the hash table. - */ -void -_eglRemoveContext(_EGLContext *ctx) -{ - _eglHashRemove(_eglGlobal.Contexts, ctx->Handle); -} - - -/** - * Return the _EGLContext object that corresponds to the given - * EGLContext handle. - */ -_EGLContext * -_eglLookupContext(EGLContext ctx) -{ - _EGLContext *c = (_EGLContext *) _eglHashLookup(_eglGlobal.Contexts, ctx); - return c; -} - - -/** - * Return the currently bound _EGLContext object, or NULL. - */ -_EGLContext * -_eglGetCurrentContext(void) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - return t->CurrentContext; -} - - -/** - * Just a placeholder/demo function. Real driver will never use this! - */ -EGLContext -_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - EGLContext share_list, const EGLint *attrib_list) -{ -#if 0 /* example code */ - _EGLContext *context; - - context = (_EGLContext *) calloc(1, sizeof(_EGLContext)); - if (!context) - return EGL_NO_CONTEXT; - - if (!_eglInitContext(drv, dpy, context, config, attrib_list)) { - free(context); - return EGL_NO_CONTEXT; - } - - _eglSaveContext(context); - return context->Handle; -#endif - return EGL_NO_CONTEXT; -} - - -/** - * Default fallback routine - drivers should usually override this. - */ -EGLBoolean -_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx) -{ - _EGLContext *context = _eglLookupContext(ctx); - if (context) { - _eglHashRemove(_eglGlobal.Contexts, ctx); - if (context->IsBound) { - context->DeletePending = EGL_TRUE; - } - else { - free(context); - } - return EGL_TRUE; - } - else { - _eglError(EGL_BAD_CONTEXT, "eglDestroyContext"); - return EGL_TRUE; - } -} - - -EGLBoolean -_eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx, - EGLint attribute, EGLint *value) -{ - _EGLContext *c = _eglLookupContext(ctx); - - (void) drv; - (void) dpy; - - if (!c) { - _eglError(EGL_BAD_CONTEXT, "eglQueryContext"); - return EGL_FALSE; - } - - switch (attribute) { - case EGL_CONFIG_ID: - *value = GET_CONFIG_ATTRIB(c->Config, EGL_CONFIG_ID); - return EGL_TRUE; -#ifdef EGL_VERSION_1_2 - case EGL_CONTEXT_CLIENT_TYPE: - *value = c->ClientAPI; - return EGL_FALSE; -#endif /* EGL_VERSION_1_2 */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext"); - return EGL_FALSE; - } -} - - -/** - * Drivers will typically call this to do the error checking and - * update the various IsBound and DeletePending flags. - * Then, the driver will do its device-dependent Make-Current stuff. - */ -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); - - _EGLContext *oldContext = _eglGetCurrentContext(); - _EGLSurface *oldDrawSurface = _eglGetCurrentSurface(EGL_DRAW); - _EGLSurface *oldReadSurface = _eglGetCurrentSurface(EGL_READ); - - /* error checking */ - if (ctx) { - if (draw == NULL || read == NULL) { - _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - return EGL_FALSE; - } - if (draw->Config != ctx->Config) { - _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - return EGL_FALSE; - } - if (read->Config != ctx->Config) { - _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - return EGL_FALSE; - } - } - - /* - * check if the old context or surfaces need to be deleted - */ - if (oldDrawSurface != NULL) { - oldDrawSurface->IsBound = EGL_FALSE; - if (oldDrawSurface->DeletePending) { - /* make sure we don't try to rebind a deleted surface */ - if (draw == oldDrawSurface || draw == oldReadSurface) { - draw = NULL; - } - /* really delete surface now */ - drv->API.DestroySurface(drv, dpy, oldDrawSurface->Handle); - } - } - if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) { - oldReadSurface->IsBound = EGL_FALSE; - if (oldReadSurface->DeletePending) { - /* make sure we don't try to rebind a deleted surface */ - if (read == oldDrawSurface || read == oldReadSurface) { - read = NULL; - } - /* really delete surface now */ - drv->API.DestroySurface(drv, dpy, oldReadSurface->Handle); - } - } - if (oldContext != NULL) { - oldContext->IsBound = EGL_FALSE; - if (oldContext->DeletePending) { - /* make sure we don't try to rebind a deleted context */ - if (ctx == oldContext) { - ctx = NULL; - } - /* really delete context now */ - drv->API.DestroyContext(drv, dpy, oldContext->Handle); - } - } - - if (ctx) { - /* check read/draw again, in case we deleted them above */ - if (draw == NULL || read == NULL) { - _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - return EGL_FALSE; - } - ctx->DrawSurface = draw; - ctx->ReadSurface = read; - ctx->IsBound = EGL_TRUE; - draw->IsBound = EGL_TRUE; - read->IsBound = EGL_TRUE; - } - - t->CurrentContext = ctx; - - return EGL_TRUE; -} - - -/** - * This is defined by the EGL_MESA_copy_context extension. - */ -EGLBoolean -_eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, - EGLContext dest, EGLint mask) -{ - /* This function will always have to be overridden/implemented in the - * device driver. If the driver is based on Mesa, use _mesa_copy_context(). - */ - return EGL_FALSE; -} diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h deleted file mode 100644 index 82bfde151f3..00000000000 --- a/src/egl/main/eglcontext.h +++ /dev/null @@ -1,71 +0,0 @@ - -#ifndef EGLCONTEXT_INCLUDED -#define EGLCONTEXT_INCLUDED - - -#include "egltypedefs.h" - - -/** - * "Base" class for device driver contexts. - */ -struct _egl_context -{ - EGLContext Handle; /* The public/opaque handle which names this object */ - - _EGLDisplay *Display; /* who do I belong to? */ - - _EGLConfig *Config; - - _EGLSurface *DrawSurface; - _EGLSurface *ReadSurface; - - EGLBoolean IsBound; - EGLBoolean DeletePending; -#ifdef EGL_VERSION_1_2 - EGLint ClientAPI; /* Either EGL_OPENGL_ES_API or EGL_OPENVG_API */ -#endif /* EGL_VERSION_1_2 */ -}; - - -extern EGLBoolean -_eglInitContext(_EGLDriver *drv, EGLDisplay dpy, _EGLContext *ctx, - EGLConfig config, const EGLint *attrib_list); - - -extern void -_eglSaveContext(_EGLContext *ctx); - - -extern void -_eglRemoveContext(_EGLContext *ctx); - - -extern _EGLContext * -_eglLookupContext(EGLContext ctx); - - -extern _EGLContext * -_eglGetCurrentContext(void); - - -extern EGLContext -_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list); - - -extern EGLBoolean -_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx); - - -extern EGLBoolean -_eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); - - -extern EGLBoolean -_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); - - -extern EGLBoolean -_eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask); - -#endif /* EGLCONTEXT_INCLUDED */ diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c deleted file mode 100644 index 074a85bf26b..00000000000 --- a/src/egl/main/egldisplay.c +++ /dev/null @@ -1,71 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include "eglcontext.h" -#include "egldisplay.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; -} - - -/** - * We're assuming that the NativeDisplayType parameter is actually - * a string. - * Return a new _EGLDisplay object for the given displayName - */ -_EGLDisplay * -_eglNewDisplay(NativeDisplayType displayName) -{ - _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 */ - } - return dpy; -} - - -/** - * Return the _EGLDisplay object that corresponds to the given public/ - * opaque display handle. - */ -_EGLDisplay * -_eglLookupDisplay(EGLDisplay dpy) -{ - _EGLDisplay *d = (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, dpy); - return d; -} - - -_EGLDisplay * -_eglGetCurrentDisplay(void) -{ - _EGLContext *ctx = _eglGetCurrentContext(); - if (ctx) - return ctx->Display; - else - return NULL; -} - - -void -_eglCleanupDisplay(_EGLDisplay *disp) -{ - /* XXX incomplete */ - free(disp->Configs); - free(disp->Name); - /* driver deletes _EGLDisplay */ -} diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h deleted file mode 100644 index 1a03fdd4ad9..00000000000 --- a/src/egl/main/egldisplay.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef EGLDISPLAY_INCLUDED -#define EGLDISPLAY_INCLUDED - - -#include "egltypedefs.h" - - -struct _egl_display -{ - EGLDisplay Handle; - - char *Name; - _EGLDriver *Driver; - - EGLint NumScreens; - _EGLScreen **Screens; /* array [NumScreens] */ - - EGLint NumConfigs; - _EGLConfig *Configs; /* array [NumConfigs] */ -}; - - -extern _EGLDisplay * -_eglNewDisplay(NativeDisplayType displayName); - - -extern _EGLDisplay * -_eglLookupDisplay(EGLDisplay dpy); - - -extern _EGLDisplay * -_eglGetCurrentDisplay(void); - - -extern void -_eglCleanupDisplay(_EGLDisplay *disp); - - -extern EGLBoolean -_eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint attrib, EGLint *value); - - - -#endif /* EGLDISPLAY_INCLUDED */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c deleted file mode 100644 index bda06dd827d..00000000000 --- a/src/egl/main/egldriver.c +++ /dev/null @@ -1,272 +0,0 @@ -#include <assert.h> -#include <dlfcn.h> -#include <stdio.h> -#include <string.h> -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - - -const char *DefaultDriverName = "demodriver"; - - -/** - * Choose and open/init the hardware driver for the given EGLDisplay. - * Previously, the EGLDisplay was created with _eglNewDisplay() where - * we recorded the user's NativeDisplayType parameter. - * - * Now we'll use the NativeDisplayType value. - * - * Currently, the native display value is treated as a string. - * If the first character is ':' we interpret it as a screen or card index - * number (i.e. ":0" or ":1", etc) - * Else if the first character is '!' we interpret it as specific driver name - * (i.e. "!r200" or "!i830". - */ -_EGLDriver * -_eglChooseDriver(EGLDisplay display) -{ - _EGLDisplay *dpy = _eglLookupDisplay(display); - _EGLDriver *drv; - const char *driverName = DefaultDriverName; - const char *name; - - assert(dpy); - - name = dpy->Name; - if (!name) { - /* use default */ - } - else if (name[0] == ':' && (name[1] >= '0' && name[1] <= '9') && !name[2]) { - /* XXX probe hardware here to determine which driver to open */ - driverName = "libEGLdri"; - } - else if (name[0] == '!') { - /* use specified driver name */ - driverName = name + 1; - } - else { - /* Maybe display was returned by XOpenDisplay? */ - _eglLog(_EGL_FATAL, "eglChooseDriver() bad name"); - } - - _eglLog(_EGL_INFO, "eglChooseDriver() choosing %s", driverName); - - drv = _eglOpenDriver(dpy, driverName); - dpy->Driver = drv; - - return drv; -} - - -/** - * Open/load the named driver and call its bootstrap function: _eglMain(). - * \return new _EGLDriver object. - */ -_EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *driverName) -{ - _EGLDriver *drv; - _EGLMain_t mainFunc; - void *lib; - char driverFilename[1000]; - - /* XXX also prepend a directory path??? */ - sprintf(driverFilename, "%s.so", driverName); - - _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); - lib = dlopen(driverFilename, RTLD_NOW); - if (!lib) { - _eglLog(_EGL_WARNING, "Could not open %s (%s)", - driverFilename, dlerror()); - return NULL; - } - - mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); - if (!mainFunc) { - _eglLog(_EGL_WARNING, "_eglMain not found in %s", driverFilename); - dlclose(lib); - return NULL; - } - - drv = mainFunc(dpy); - if (!drv) { - dlclose(lib); - return NULL; - } - /* with a recurvise open you want the inner most handle */ - if (!drv->LibHandle) - drv->LibHandle = lib; - else - dlclose(lib); - - drv->Display = dpy; - return drv; -} - - -EGLBoolean -_eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy) -{ - void *handle = drv->LibHandle; - EGLBoolean b; - - _eglLog(_EGL_INFO, "Closing driver"); - - /* - * XXX check for currently bound context/surfaces and delete them? - */ - - b = drv->API.Terminate(drv, dpy); - dlclose(handle); - return b; -} - - -/** - * Given a display handle, return the _EGLDriver for that display. - */ -_EGLDriver * -_eglLookupDriver(EGLDisplay dpy) -{ - _EGLDisplay *d = _eglLookupDisplay(dpy); - if (d) - return d->Driver; - else - return NULL; -} - - -/** - * Plug all the available fallback routines into the given driver's - * dispatch table. - */ -void -_eglInitDriverFallbacks(_EGLDriver *drv) -{ - /* If a pointer is set to NULL, then the device driver _really_ has - * to implement it. - */ - drv->API.Initialize = NULL; - drv->API.Terminate = NULL; - - drv->API.GetConfigs = _eglGetConfigs; - drv->API.ChooseConfig = _eglChooseConfig; - drv->API.GetConfigAttrib = _eglGetConfigAttrib; - - drv->API.CreateContext = _eglCreateContext; - drv->API.DestroyContext = _eglDestroyContext; - drv->API.MakeCurrent = _eglMakeCurrent; - drv->API.QueryContext = _eglQueryContext; - - drv->API.CreateWindowSurface = _eglCreateWindowSurface; - drv->API.CreatePixmapSurface = _eglCreatePixmapSurface; - drv->API.CreatePbufferSurface = _eglCreatePbufferSurface; - drv->API.DestroySurface = _eglDestroySurface; - drv->API.QuerySurface = _eglQuerySurface; - drv->API.SurfaceAttrib = _eglSurfaceAttrib; - drv->API.BindTexImage = _eglBindTexImage; - drv->API.ReleaseTexImage = _eglReleaseTexImage; - drv->API.SwapInterval = _eglSwapInterval; - drv->API.SwapBuffers = _eglSwapBuffers; - drv->API.CopyBuffers = _eglCopyBuffers; - - drv->API.QueryString = _eglQueryString; - drv->API.WaitGL = _eglWaitGL; - drv->API.WaitNative = _eglWaitNative; - -#ifdef EGL_MESA_screen_surface - drv->API.ChooseModeMESA = _eglChooseModeMESA; - drv->API.GetModesMESA = _eglGetModesMESA; - drv->API.GetModeAttribMESA = _eglGetModeAttribMESA; - drv->API.GetScreensMESA = _eglGetScreensMESA; - drv->API.CreateScreenSurfaceMESA = _eglCreateScreenSurfaceMESA; - drv->API.ShowScreenSurfaceMESA = _eglShowScreenSurfaceMESA; - drv->API.ScreenPositionMESA = _eglScreenPositionMESA; - drv->API.QueryScreenMESA = _eglQueryScreenMESA; - drv->API.QueryScreenSurfaceMESA = _eglQueryScreenSurfaceMESA; - drv->API.QueryScreenModeMESA = _eglQueryScreenModeMESA; - drv->API.QueryModeStringMESA = _eglQueryModeStringMESA; -#endif /* EGL_MESA_screen_surface */ - -#ifdef EGL_VERSION_1_2 - drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer; -#endif /* EGL_VERSION_1_2 */ -} - - -/** - * Examine the individual extension enable/disable flags and recompute - * the driver's Extensions string. - */ -static void -_eglUpdateExtensionsString(_EGLDriver *drv) -{ - drv->Extensions.String[0] = 0; - - if (drv->Extensions.MESA_screen_surface) - strcat(drv->Extensions.String, "EGL_MESA_screen_surface "); - if (drv->Extensions.MESA_copy_context) - strcat(drv->Extensions.String, "EGL_MESA_copy_context "); - assert(strlen(drv->Extensions.String) < MAX_EXTENSIONS_LEN); -} - - - -const char * -_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name) -{ - (void) drv; - (void) dpy; - switch (name) { - case EGL_VENDOR: - return "Mesa Project"; - case EGL_VERSION: - return "1.0"; - case EGL_EXTENSIONS: - _eglUpdateExtensionsString(drv); - return drv->Extensions.String; -#ifdef EGL_VERSION_1_2 - case EGL_CLIENT_APIS: - /* XXX need to initialize somewhere */ - return drv->ClientAPIs; -#endif - default: - _eglError(EGL_BAD_PARAMETER, "eglQueryString"); - return NULL; - } -} - - -EGLBoolean -_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy) -{ - /* just a placeholder */ - (void) drv; - (void) dpy; - return EGL_TRUE; -} - - -EGLBoolean -_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine) -{ - /* just a placeholder */ - (void) drv; - (void) dpy; - switch (engine) { - case EGL_CORE_NATIVE_ENGINE: - break; - default: - _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)"); - return EGL_FALSE; - } - - return EGL_TRUE; -} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h deleted file mode 100644 index 88526e973d1..00000000000 --- a/src/egl/main/egldriver.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef EGLDRIVER_INCLUDED -#define EGLDRIVER_INCLUDED - - -#include "egltypedefs.h" -#include "eglapi.h" - -/* should probably use a dynamic-length string, but this will do */ -#define MAX_EXTENSIONS_LEN 1000 - - -/** - * Optional EGL extensions info. - */ -struct _egl_extensions -{ - EGLBoolean MESA_screen_surface; - EGLBoolean MESA_copy_context; - - char String[MAX_EXTENSIONS_LEN]; -}; - - -/** - * Base class for device drivers. - */ -struct _egl_driver -{ - EGLBoolean Initialized; /* set by driver after initialized */ - - void *LibHandle; /* dlopen handle */ - - _EGLDisplay *Display; - - int ABIversion; - int APImajor, APIminor; /* returned through eglInitialize */ - const char *ClientAPIs; - - _EGLAPI API; - - _EGLExtensions Extensions; -}; - - -extern _EGLDriver *_eglMain(_EGLDisplay *dpy); - - -extern _EGLDriver * -_eglChooseDriver(EGLDisplay dpy); - - -extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy, const char *driverName); - - -extern EGLBoolean -_eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy); - - -extern _EGLDriver * -_eglLookupDriver(EGLDisplay d); - - -extern void -_eglInitDriverFallbacks(_EGLDriver *drv); - - -extern const char * -_eglQueryString(_EGLDriver *drv, EGLDisplay dpy, EGLint name); - - -extern EGLBoolean -_eglWaitGL(_EGLDriver *drv, EGLDisplay dpy); - - -extern EGLBoolean -_eglWaitNative(_EGLDriver *drv, EGLDisplay dpy, EGLint engine); - - - -#endif /* EGLDRIVER_INCLUDED */ diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c deleted file mode 100644 index 608311d7494..00000000000 --- a/src/egl/main/eglglobals.c +++ /dev/null @@ -1,148 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "eglglobals.h" - - -struct _egl_global _eglGlobal = { .Initialized = EGL_FALSE }; - - -/** - * Init the fields in the _eglGlobal struct - * May be safely called more than once. - */ -void -_eglInitGlobals(void) -{ - if (!_eglGlobal.Initialized) { - _eglGlobal.Displays = _eglNewHashTable(); - _eglGlobal.Contexts = _eglNewHashTable(); - _eglGlobal.Surfaces = _eglNewHashTable(); - _eglGlobal.FreeScreenHandle = 1; - _eglGlobal.Initialized = EGL_TRUE; - - _eglGlobal.OpenGLESAPISupported = EGL_TRUE; - _eglGlobal.OpenVGAPISupported = EGL_FALSE; - - /* XXX temporary */ - _eglGlobal.ThreadInfo = _eglNewThreadInfo(); - } -} - - -/** - * Should call this via an atexit handler. - */ -void -_eglDestroyGlobals(void) -{ - /* XXX TODO walk over table entries, deleting each */ - _eglDeleteHashTable(_eglGlobal.Displays); - _eglDeleteHashTable(_eglGlobal.Contexts); - _eglDeleteHashTable(_eglGlobal.Surfaces); -} - - -/** - * Allocate and init a new _EGLThreadInfo object. - */ -_EGLThreadInfo * -_eglNewThreadInfo(void) -{ - _EGLThreadInfo *t = (_EGLThreadInfo *) calloc(1, sizeof(_EGLThreadInfo)); - if (t) { - t->CurrentContext = EGL_NO_CONTEXT; - t->LastError = EGL_SUCCESS; - t->CurrentAPI = EGL_NONE; - } - return t; -} - - -/** - * Delete/free a _EGLThreadInfo object. - */ -void -_eglDeleteThreadData(_EGLThreadInfo *t) -{ - free(t); -} - - - -/** - * Return pointer to calling thread's _EGLThreadInfo object. - * Create a new one if needed. - * Should never return NULL. - */ -_EGLThreadInfo * -_eglGetCurrentThread(void) -{ - _eglInitGlobals(); - - /* XXX temporary */ - return _eglGlobal.ThreadInfo; -} - - -/** - * Record EGL error code. - */ -void -_eglError(EGLint errCode, const char *msg) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - const char *s; - - if (t->LastError == EGL_SUCCESS) { - t->LastError = errCode; - - switch (errCode) { - case EGL_BAD_ACCESS: - s = "EGL_BAD_ACCESS"; - break; - case EGL_BAD_ALLOC: - s = "EGL_BAD_ALLOC"; - break; - case EGL_BAD_ATTRIBUTE: - s = "EGL_BAD_ATTRIBUTE"; - break; - case EGL_BAD_CONFIG: - s = "EGL_BAD_CONFIG"; - break; - case EGL_BAD_CONTEXT: - s = "EGL_BAD_CONTEXT"; - break; - case EGL_BAD_CURRENT_SURFACE: - s = "EGL_BAD_CURRENT_SURFACE"; - break; - case EGL_BAD_DISPLAY: - s = "EGL_BAD_DISPLAY"; - break; - case EGL_BAD_MATCH: - s = "EGL_BAD_MATCH"; - break; - case EGL_BAD_NATIVE_PIXMAP: - s = "EGL_BAD_NATIVE_PIXMAP"; - break; - case EGL_BAD_NATIVE_WINDOW: - s = "EGL_BAD_NATIVE_WINDOW"; - break; - case EGL_BAD_PARAMETER: - s = "EGL_BAD_PARAMETER"; - break; - case EGL_BAD_SURFACE: - s = "EGL_BAD_SURFACE"; - break; - case EGL_BAD_SCREEN_MESA: - s = "EGL_BAD_SCREEN_MESA"; - break; - case EGL_BAD_MODE_MESA: - s = "EGL_BAD_MODE_MESA"; - break; - default: - s = "other"; - } - /* XXX temporary */ - fprintf(stderr, "EGL user error 0x%x (%s) in %s\n", errCode, s, msg); - } -} diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h deleted file mode 100644 index c16baa2d6bd..00000000000 --- a/src/egl/main/eglglobals.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef EGLGLOBALS_INCLUDED -#define EGLGLOBALS_INCLUDED - -#include "egltypedefs.h" -#include "eglhash.h" - - -/** - * Per-thread info - */ -struct _egl_thread_info -{ - EGLint LastError; - _EGLContext *CurrentContext; - EGLenum CurrentAPI; -}; - - -/** - * Global library data - */ -struct _egl_global -{ - EGLBoolean Initialized; - - _EGLHashtable *Displays; - _EGLHashtable *Contexts; - _EGLHashtable *Surfaces; - - EGLScreenMESA FreeScreenHandle; - - /* XXX these may be temporary */ - EGLBoolean OpenGLESAPISupported; - EGLBoolean OpenVGAPISupported; - - /* XXX temporary - should be thread-specific data (TSD) */ - _EGLThreadInfo *ThreadInfo; -}; - - -extern struct _egl_global _eglGlobal; - - -extern void -_eglInitGlobals(void); - - -extern void -_eglDestroyGlobals(void); - - -extern _EGLThreadInfo * -_eglNewThreadInfo(void); - - -extern void -_eglDeleteThreadData(_EGLThreadInfo *t); - - -extern _EGLThreadInfo * -_eglGetCurrentThread(void); - - -extern void -_eglError(EGLint errCode, const char *msg); - - -#endif /* EGLGLOBALS_INCLUDED */ diff --git a/src/egl/main/eglhash.c b/src/egl/main/eglhash.c deleted file mode 100644 index 8e3da2e9061..00000000000 --- a/src/egl/main/eglhash.c +++ /dev/null @@ -1,347 +0,0 @@ -/** - * \file hash.c - * Generic hash table. - * - * This code taken from Mesa and adapted. - */ - -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> -#include "eglhash.h" - - -#define TABLE_SIZE 1023 /**< Size of lookup table/array */ - -#define HASH_FUNC(K) ((K) % TABLE_SIZE) - - -/* - * Unfinished mutex stuff - */ - -typedef int _EGLMutex; - -static void -_eglInitMutex(_EGLMutex m) -{ -} - -static void -_eglDestroyMutex(_EGLMutex m) -{ -} - -static void -_eglLockMutex(_EGLMutex m) -{ -} - -static void -_eglUnlockMutex(_EGLMutex m) -{ -} - - - -typedef struct _egl_hashentry _EGLHashentry; - -struct _egl_hashentry -{ - EGLuint Key; /**< the entry's key */ - void *Data; /**< the entry's data */ - _EGLHashentry *Next; /**< pointer to next entry */ -}; - - -struct _egl_hashtable -{ - _EGLHashentry *Table[TABLE_SIZE]; /**< the lookup table */ - EGLuint MaxKey; /**< highest key inserted so far */ - _EGLMutex Mutex; /**< mutual exclusion lock */ -}; - - -/** - * Create a new hash table. - * - * \return pointer to a new, empty hash table. - */ -_EGLHashtable * -_eglNewHashTable(void) -{ - _EGLHashtable *table = (_EGLHashtable *) calloc(1, sizeof(_EGLHashtable)); - if (table) { - _eglInitMutex(table->Mutex); - table->MaxKey = 1; - } - return table; -} - - - -/** - * Delete a hash table. - * Frees each entry on the hash table and then the hash table structure itself. - * Note that the caller should have already traversed the table and deleted - * the objects in the table (i.e. We don't free the entries' data pointer). - * - * \param table the hash table to delete. - */ -void -_eglDeleteHashTable(_EGLHashtable *table) -{ - EGLuint i; - assert(table); - for (i = 0; i < TABLE_SIZE; i++) { - _EGLHashentry *entry = table->Table[i]; - while (entry) { - _EGLHashentry *next = entry->Next; - free(entry); - entry = next; - } - } - _eglDestroyMutex(table->Mutex); - free(table); -} - - - -/** - * Lookup an entry in the hash table. - * - * \param table the hash table. - * \param key the key. - * - * \return pointer to user's data or NULL if key not in table - */ -void * -_eglHashLookup(const _EGLHashtable *table, EGLuint key) -{ - EGLuint pos; - const _EGLHashentry *entry; - - assert(table); - - if (!key) - return NULL; - - pos = HASH_FUNC(key); - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - return entry->Data; - } - entry = entry->Next; - } - return NULL; -} - - - -/** - * Insert a key/pointer pair into the hash table. - * If an entry with this key already exists we'll replace the existing entry. - * - * \param table the hash table. - * \param key the key (not zero). - * \param data pointer to user data. - */ -void -_eglHashInsert(_EGLHashtable *table, EGLuint key, void *data) -{ - /* search for existing entry with this key */ - EGLuint pos; - _EGLHashentry *entry; - - assert(table); - assert(key); - - _eglLockMutex(table->Mutex); - - if (key > table->MaxKey) - table->MaxKey = key; - - pos = HASH_FUNC(key); - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - /* replace entry's data */ - entry->Data = data; - _eglUnlockMutex(table->Mutex); - return; - } - entry = entry->Next; - } - - /* alloc and insert new table entry */ - entry = (_EGLHashentry *) malloc(sizeof(_EGLHashentry)); - entry->Key = key; - entry->Data = data; - entry->Next = table->Table[pos]; - table->Table[pos] = entry; - - _eglUnlockMutex(table->Mutex); -} - - - -/** - * Remove an entry from the hash table. - * - * \param table the hash table. - * \param key key of entry to remove. - * - * While holding the hash table's lock, searches the entry with the matching - * key and unlinks it. - */ -void -_eglHashRemove(_EGLHashtable *table, EGLuint key) -{ - EGLuint pos; - _EGLHashentry *entry, *prev; - - assert(table); - assert(key); - - _eglLockMutex(table->Mutex); - - pos = HASH_FUNC(key); - prev = NULL; - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - /* found it! */ - if (prev) { - prev->Next = entry->Next; - } - else { - table->Table[pos] = entry->Next; - } - free(entry); - _eglUnlockMutex(table->Mutex); - return; - } - prev = entry; - entry = entry->Next; - } - - _eglUnlockMutex(table->Mutex); -} - - - -/** - * Get the key of the "first" entry in the hash table. - * - * This is used in the course of deleting all display lists when - * a context is destroyed. - * - * \param table the hash table - * - * \return key for the "first" entry in the hash table. - * - * While holding the lock, walks through all table positions until finding - * the first entry of the first non-empty one. - */ -EGLuint -_eglHashFirstEntry(_EGLHashtable *table) -{ - EGLuint pos; - assert(table); - _eglLockMutex(table->Mutex); - for (pos = 0; pos < TABLE_SIZE; pos++) { - if (table->Table[pos]) { - _eglUnlockMutex(table->Mutex); - return table->Table[pos]->Key; - } - } - _eglUnlockMutex(table->Mutex); - return 0; -} - - -/** - * Given a hash table key, return the next key. This is used to walk - * over all entries in the table. Note that the keys returned during - * walking won't be in any particular order. - * \return next hash key or 0 if end of table. - */ -EGLuint -_eglHashNextEntry(const _EGLHashtable *table, EGLuint key) -{ - const _EGLHashentry *entry; - EGLuint pos; - - assert(table); - assert(key); - - /* Find the entry with given key */ - pos = HASH_FUNC(key); - entry = table->Table[pos]; - while (entry) { - if (entry->Key == key) { - break; - } - entry = entry->Next; - } - - if (!entry) { - /* the key was not found, we can't find next entry */ - return 0; - } - - if (entry->Next) { - /* return next in linked list */ - return entry->Next->Key; - } - else { - /* look for next non-empty table slot */ - pos++; - while (pos < TABLE_SIZE) { - if (table->Table[pos]) { - return table->Table[pos]->Key; - } - pos++; - } - return 0; - } -} - - -/** - * Dump contents of hash table for debugging. - * - * \param table the hash table. - */ -void -_eglHashPrint(const _EGLHashtable *table) -{ - EGLuint i; - assert(table); - for (i = 0; i < TABLE_SIZE; i++) { - const _EGLHashentry *entry = table->Table[i]; - while (entry) { - printf("%u %p\n", entry->Key, entry->Data); - entry = entry->Next; - } - } -} - - - -/** - * Return a new, unused hash key. - */ -EGLuint -_eglHashGenKey(_EGLHashtable *table) -{ - EGLuint k; - - _eglLockMutex(table->Mutex); - k = table->MaxKey; - table->MaxKey++; - _eglUnlockMutex(table->Mutex); - return k; -} - diff --git a/src/egl/main/eglhash.h b/src/egl/main/eglhash.h deleted file mode 100644 index 1d6db9598ce..00000000000 --- a/src/egl/main/eglhash.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * \file eglhash.h - * Generic hash table. - */ - - -#ifndef EGLHASH_INCLUDED -#define EGLHASH_INCLUDED - - -/* XXX move this? */ -typedef unsigned int EGLuint; - - -typedef struct _egl_hashtable _EGLHashtable; - - -extern _EGLHashtable *_eglNewHashTable(void); - -extern void _eglDeleteHashTable(_EGLHashtable *table); - -extern void *_eglHashLookup(const _EGLHashtable *table, EGLuint key); - -extern void _eglHashInsert(_EGLHashtable *table, EGLuint key, void *data); - -extern void _eglHashRemove(_EGLHashtable *table, EGLuint key); - -extern EGLuint _eglHashFirstEntry(_EGLHashtable *table); - -extern EGLuint _eglHashNextEntry(const _EGLHashtable *table, EGLuint key); - -extern void _eglHashPrint(const _EGLHashtable *table); - -extern EGLuint _eglHashGenKey(_EGLHashtable *table); - -extern void _egltest_hash_functions(void); - - -#endif /* EGLHASH_INCLUDED */ diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c deleted file mode 100644 index 59b1d2684e3..00000000000 --- a/src/egl/main/egllog.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Logging facility for debug/info messages. - */ - - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include "egllog.h" - -#define MAXSTRING 1000 - - -/* XXX init this with an env var or something */ -static EGLint ReportingLevel = _EGL_DEBUG; - - -/** - * Log a message to stderr. - * \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG. - */ -void -_eglLog(EGLint level, const char *fmtStr, ...) -{ - va_list args; - char msg[MAXSTRING]; - const char *levelStr; - - if (level <= ReportingLevel) { - switch (level) { - case _EGL_FATAL: - levelStr = "Fatal"; - break; - case _EGL_WARNING: - levelStr = "Warning"; - break; - case _EGL_INFO: - levelStr = "Info"; - break; - case _EGL_DEBUG: - levelStr = "Debug"; - break; - default: - levelStr = ""; - } - - va_start(args, fmtStr); - vsnprintf(msg, MAXSTRING, fmtStr, args); - va_end(args); - - fprintf(stderr, "EGL %s: %s\n", levelStr, msg); - - if (level == _EGL_FATAL) { - exit(1); /* or abort()? */ - } - } -} diff --git a/src/egl/main/egllog.h b/src/egl/main/egllog.h deleted file mode 100644 index 2fa352f155d..00000000000 --- a/src/egl/main/egllog.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EGLLOG_INCLUDED -#define EGLLOG_INCLUDED - -#include "egltypedefs.h" - -#define _EGL_FATAL 0 /* unrecoverable error */ -#define _EGL_WARNING 1 /* recoverable error/problem */ -#define _EGL_INFO 2 /* just useful info */ -#define _EGL_DEBUG 3 /* useful info for debugging */ - - -extern void -_eglLog(EGLint level, const char *fmtStr, ...); - - -#endif /* EGLLOG_INCLUDED */ diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c deleted file mode 100644 index 786432234bb..00000000000 --- a/src/egl/main/eglmode.c +++ /dev/null @@ -1,431 +0,0 @@ -#include <stdio.h> -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include "egldisplay.h" -#include "egldriver.h" -#include "eglmode.h" -#include "eglglobals.h" -#include "eglscreen.h" - - -#define MIN2(A, B) (((A) < (B)) ? (A) : (B)) - - -static char * -my_strdup(const char *s) -{ - if (s) { - int l = strlen(s); - char *s2 = malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - else { - return NULL; - } -} - - -/** - * Given an EGLModeMESA handle, return the corresponding _EGLMode object - * or null if non-existant. - */ -_EGLMode * -_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode) -{ - const _EGLDisplay *disp = _eglLookupDisplay(dpy); - EGLint scrnum; - - /* loop over all screens on the display */ - for (scrnum = 0; scrnum < disp->NumScreens; scrnum++) { - const _EGLScreen *scrn = disp->Screens[scrnum]; - EGLint i; - /* search list of modes for handle */ - for (i = 0; i < scrn->NumModes; i++) { - if (scrn->Modes[i].Handle == mode) { - return scrn->Modes + i; - } - } - } - - return NULL; -} - - -/** - * Add a new mode with the given attributes (width, height, depth, refreshRate) - * to the given screen. - * Assign a new mode ID/handle to the mode as well. - * \return pointer to the new _EGLMode - */ -_EGLMode * -_eglAddNewMode(_EGLScreen *screen, EGLint width, EGLint height, - EGLint refreshRate, const char *name) -{ - EGLint n; - _EGLMode *newModes; - - assert(screen); - assert(width > 0); - assert(height > 0); - assert(refreshRate > 0); - - n = screen->NumModes; - newModes = (_EGLMode *) realloc(screen->Modes, (n+1) * sizeof(_EGLMode)); - if (newModes) { - screen->Modes = newModes; - screen->Modes[n].Handle = n + 1; - screen->Modes[n].Width = width; - screen->Modes[n].Height = height; - screen->Modes[n].RefreshRate = refreshRate; - screen->Modes[n].Optimal = EGL_FALSE; - screen->Modes[n].Interlaced = EGL_FALSE; - screen->Modes[n].Name = my_strdup(name); - screen->NumModes++; - return screen->Modes + n; - } - else { - return NULL; - } -} - - - -/** - * Parse the attrib_list to fill in the fields of the given _eglMode - * Return EGL_FALSE if any errors, EGL_TRUE otherwise. - */ -static EGLBoolean -_eglParseModeAttribs(_EGLMode *mode, const EGLint *attrib_list) -{ - EGLint i; - - /* init all attribs to EGL_DONT_CARE */ - mode->Handle = EGL_DONT_CARE; - mode->Width = EGL_DONT_CARE; - mode->Height = EGL_DONT_CARE; - mode->RefreshRate = EGL_DONT_CARE; - mode->Optimal = EGL_DONT_CARE; - mode->Interlaced = EGL_DONT_CARE; - mode->Name = NULL; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - case EGL_MODE_ID_MESA: - mode->Handle = attrib_list[++i]; - if (mode->Handle <= 0) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(handle)"); - return EGL_FALSE; - } - break; - case EGL_WIDTH: - mode->Width = attrib_list[++i]; - if (mode->Width <= 0) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(width)"); - return EGL_FALSE; - } - break; - case EGL_HEIGHT: - mode->Height = attrib_list[++i]; - if (mode->Height <= 0) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(height)"); - return EGL_FALSE; - } - break; - case EGL_REFRESH_RATE_MESA: - mode->RefreshRate = attrib_list[++i]; - if (mode->RefreshRate <= 0) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(refresh rate)"); - return EGL_FALSE; - } - break; - case EGL_INTERLACED_MESA: - mode->Interlaced = attrib_list[++i]; - if (mode->Interlaced != EGL_TRUE && mode->Interlaced != EGL_FALSE) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(interlaced)"); - return EGL_FALSE; - } - break; - case EGL_OPTIMAL_MESA: - mode->Optimal = attrib_list[++i]; - if (mode->Optimal != EGL_TRUE && mode->Optimal != EGL_FALSE) { - _eglError(EGL_BAD_PARAMETER, "eglChooseModeMESA(optimal)"); - return EGL_FALSE; - } - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglChooseModeMESA"); - return EGL_FALSE; - } - } - return EGL_TRUE; -} - - -/** - * Determine if the candidate mode's attributes are at least as good - * as the minimal mode's. - * \return EGL_TRUE if qualifies, EGL_FALSE otherwise - */ -static EGLBoolean -_eglModeQualifies(const _EGLMode *c, const _EGLMode *min) -{ - if (min->Handle != EGL_DONT_CARE && c->Handle != min->Handle) - return EGL_FALSE; - if (min->Width != EGL_DONT_CARE && c->Width < min->Width) - return EGL_FALSE; - if (min->Height != EGL_DONT_CARE && c->Height < min->Height) - return EGL_FALSE; - if (min->RefreshRate != EGL_DONT_CARE && c->RefreshRate < min->RefreshRate) - return EGL_FALSE; - if (min->Optimal != EGL_DONT_CARE && c->Optimal != min->Optimal) - return EGL_FALSE; - if (min->Interlaced != EGL_DONT_CARE && c->Interlaced != min->Interlaced) - return EGL_FALSE; - - return EGL_TRUE; -} - - -/** - * Return value of given mode attribute, or -1 if bad attrib. - */ -static EGLint -getModeAttrib(const _EGLMode *m, EGLint attrib) -{ - switch (attrib) { - case EGL_MODE_ID_MESA: - return m->Handle; - case EGL_WIDTH: - return m->Width; - case EGL_HEIGHT: - return m->Height; - case EGL_REFRESH_RATE_MESA: - return m->RefreshRate; - case EGL_OPTIMAL_MESA: - return m->Optimal; - case EGL_INTERLACED_MESA: - return m->Interlaced; - default: - return -1; - } -} - - -#define SMALLER 1 -#define LARGER 2 - -struct sort_info { - EGLint Attrib; - EGLint Order; /* SMALLER or LARGER */ -}; - -/* the order of these entries is the priority */ -static struct sort_info SortInfo[] = { - { EGL_OPTIMAL_MESA, LARGER }, - { EGL_INTERLACED_MESA, SMALLER }, - { EGL_WIDTH, LARGER }, - { EGL_HEIGHT, LARGER }, - { EGL_REFRESH_RATE_MESA, LARGER }, - { EGL_MODE_ID_MESA, SMALLER }, - { 0, 0 } -}; - - -/** - * Compare modes 'a' and 'b' and return -1 if a belongs before b, or 1 if a - * belongs after b, or 0 if they're equal. - * Used by qsort(). - */ -static int -_eglCompareModes(const void *a, const void *b) -{ - const _EGLMode *aMode = *((const _EGLMode **) a); - const _EGLMode *bMode = *((const _EGLMode **) b); - EGLint i; - - for (i = 0; SortInfo[i].Attrib; i++) { - const EGLint aVal = getModeAttrib(aMode, SortInfo[i].Attrib); - const EGLint bVal = getModeAttrib(bMode, SortInfo[i].Attrib); - if (aVal == bVal) { - /* a tie */ - continue; - } - else if (SortInfo[i].Order == SMALLER) { - return (aVal < bVal) ? -1 : 1; - } - else if (SortInfo[i].Order == LARGER) { - return (aVal > bVal) ? -1 : 1; - } - } - - /* all attributes identical */ - return 0; -} - - -/** - * Search for EGLModes which match the given attribute list. - * Called via eglChooseModeMESA API function. - */ -EGLBoolean -_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - const EGLint *attrib_list, EGLModeMESA *modes, - EGLint modes_size, EGLint *num_modes) -{ - const _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - _EGLMode **modeList, min; - EGLint i, count; - - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglChooseModeMESA"); - return EGL_FALSE; - } - - if (!_eglParseModeAttribs(&min, attrib_list)) { - /* error code will have been recorded */ - return EGL_FALSE; - } - - /* allocate array of mode pointers */ - modeList = (_EGLMode **) malloc(modes_size * sizeof(_EGLMode *)); - if (!modeList) { - _eglError(EGL_BAD_MODE_MESA, "eglChooseModeMESA(out of memory)"); - return EGL_FALSE; - } - - /* make array of pointers to qualifying modes */ - for (i = count = 0; i < scrn->NumModes && count < modes_size; i++) { - if (_eglModeQualifies(scrn->Modes + i, &min)) { - modeList[count++] = scrn->Modes + i; - } - } - - /* sort array of pointers */ - qsort(modeList, count, sizeof(_EGLMode *), _eglCompareModes); - - /* copy mode handles to output array */ - for (i = 0; i < count; i++) { - modes[i] = modeList[i]->Handle; - } - - free(modeList); - - *num_modes = count; - - return EGL_TRUE; -} - - - -/** - * Return all possible modes for the given screen. No sorting of results. - * Called via eglGetModesMESA() API function. - */ -EGLBoolean -_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes) -{ - _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglGetModesMESA"); - return EGL_FALSE; - } - - if (modes) { - EGLint i; - *num_modes = MIN2(scrn->NumModes, modes_size); - for (i = 0; i < *num_modes; i++) { - modes[i] = scrn->Modes[i].Handle; - } - } - else { - /* just return total number of supported modes */ - *num_modes = scrn->NumModes; - } - - return EGL_TRUE; -} - - -/** - * Query an attribute of a mode. - */ -EGLBoolean -_eglGetModeAttribMESA(_EGLDriver *drv, EGLDisplay dpy, - EGLModeMESA mode, EGLint attribute, EGLint *value) -{ - _EGLMode *m = _eglLookupMode(dpy, mode); - EGLint v; - - if (!m) { - _eglError(EGL_BAD_MODE_MESA, "eglGetModeAttribMESA"); - return EGL_FALSE; - } - - v = getModeAttrib(m, attribute); - if (v < 0) { - _eglError(EGL_BAD_ATTRIBUTE, "eglGetModeAttribMESA"); - return EGL_FALSE; - } - *value = v; - return EGL_TRUE; -} - - -/** - * Return human-readable string for given mode. - * This is the default function called by eglQueryModeStringMESA(). - */ -const char * -_eglQueryModeStringMESA(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode) -{ - _EGLMode *m = _eglLookupMode(dpy, mode); - if (!m) { - _eglError(EGL_BAD_MODE_MESA, "eglQueryModeStringMESA"); - return NULL; - } - return m->Name; -} - - -#if 0 -static int -_eglRand(int max) -{ - return rand() % max; -} - -void -_eglTestModeModule(void) -{ - EGLint count = 30; - _EGLMode *modes = (_EGLMode *) malloc(count * sizeof(_EGLMode)); - _EGLMode **modeList = (_EGLMode **) malloc(count * sizeof(_EGLMode*)); - EGLint i; - - for (i = 0; i < count; i++) { - modes[i].Handle = _eglRand(20); - modes[i].Width = 512 + 256 * _eglRand(2); - modes[i].Height = 512 + 256 * _eglRand(2); - modes[i].RefreshRate = 50 + 5 * _eglRand(3); - modes[i].Interlaced = _eglRand(2); - modes[i].Optimal = _eglRand(4) == 0; - modeList[i] = modes + i; - } - - /* sort array of pointers */ - qsort(modeList, count, sizeof(_EGLMode *), compareModes); - - for (i = 0; i < count; i++) { - _EGLMode *m = modeList[i]; - printf("%2d: %3d %4d x %4d @ %3d opt %d int %d\n", i, - m->Handle, m->Width, m->Height, m->RefreshRate, - m->Optimal, m->Interlaced); - } -} -#endif diff --git a/src/egl/main/eglmode.h b/src/egl/main/eglmode.h deleted file mode 100644 index e70da857595..00000000000 --- a/src/egl/main/eglmode.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef EGLMODE_INCLUDED -#define EGLMODE_INCLUDED - -#include "egltypedefs.h" - - -/** - * Data structure which corresponds to an EGLModeMESA. - */ -struct _egl_mode -{ - EGLModeMESA Handle; /* the public/opaque handle which names this mode */ - EGLint Width, Height; /* size in pixels */ - EGLint RefreshRate; /* rate * 1000.0 */ - EGLint Optimal; - EGLint Interlaced; - const char *Name; - - /* Other possible attributes */ - /* interlaced */ - /* external sync */ -}; - - -extern _EGLMode * -_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode); - - -extern _EGLMode * -_eglAddNewMode(_EGLScreen *screen, EGLint width, EGLint height, - EGLint refreshRate, const char *name); - - -extern EGLBoolean -_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - const EGLint *attrib_list, EGLModeMESA *modes, - EGLint modes_size, EGLint *num_modes); - - -extern EGLBoolean -_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes); - - -extern EGLBoolean -_eglGetModeAttribMESA(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, - EGLint attribute, EGLint *value); - - -extern const char * -_eglQueryModeStringMESA(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode); - - -#endif /* EGLMODE_INCLUDED */ diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c deleted file mode 100644 index 9c9a8377bf2..00000000000 --- a/src/egl/main/eglscreen.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Ideas for screen management extension to EGL. - * - * Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc). - * The screens' handles can be obtained with eglGetScreensMESA(). - * - * A new kind of EGLSurface is possible- one which can be directly scanned - * out on a screen. Such a surface is created with eglCreateScreenSurface(). - * - * To actually display a screen surface on a screen, the eglShowSurface() - * function is called. - */ - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include "egldisplay.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglconfig.h" -#include "eglsurface.h" -#include "eglscreen.h" - - -/** - * Return a new screen handle/ID. - * NOTE: we never reuse these! - */ -EGLScreenMESA -_eglAllocScreenHandle(void) -{ - EGLScreenMESA s = _eglGlobal.FreeScreenHandle; - _eglGlobal.FreeScreenHandle++; - return s; -} - - -/** - * Initialize an _EGLScreen object to default values. - */ -void -_eglInitScreen(_EGLScreen *screen) -{ - memset(screen, 0, sizeof(_EGLScreen)); - screen->StepX = 1; - screen->StepY = 1; -} - - -/** - * Given a public screen handle, return the internal _EGLScreen object. - */ -_EGLScreen * -_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen) -{ - EGLint i; - _EGLDisplay *display = _eglLookupDisplay(dpy); - - if (!display) - return NULL; - - for (i = 0; i < display->NumScreens; i++) { - if (display->Screens[i]->Handle == screen) - return display->Screens[i]; - } - return NULL; -} - - -/** - * Add the given _EGLScreen to the display's list of screens. - */ -void -_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen) -{ - EGLint n; - - assert(display); - assert(screen); - - screen->Handle = _eglAllocScreenHandle(); - n = display->NumScreens; - display->Screens = realloc(display->Screens, (n+1) * sizeof(_EGLScreen *)); - display->Screens[n] = screen; - display->NumScreens++; -} - - - -EGLBoolean -_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, - EGLint max_screens, EGLint *num_screens) -{ - _EGLDisplay *display = _eglLookupDisplay(dpy); - EGLint n; - - if (!display) { - _eglError(EGL_BAD_DISPLAY, "eglGetScreensMESA"); - return EGL_FALSE; - } - - if (display->NumScreens > max_screens) { - n = max_screens; - } - else { - n = display->NumScreens; - } - - if (screens) { - EGLint i; - for (i = 0; i < n; i++) - screens[i] = display->Screens[i]->Handle; - } - if (num_screens) - *num_screens = n; - - return EGL_TRUE; -} - - -/** - * Example function - drivers should do a proper implementation. - */ -EGLSurface -_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list) -{ -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return EGL_NO_SURFACE; - - if (!_eglInitSurface(drv, dpy, surf, EGL_SCREEN_BIT_MESA, - config, attrib_list)) { - free(surf); - return EGL_NO_SURFACE; - } - - _eglSaveSurface(surf); - - return surf->Handle; -#endif - return EGL_NO_SURFACE; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - * - * This is just a placeholder function; drivers will always override - * this with code that _really_ shows the surface. - */ -EGLBoolean -_eglShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, - EGLScreenMESA screen, EGLSurface surface, - EGLModeMESA m) -{ - _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - _EGLMode *mode = _eglLookupMode(dpy, m); - - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglShowSurfaceMESA"); - return EGL_FALSE; - } - if (!mode && (m != EGL_NO_MODE_MESA )) { - _eglError(EGL_BAD_MODE_MESA, "eglShowSurfaceMESA"); - return EGL_FALSE; - } - - if (surface == EGL_NO_SURFACE) { - scrn->CurrentSurface = NULL; - } - else { - _EGLSurface *surf = _eglLookupSurface(surface); - if (!surf || surf->Type != EGL_SCREEN_BIT_MESA) { - _eglError(EGL_BAD_SURFACE, "eglShowSurfaceMESA"); - return EGL_FALSE; - } - if (surf->Width < mode->Width || surf->Height < mode->Height) { - _eglError(EGL_BAD_SURFACE, - "eglShowSurfaceMESA(surface smaller than screen size)"); - return EGL_FALSE; - } - - scrn->CurrentSurface = surf; - scrn->CurrentMode = mode; - } - return EGL_TRUE; -} - - -/** - * Set a screen's current display mode. - * Note: mode = EGL_NO_MODE is valid (turns off the screen) - * - * This is just a placeholder function; drivers will always override - * this with code that _really_ sets the mode. - */ -EGLBoolean -_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLModeMESA mode) -{ - _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglScreenModeMESA"); - return EGL_FALSE; - } - - scrn->CurrentMode = _eglLookupMode(dpy, mode); - - return EGL_TRUE; -} - - -/** - * Set a screen's surface origin. - */ -EGLBoolean -_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, - EGLScreenMESA screen, EGLint x, EGLint y) -{ - _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglScreenPositionMESA"); - return EGL_FALSE; - } - - scrn->OriginX = x; - scrn->OriginY = y; - - return EGL_TRUE; -} - - -/** - * Query a screen's current surface. - */ -EGLBoolean -_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, - EGLScreenMESA screen, EGLSurface *surface) -{ - const _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - if (scrn->CurrentSurface) - *surface = scrn->CurrentSurface->Handle; - else - *surface = EGL_NO_SURFACE; - return EGL_TRUE; -} - - -/** - * Query a screen's current mode. - */ -EGLBoolean -_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLModeMESA *mode) -{ - const _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - if (scrn->CurrentMode) - *mode = scrn->CurrentMode->Handle; - else - *mode = EGL_NO_MODE_MESA; - return EGL_TRUE; -} - - -EGLBoolean -_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLint attribute, EGLint *value) -{ - const _EGLScreen *scrn = _eglLookupScreen(dpy, screen); - - if (!scrn) { - _eglError(EGL_BAD_SCREEN_MESA, "eglQueryScreenMESA"); - return EGL_FALSE; - } - - switch (attribute) { - case EGL_SCREEN_POSITION_MESA: - value[0] = scrn->OriginX; - value[1] = scrn->OriginY; - break; - case EGL_SCREEN_POSITION_GRANULARITY_MESA: - value[0] = scrn->StepX; - value[1] = scrn->StepY; - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglQueryScreenMESA"); - return EGL_FALSE; - } - - return EGL_TRUE; -} - - -/** - * Delete the modes associated with given screen. - */ -void -_eglDestroyScreenModes(_EGLScreen *scrn) -{ - EGLint i; - for (i = 0; i < scrn->NumModes; i++) { - if (scrn->Modes[i].Name) - free((char *) scrn->Modes[i].Name); /* cast away const */ - } - if (scrn->Modes) - free(scrn->Modes); - scrn->Modes = NULL; - scrn->NumModes = 0; -} - - -/** - * Default fallback routine - drivers should usually override this. - */ -void -_eglDestroyScreen(_EGLScreen *scrn) -{ - _eglDestroyScreenModes(scrn); - free(scrn); -} - diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h deleted file mode 100644 index 833439b4107..00000000000 --- a/src/egl/main/eglscreen.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef EGLSCREEN_INCLUDED -#define EGLSCREEN_INCLUDED - - -/** - * Per-screen information. - * Note that an EGL screen doesn't have a size. A screen may be set to - * one of several display modes (width/height/scanrate). The screen - * then displays a drawing surface. The drawing surface must be at least - * as large as the display mode's resolution. If it's larger, the - * OriginX and OriginY fields control what part of the surface is visible - * on the screen. - */ -struct _egl_screen -{ - EGLScreenMESA Handle; /* The public/opaque handle which names this object */ - - _EGLMode *CurrentMode; - _EGLSurface *CurrentSurface; - - EGLint OriginX, OriginY; /**< Origin of scan-out region w.r.t. surface */ - EGLint StepX, StepY; /**< Screen position/origin granularity */ - - EGLint NumModes; - _EGLMode *Modes; /**< array [NumModes] */ -}; - - -extern EGLScreenMESA -_eglAllocScreenHandle(void); - - -extern void -_eglInitScreen(_EGLScreen *screen); - - -extern _EGLScreen * -_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen); - - -extern void -_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen); - - -extern EGLBoolean -_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens); - - -extern EGLSurface -_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); - - -extern EGLBoolean -_eglShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface, EGLModeMESA mode); - - -extern EGLBoolean -_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA mode); - - -extern EGLBoolean -_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y); - - -extern EGLBoolean -_eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint attribute, EGLint *value); - - -extern EGLBoolean -_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, - EGLScreenMESA screen, EGLSurface *surface); - - -extern EGLBoolean -_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode); - - -extern EGLBoolean -_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value); - - -extern void -_eglDestroyScreenModes(_EGLScreen *scrn); - - -extern void -_eglDestroyScreen(_EGLScreen *scrn); - - -#endif /* EGLSCREEN_INCLUDED */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c deleted file mode 100644 index 874f318e966..00000000000 --- a/src/egl/main/eglsurface.c +++ /dev/null @@ -1,530 +0,0 @@ -/** - * Surface-related functions. - */ - - -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#include "eglcontext.h" -#include "eglconfig.h" -#include "eglglobals.h" -#include "eglhash.h" -#include "egllog.h" -#include "eglsurface.h" - - -/** - * Do error check on parameters and initialize the given _EGLSurface object. - * \return EGL_TRUE if no errors, EGL_FALSE otherwise. - */ -EGLBoolean -_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, - _EGLSurface *surf, EGLint type, EGLConfig config, - const EGLint *attrib_list) -{ - const char *func; - _EGLConfig *conf; - EGLint width = 0, height = 0, largest = 0; - EGLint texFormat = 0, texTarget = 0, mipmapTex = 0; - EGLint renderBuffer = EGL_BACK_BUFFER; -#ifdef EGL_VERSION_1_2 - EGLint colorspace = EGL_COLORSPACE_sRGB; - EGLint alphaFormat = EGL_ALPHA_FORMAT_NONPRE; -#endif - EGLint i; - - switch (type) { - case EGL_WINDOW_BIT: - func = "eglCreateWindowSurface"; - break; - case EGL_PIXMAP_BIT: - func = "eglCreatePixmapSurface"; - renderBuffer = EGL_SINGLE_BUFFER; - break; - case EGL_PBUFFER_BIT: - func = "eglCreatePBufferSurface"; - break; - case EGL_SCREEN_BIT_MESA: - func = "eglCreateScreenSurface"; - renderBuffer = EGL_SINGLE_BUFFER; /* XXX correct? */ - break; - default: - _eglLog(_EGL_WARNING, "Bad type in _eglInitSurface"); - return EGL_FALSE; - } - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, func); - return EGL_FALSE; - } - - /* - * Parse attribute list. Different kinds of surfaces support different - * attributes. - */ - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - case EGL_WIDTH: - if (type == EGL_PBUFFER_BIT || type == EGL_SCREEN_BIT_MESA) { - width = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_HEIGHT: - if (type == EGL_PBUFFER_BIT || type == EGL_SCREEN_BIT_MESA) { - height = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_LARGEST_PBUFFER: - if (type == EGL_PBUFFER_BIT) { - largest = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_TEXTURE_FORMAT: - if (type == EGL_PBUFFER_BIT) { - texFormat = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_TEXTURE_TARGET: - if (type == EGL_PBUFFER_BIT) { - texTarget = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_MIPMAP_TEXTURE: - if (type == EGL_PBUFFER_BIT) { - mipmapTex = attrib_list[++i]; - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; -#ifdef EGL_VERSION_1_2 - case EGL_RENDER_BUFFER: - if (type == EGL_WINDOW_BIT) { - renderBuffer = attrib_list[++i]; - if (renderBuffer != EGL_BACK_BUFFER && - renderBuffer != EGL_SINGLE_BUFFER) { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_COLORSPACE: - if (type == EGL_WINDOW_BIT || - type == EGL_PBUFFER_BIT || - type == EGL_PIXMAP_BIT) { - colorspace = attrib_list[++i]; - if (colorspace != EGL_COLORSPACE_sRGB && - colorspace != EGL_COLORSPACE_LINEAR) { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - case EGL_ALPHA_FORMAT: - if (type == EGL_WINDOW_BIT || - type == EGL_PBUFFER_BIT || - type == EGL_PIXMAP_BIT) { - alphaFormat = attrib_list[++i]; - if (alphaFormat != EGL_ALPHA_FORMAT_NONPRE && - alphaFormat != EGL_ALPHA_FORMAT_PRE) { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - } - else { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - break; - -#endif /* EGL_VERSION_1_2 */ - default: - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - } - - if (width <= 0 || height <= 0) { - _eglError(EGL_BAD_ATTRIBUTE, func); - return EGL_FALSE; - } - - memset(surf, 0, sizeof(_EGLSurface)); - surf->Config = conf; - surf->Type = type; - surf->Width = width; - surf->Height = height; - surf->TextureFormat = texFormat; - surf->TextureTarget = texTarget; - surf->MipmapTexture = mipmapTex; - surf->MipmapLevel = 0; - surf->SwapInterval = 0; -#ifdef EGL_VERSION_1_2 - surf->SwapBehavior = EGL_BUFFER_DESTROYED; /* XXX ok? */ - surf->HorizontalResolution = EGL_UNKNOWN; /* set by caller */ - surf->VerticalResolution = EGL_UNKNOWN; /* set by caller */ - surf->AspectRatio = EGL_UNKNOWN; /* set by caller */ - surf->RenderBuffer = renderBuffer; - surf->AlphaFormat = alphaFormat; - surf->Colorspace = colorspace; -#endif - - return EGL_TRUE; -} - - -void -_eglSaveSurface(_EGLSurface *surf) -{ - assert(surf); - assert(!surf->Handle); - surf->Handle = _eglHashGenKey(_eglGlobal.Contexts); - assert(surf->Handle); - _eglHashInsert(_eglGlobal.Surfaces, surf->Handle, surf); -} - - -void -_eglRemoveSurface(_EGLSurface *surf) -{ - _eglHashRemove(_eglGlobal.Surfaces, surf->Handle); -} - - -_EGLSurface * -_eglLookupSurface(EGLSurface surf) -{ - _EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces, surf); - return c; -} - - -_EGLSurface * -_eglGetCurrentSurface(EGLint readdraw) -{ - _EGLContext *ctx = _eglGetCurrentContext(); - if (ctx) { - switch (readdraw) { - case EGL_DRAW: - return ctx->DrawSurface; - case EGL_READ: - return ctx->ReadSurface; - default: - return NULL; - } - } - return NULL; -} - - -EGLBoolean -_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; - } - return EGL_TRUE; -} - - -EGLBoolean -_eglCopyBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, - NativePixmapType target) -{ - /* copy surface to native pixmap */ - /* All implementation burdon for this is in the device driver */ - return EGL_FALSE; -} - - -EGLBoolean -_eglQuerySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, - EGLint attribute, EGLint *value) -{ - _EGLSurface *surface = _eglLookupSurface(surf); - if (surface == NULL) { - _eglError(EGL_BAD_SURFACE, "eglQuerySurface"); - return EGL_FALSE; - } - switch (attribute) { - case EGL_WIDTH: - *value = surface->Width; - return EGL_TRUE; - case EGL_HEIGHT: - *value = surface->Height; - return EGL_TRUE; - case EGL_CONFIG_ID: - *value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID); - return EGL_TRUE; - /*XXX case EGL_LARGEST_PBUFFER:*/ - case EGL_SURFACE_TYPE: - *value = surface->Type; - return EGL_TRUE; -#ifdef EGL_VERSION_1_1 - case EGL_TEXTURE_FORMAT: - /* texture attributes: only for pbuffers, no error otherwise */ - if (surface->Type == EGL_PBUFFER_BIT) - *value = surface->TextureFormat; - return EGL_TRUE; - case EGL_TEXTURE_TARGET: - if (surface->Type == EGL_PBUFFER_BIT) - *value = surface->TextureTarget; - return EGL_TRUE; - case EGL_MIPMAP_TEXTURE: - if (surface->Type == EGL_PBUFFER_BIT) - *value = surface->MipmapTexture; - return EGL_TRUE; - case EGL_MIPMAP_LEVEL: - if (surface->Type == EGL_PBUFFER_BIT) - *value = surface->MipmapLevel; - return EGL_TRUE; -#endif /* EGL_VERSION_1_1 */ -#ifdef EGL_VERSION_1_2 - case EGL_SWAP_BEHAVIOR: - *value = surface->SwapBehavior; - return EGL_TRUE; - case EGL_RENDER_BUFFER: - *value = surface->RenderBuffer; - return EGL_TRUE; - case EGL_PIXEL_ASPECT_RATIO: - *value = surface->AspectRatio; - return EGL_TRUE; - case EGL_HORIZONTAL_RESOLUTION: - *value = surface->HorizontalResolution; - return EGL_TRUE; - case EGL_VERTICAL_RESOLUTION: - *value = surface->VerticalResolution; - return EGL_TRUE; - case EGL_ALPHA_FORMAT: - *value = surface->AlphaFormat; - return EGL_TRUE; - case EGL_COLORSPACE: - *value = surface->Colorspace; - return EGL_TRUE; -#endif /* EGL_VERSION_1_2 */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); - return EGL_FALSE; - } -} - - -/** - * Example function - drivers should do a proper implementation. - */ -EGLSurface -_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - NativeWindowType window, const EGLint *attrib_list) -{ -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return EGL_NO_SURFACE; - - if (!_eglInitSurface(drv, dpy, surf, EGL_WINDOW_BIT, config, attrib_list)) { - free(surf); - return EGL_NO_SURFACE; - } - - _eglSaveSurface(surf); - - return surf->Handle; -#endif - return EGL_NO_SURFACE; -} - - -/** - * Example function - drivers should do a proper implementation. - */ -EGLSurface -_eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - NativePixmapType pixmap, const EGLint *attrib_list) -{ -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return EGL_NO_SURFACE; - - if (!_eglInitSurface(drv, dpy, surf, EGL_PIXMAP_BIT, config, attrib_list)) { - free(surf); - return EGL_NO_SURFACE; - } - - _eglSaveSurface(surf); - - return surf->Handle; -#endif - return EGL_NO_SURFACE; -} - - -/** - * Example function - drivers should do a proper implementation. - */ -EGLSurface -_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list) -{ -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return EGL_NO_SURFACE; - - if (!_eglInitSurface(drv, dpy, surf, EGL_PBUFFER_BIT, config, attrib_list)) { - free(surf); - return EGL_NO_SURFACE; - } - - _eglSaveSurface(surf); - - return surf->Handle; -#endif - return EGL_NO_SURFACE; -} - - -/** - * Default fallback routine - drivers should usually override this. - */ -EGLBoolean -_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) -{ - _EGLSurface *surf = _eglLookupSurface(surface); - if (surf) { - _eglHashRemove(_eglGlobal.Surfaces, surface); - if (surf->IsBound) { - surf->DeletePending = EGL_TRUE; - } - else { - free(surf); - } - return EGL_TRUE; - } - else { - _eglError(EGL_BAD_SURFACE, "eglDestroySurface"); - return EGL_FALSE; - } -} - - -/** - * Default fallback routine - drivers might override this. - */ -EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surf, EGLint attribute, EGLint value) -{ - _EGLSurface *surface = _eglLookupSurface(surf); - - if (surface == NULL) { - _eglError(EGL_BAD_SURFACE, "eglSurfaceAttrib"); - return EGL_FALSE; - } - - switch (attribute) { - case EGL_MIPMAP_LEVEL: - surface->MipmapLevel = value; - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglSurfaceAttrib"); - return EGL_FALSE; - } - return EGL_TRUE; -} - - -EGLBoolean -_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - /* XXX unfinished */ - return EGL_FALSE; -} - - -EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer) -{ - /* XXX unfinished */ - return EGL_FALSE; -} - - -EGLBoolean -_eglSwapInterval(_EGLDriver *drv, EGLDisplay dpy, EGLint interval) -{ - _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); - if (surf == NULL) { - _eglError(EGL_BAD_SURFACE, "eglSwapInterval"); - return EGL_FALSE; - } - surf->SwapInterval = interval; - return EGL_TRUE; -} - - -#ifdef EGL_VERSION_1_2 - -/** - * Example function - drivers should do a proper implementation. - */ -EGLSurface -_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy, - EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list) -{ - if (buftype != EGL_OPENVG_IMAGE) { - _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferFromClientBuffer"); - return EGL_NO_SURFACE; - } - - return EGL_NO_SURFACE; -} - -#endif /* EGL_VERSION_1_2 */ diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h deleted file mode 100644 index 79abeca0b2a..00000000000 --- a/src/egl/main/eglsurface.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef EGLSURFACE_INCLUDED -#define EGLSURFACE_INCLUDED - - -#include "egltypedefs.h" - - -/** - * "Base" class for device driver surfaces. - */ -struct _egl_surface -{ - EGLSurface Handle; /* The public/opaque handle which names this object */ - _EGLConfig *Config; - - /* May need reference counting here */ - EGLBoolean IsBound; - EGLBoolean DeletePending; - - EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ - EGLint Width, Height; - EGLint TextureFormat, TextureTarget; - EGLint MipmapTexture, MipmapLevel; - EGLint SwapInterval; - - /* If type == EGL_SCREEN_BIT: */ - EGLint VisibleRefCount; /* number of screens I'm displayed on */ - -#ifdef EGL_VERSION_1_2 - EGLint SwapBehavior; /* one of EGL_BUFFER_PRESERVED/DESTROYED */ - EGLint HorizontalResolution, VerticalResolution; - EGLint AspectRatio; - EGLint RenderBuffer; /* EGL_BACK_BUFFER or EGL_SINGLE_BUFFER */ - EGLint AlphaFormat; /* EGL_ALPHA_FORMAT_NONPRE or EGL_ALPHA_FORMAT_PRE */ - EGLint Colorspace; /* EGL_COLORSPACE_sRGB or EGL_COLORSPACE_LINEAR */ -#endif /* EGL_VERSION_1_2 */ -}; - - -extern EGLBoolean -_eglInitSurface(_EGLDriver *drv, EGLDisplay dpy, - _EGLSurface *surf, EGLint type, EGLConfig config, - const EGLint *attrib_list); - - -extern void -_eglSaveSurface(_EGLSurface *surf); - - -extern void -_eglRemoveSurface(_EGLSurface *surf); - - -extern _EGLSurface * -_eglLookupSurface(EGLSurface surf); - - -extern _EGLSurface * -_eglGetCurrentSurface(EGLint readdraw); - - -extern EGLBoolean -_eglSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw); - - -extern EGLBoolean -_eglCopyBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, NativePixmapType target); - - -extern EGLBoolean -_eglQuerySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); - - -extern EGLSurface -_eglCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list); - - -extern EGLSurface -_eglCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list); - - -extern EGLSurface -_eglCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); - - -extern EGLBoolean -_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface); - - -extern EGLBoolean -_eglSurfaceAttrib(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); - - -extern EGLBoolean -_eglBindTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer); - - -extern EGLBoolean -_eglReleaseTexImage(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface, EGLint buffer); - - -extern EGLBoolean -_eglSwapInterval(_EGLDriver *drv, EGLDisplay dpy, EGLint interval); - - -#ifdef EGL_VERSION_1_2 - -extern EGLSurface -_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy, - EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list); - -#endif /* EGL_VERSION_1_2 */ - - - -#endif /* EGLSURFACE_INCLUDED */ diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h deleted file mode 100644 index fa8cb496f8d..00000000000 --- a/src/egl/main/egltypedefs.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef EGLTYPEDEFS_INCLUDED -#define EGLTYPEDEFS_INCLUDED - - -#include <GLES/egl.h> - - -typedef struct _egl_api _EGLAPI; - -typedef struct _egl_config _EGLConfig; - -typedef struct _egl_context _EGLContext; - -typedef struct _egl_display _EGLDisplay; - -typedef struct _egl_driver _EGLDriver; - -typedef struct _egl_extensions _EGLExtensions; - -typedef struct _egl_mode _EGLMode; - -typedef struct _egl_screen _EGLScreen; - -typedef struct _egl_surface _EGLSurface; - -typedef struct _egl_thread_info _EGLThreadInfo; - - -typedef void (*_EGLProc)(); - -typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy); - - -#endif /* EGLTYPEDEFS_INCLUDED */ |