diff options
Diffstat (limited to 'src/egl/main')
-rw-r--r-- | src/egl/main/Makefile | 23 | ||||
-rw-r--r-- | src/egl/main/SConscript | 5 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 23 | ||||
-rw-r--r-- | src/egl/main/egldisplay.c | 10 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 20 | ||||
-rw-r--r-- | src/egl/main/egldriver.c | 53 | ||||
-rw-r--r-- | src/egl/main/egldriver.h | 5 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 1 | ||||
-rw-r--r-- | src/egl/main/eglstring.h | 2 |
9 files changed, 107 insertions, 35 deletions
diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 82fd855b1d..be27d9450f 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -7,7 +7,7 @@ include $(TOP)/configs/current EGL_MAJOR = 1 EGL_MINOR = 0 -INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS) +INCLUDE_DIRS = -I$(TOP)/include HEADERS = \ eglcompiler.h \ @@ -49,12 +49,25 @@ OBJECTS = $(SOURCES:.c=.o) # use dl*() to load drivers -LOCAL_CFLAGS = -D_EGL_PLATFORM_POSIX=1 - -EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) +LOCAL_CFLAGS = -D_EGL_OS_UNIX=1 + +EGL_DEFAULT_PLATFORM = $(firstword $(EGL_PLATFORMS)) + +# translate --with-egl-platforms to _EGLPlatformType +EGL_NATIVE_PLATFORM=_EGL_INVALID_PLATFORM +ifeq ($(firstword $(EGL_PLATFORMS)),x11) +EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11 +endif +ifeq ($(firstword $(EGL_PLATFORMS)),kms) +EGL_NATIVE_PLATFORM=_EGL_PLATFORM_DRM +endif +ifeq ($(firstword $(EGL_PLATFORMS)),fbdev) +EGL_NATIVE_PLATFORM=_EGL_PLATFORM_FBDEV +endif LOCAL_CFLAGS += \ - -D_EGL_DEFAULT_DISPLAY=\"$(EGL_DEFAULT_DISPLAY)\" \ + -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ + -D_EGL_DEFAULT_PLATFORM=\"$(EGL_DEFAULT_PLATFORM)\" \ -D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" .c.o: diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index f3fe9966b3..fad0671f38 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -9,9 +9,10 @@ if env['platform'] != 'winddk': env = env.Clone() env.Append(CPPDEFINES = [ - '_EGL_DEFAULT_DISPLAY=\\"gdi\\"', + '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_WINDOWS', + '_EGL_DEFAULT_PLATFORM=\\"gdi\\"', '_EGL_DRIVER_SEARCH_DIR=\\"\\"', - '_EGL_PLATFORM_WINDOWS', + '_EGL_OS_WINDOWS', 'KHRONOS_DLL_EXPORTS', ]) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 9912043e06..1ec1486d3f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -250,7 +250,8 @@ _eglUnlockDisplay(_EGLDisplay *dpy) EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType nativeDisplay) { - _EGLDisplay *dpy = _eglFindDisplay(nativeDisplay); + _EGLPlatformType plat = _eglGetNativePlatform(); + _EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay); return _eglGetDisplayHandle(dpy); } @@ -491,6 +492,8 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLSurface ret; _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + if (disp->Platform != _eglGetNativePlatform()) + RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list); ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE; @@ -510,6 +513,8 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLSurface ret; _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); + if (disp->Platform != _eglGetNativePlatform()) + RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list); ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE; @@ -667,6 +672,8 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + if (disp->Platform != _eglGetNativePlatform()) + RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE); ret = drv->API.CopyBuffers(drv, disp, surf, target); RETURN_EGL_EVAL(disp, ret); @@ -836,6 +843,9 @@ eglGetProcAddress(const char *procname) { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA }, { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA }, #endif /* EGL_MESA_screen_surface */ +#ifdef EGL_MESA_drm_display + { "eglGetDRMDisplayMESA", (_EGLProc) eglGetDRMDisplayMESA }, +#endif #ifdef EGL_KHR_image_base { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, { "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, @@ -1098,6 +1108,17 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode) #endif /* EGL_MESA_screen_surface */ +#ifdef EGL_MESA_drm_display + +EGLDisplay EGLAPIENTRY +eglGetDRMDisplayMESA(int fd) +{ + _EGLDisplay *dpy = _eglFindDisplay(_EGL_PLATFORM_DRM, (void *) fd); + return _eglGetDisplayHandle(dpy); +} + +#endif /* EGL_MESA_drm_display */ + /** ** EGL 1.2 **/ diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 5dc5fd9719..d666bdabe0 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -49,16 +49,19 @@ _eglFiniDisplay(void) * new one. */ _EGLDisplay * -_eglFindDisplay(EGLNativeDisplayType nativeDisplay) +_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) { _EGLDisplay *dpy; + if (plat == _EGL_INVALID_PLATFORM) + return NULL; + _eglLockMutex(_eglGlobal.Mutex); /* search the display list first */ dpy = _eglGlobal.DisplayList; while (dpy) { - if (dpy->NativeDisplay == nativeDisplay) + if (dpy->Platform == plat && dpy->PlatformDisplay == plat_dpy) break; dpy = dpy->Next; } @@ -68,7 +71,8 @@ _eglFindDisplay(EGLNativeDisplayType nativeDisplay) dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { _eglInitMutex(&dpy->Mutex); - dpy->NativeDisplay = nativeDisplay; + dpy->Platform = plat; + dpy->PlatformDisplay = plat_dpy; /* add to the display list */ dpy->Next = _eglGlobal.DisplayList; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 42e305f91a..0b325f7cf0 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -7,6 +7,18 @@ #include "eglmutex.h" +enum _egl_platform_type { + _EGL_PLATFORM_WINDOWS, + _EGL_PLATFORM_X11, + _EGL_PLATFORM_DRM, + _EGL_PLATFORM_FBDEV, + + _EGL_NUM_PLATFORMS, + _EGL_INVALID_PLATFORM = -1 +}; +typedef enum _egl_platform_type _EGLPlatformType; + + enum _egl_resource_type { _EGL_RESOURCE_CONTEXT, _EGL_RESOURCE_SURFACE, @@ -39,6 +51,7 @@ struct _egl_extensions { EGLBoolean MESA_screen_surface; EGLBoolean MESA_copy_context; + EGLBoolean MESA_drm_display; EGLBoolean KHR_image_base; EGLBoolean KHR_image_pixmap; EGLBoolean KHR_vg_parent_image; @@ -53,14 +66,15 @@ struct _egl_extensions }; -struct _egl_display +struct _egl_display { /* used to link displays */ _EGLDisplay *Next; _EGLMutex Mutex; - EGLNativeDisplayType NativeDisplay; + _EGLPlatformType Platform; + void *PlatformDisplay; EGLBoolean Initialized; /**< True if the display is initialized */ _EGLDriver *Driver; @@ -92,7 +106,7 @@ _eglFiniDisplay(void); extern _EGLDisplay * -_eglFindDisplay(EGLNativeDisplayType displayName); +_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy); PUBLIC void diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 631a8710ac..db7b4a7471 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -23,7 +23,7 @@ #include "eglsurface.h" #include "eglimage.h" -#if defined(_EGL_PLATFORM_POSIX) +#if defined(_EGL_OS_UNIX) #include <dlfcn.h> #include <sys/types.h> #include <dirent.h> @@ -34,7 +34,7 @@ /** * Wrappers for dlopen/dlclose() */ -#if defined(_EGL_PLATFORM_WINDOWS) +#if defined(_EGL_OS_WINDOWS) /* XXX Need to decide how to do dynamic name lookup on Windows */ @@ -64,7 +64,7 @@ library_suffix(void) } -#elif defined(_EGL_PLATFORM_POSIX) +#elif defined(_EGL_OS_UNIX) static const char *DefaultDriverNames[] = { @@ -119,11 +119,11 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath); lib = open_library(driverPath); -#if defined(_EGL_PLATFORM_WINDOWS) +#if defined(_EGL_OS_WINDOWS) /* XXX untested */ if (lib) mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); -#elif defined(_EGL_PLATFORM_POSIX) +#elif defined(_EGL_OS_UNIX) if (lib) { union { _EGLMain_t func; @@ -301,7 +301,7 @@ _eglLoaderFile(const char *dir, size_t len, void *loader_data) static EGLBoolean _eglLoaderPattern(const char *dir, size_t len, void *loader_data) { -#if defined(_EGL_PLATFORM_POSIX) +#if defined(_EGL_OS_UNIX) const char *prefix, *suffix; size_t prefix_len, suffix_len; DIR *dirp; @@ -352,7 +352,7 @@ _eglLoaderPattern(const char *dir, size_t len, void *loader_data) closedir(dirp); return EGL_TRUE; -#else /* _EGL_PLATFORM_POSIX */ +#else /* _EGL_OS_UNIX */ /* stop immediately */ return EGL_FALSE; #endif @@ -397,20 +397,20 @@ _eglGetSearchPath(void) { static const char *search_path; -#if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS) +#if defined(_EGL_OS_UNIX) || defined(_EGL_OS_WINDOWS) if (!search_path) { static char buffer[1024]; const char *p; int ret; p = getenv("EGL_DRIVERS_PATH"); -#if defined(_EGL_PLATFORM_POSIX) +#if defined(_EGL_OS_UNIX) if (p && (geteuid() != getuid() || getegid() != getgid())) { _eglLog(_EGL_DEBUG, "ignore EGL_DRIVERS_PATH for setuid/setgid binaries"); p = NULL; } -#endif /* _EGL_PLATFORM_POSIX */ +#endif /* _EGL_OS_UNIX */ if (p) { ret = _eglsnprintf(buffer, sizeof(buffer), @@ -441,7 +441,7 @@ _eglPreloadUserDriver(void) char *env; env = getenv("EGL_DRIVER"); -#if defined(_EGL_PLATFORM_POSIX) +#if defined(_EGL_OS_UNIX) if (env && strchr(env, '/')) { search_path = ""; if ((geteuid() != getuid() || getegid() != getgid())) { @@ -450,7 +450,7 @@ _eglPreloadUserDriver(void) env = NULL; } } -#endif /* _EGL_PLATFORM_POSIX */ +#endif /* _EGL_OS_UNIX */ if (!env) return EGL_FALSE; @@ -464,24 +464,27 @@ _eglPreloadUserDriver(void) /** - * Preload display drivers. + * Preload platform drivers. * - * Display drivers are a set of drivers that support a certain display system. - * The display system may be specified by EGL_DISPLAY. + * Platform drivers are a set of drivers that support a certain window system. + * The window system may be specified by EGL_PLATFORM. * * FIXME This makes libEGL a memory hog if an user driver is not specified and - * there are many display drivers. + * there are many platform drivers. */ static EGLBoolean -_eglPreloadDisplayDrivers(void) +_eglPreloadPlatformDrivers(void) { const char *dpy; char prefix[32]; int ret; - dpy = getenv("EGL_DISPLAY"); + dpy = getenv("EGL_PLATFORM"); + /* try deprecated env variable */ if (!dpy || !dpy[0]) - dpy = _EGL_DEFAULT_DISPLAY; + dpy = getenv("EGL_DISPLAY"); + if (!dpy || !dpy[0]) + dpy = _EGL_DEFAULT_PLATFORM; if (!dpy || !dpy[0]) return EGL_FALSE; @@ -515,7 +518,7 @@ _eglPreloadDrivers(void) } loaded = (_eglPreloadUserDriver() || - _eglPreloadDisplayDrivers()); + _eglPreloadPlatformDrivers()); _eglUnlockMutex(_eglGlobal.Mutex); @@ -578,6 +581,16 @@ _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor) /** + * Return the native platform. It is the platform of the EGL native types. + */ +_EGLPlatformType +_eglGetNativePlatform(void) +{ + return _EGL_NATIVE_PLATFORM; +} + + +/** * Plug all the available fallback routines into the given driver's * dispatch table. */ diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 8b34c43b92..6a52374764 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -3,6 +3,7 @@ #include "egltypedefs.h" +#include "egldisplay.h" #include "eglapi.h" @@ -88,6 +89,10 @@ extern _EGLDriver * _eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor); +extern _EGLPlatformType +_eglGetNativePlatform(void); + + PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 4652969659..281138c752 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -84,6 +84,7 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(MESA_screen_surface); _EGL_CHECK_EXTENSION(MESA_copy_context); + _EGL_CHECK_EXTENSION(MESA_drm_display); _EGL_CHECK_EXTENSION(KHR_image_base); _EGL_CHECK_EXTENSION(KHR_image_pixmap); diff --git a/src/egl/main/eglstring.h b/src/egl/main/eglstring.h index bebb758dd8..f1d559b24a 100644 --- a/src/egl/main/eglstring.h +++ b/src/egl/main/eglstring.h @@ -3,7 +3,7 @@ #include <string.h> -#ifdef _EGL_PLATFORM_WINDOWS +#ifdef _EGL_OS_WINDOWS #define _eglstrcasecmp _stricmp #define _eglsnprintf _snprintf #else |