struct dri2_egl_display *dri2_dpy;
unsigned int api_mask;
+ if (disp->Platform != _EGL_PLATFORM_X11)
+ return EGL_FALSE;
+
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
disp->DriverData = (void *) dri2_dpy;
- if (disp->NativeDisplay == NULL) {
+ if (disp->PlatformDisplay == NULL) {
dri2_dpy->conn = xcb_connect(0, 0);
} else {
- dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
+ dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay);
}
if (xcb_connection_has_error(dri2_dpy->conn)) {
cleanup_driver:
dlclose(dri2_dpy->driver);
cleanup_conn:
- if (disp->NativeDisplay == NULL)
+ if (disp->PlatformDisplay == NULL)
xcb_disconnect(dri2_dpy->conn);
cleanup_dpy:
free(dri2_dpy);
dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen);
close(dri2_dpy->fd);
dlclose(dri2_dpy->driver);
- if (disp->NativeDisplay == NULL)
+ if (disp->PlatformDisplay == NULL)
xcb_disconnect(dri2_dpy->conn);
free(dri2_dpy);
disp->DriverData = NULL;
{
struct GLX_egl_display *GLX_dpy;
+ if (disp->Platform != _EGL_PLATFORM_X11)
+ return EGL_FALSE;
+
GLX_dpy = CALLOC_STRUCT(GLX_egl_display);
if (!GLX_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
- GLX_dpy->dpy = (Display *) disp->NativeDisplay;
+ GLX_dpy->dpy = (Display *) disp->PlatformDisplay;
if (!GLX_dpy->dpy) {
GLX_dpy->dpy = XOpenDisplay(NULL);
if (!GLX_dpy->dpy) {
if (!glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min)) {
_eglLog(_EGL_WARNING, "GLX: glXQueryVersion failed");
- if (!disp->NativeDisplay)
+ if (!disp->PlatformDisplay)
XCloseDisplay(GLX_dpy->dpy);
free(GLX_dpy);
return EGL_FALSE;
create_configs(disp, GLX_dpy, DefaultScreen(GLX_dpy->dpy));
if (!disp->NumConfigs) {
_eglLog(_EGL_WARNING, "GLX: failed to create any config");
- if (!disp->NativeDisplay)
+ if (!disp->PlatformDisplay)
XCloseDisplay(GLX_dpy->dpy);
free(GLX_dpy);
return EGL_FALSE;
if (GLX_dpy->fbconfigs)
XFree(GLX_dpy->fbconfigs);
- if (!disp->NativeDisplay)
+ if (!disp->PlatformDisplay)
XCloseDisplay(GLX_dpy->dpy);
free(GLX_dpy);
static void
destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
{
+ struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp);
struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf);
if (GLX_surf->destroy)
- GLX_surf->destroy(disp->NativeDisplay, GLX_surf->glx_drawable);
+ GLX_surf->destroy(GLX_dpy->dpy, GLX_surf->glx_drawable);
free(GLX_surf);
}
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_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \
-D_EGL_DEFAULT_PLATFORM=\"$(EGL_DEFAULT_PLATFORM)\" \
-D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\"
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_OS_WINDOWS',
'KHRONOS_DLL_EXPORTS',
EGLDisplay EGLAPIENTRY
eglGetDisplay(EGLNativeDisplayType nativeDisplay)
{
- _EGLDisplay *dpy = _eglFindDisplay(nativeDisplay);
+ _EGLPlatformType plat = _eglGetNativePlatform();
+ _EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay);
return _eglGetDisplayHandle(dpy);
}
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;
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;
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);
* 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;
}
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;
#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,
};
-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;
extern _EGLDisplay *
-_eglFindDisplay(EGLNativeDisplayType displayName);
+_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
PUBLIC void
}
+/**
+ * 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.
#include "egltypedefs.h"
+#include "egldisplay.h"
#include "eglapi.h"
_eglLoadDefaultDriver(EGLDisplay dpy, EGLint *major, EGLint *minor);
+extern _EGLPlatformType
+_eglGetNativePlatform(void);
+
+
PUBLIC void
_eglInitDriverFallbacks(_EGLDriver *drv);
struct native_probe *nprobe;
nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key);
- if (!nprobe || nprobe->display != dpy->NativeDisplay) {
+ if (!nprobe || nprobe->display != dpy->PlatformDisplay) {
if (nprobe)
nprobe->destroy(nprobe);
- nprobe = native_create_probe(dpy->NativeDisplay);
+ nprobe = native_create_probe(dpy->PlatformDisplay);
_eglSetProbeCache(gdrv->probe_key, (void *) nprobe);
}
struct native_probe *nprobe;
nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key);
- if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) {
+ if (nprobe && (!dpy || nprobe->display == dpy->PlatformDisplay)) {
nprobe->destroy(nprobe);
_eglSetProbeCache(gdrv->probe_key, NULL);
}
}
dpy->DriverData = gdpy;
- gdpy->native = native_create_display(dpy->NativeDisplay,
+ gdpy->native = native_create_display(dpy->PlatformDisplay,
&egl_g3d_native_event_handler);
if (!gdpy->native) {
_eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)");
native_get_name(void);
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *handler);
+native_create_display(void *dpy, struct native_event_handler *handler);
#endif /* _NATIVE_H_ */
*/
struct native_probe {
int magic;
- EGLNativeDisplayType display;
+ void *display;
void *data;
void (*destroy)(struct native_probe *nprobe);
* same display.
*/
struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy);
+native_create_probe(void *dpy);
/**
* Probe the probe object.
}
struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy)
+native_create_probe(void *dpy)
{
return NULL;
}
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler)
+native_create_display(void *dpy, struct native_event_handler *event_handler)
{
struct native_display *ndpy;
int fd;
/* well, this makes fd 0 being ignored */
- if (dpy == EGL_DEFAULT_DISPLAY) {
+ if (!dpy) {
fd = open("/dev/fb0", O_RDWR);
}
else {
- fd = dup((int) pointer_to_intptr((void *) dpy));
+ fd = dup((int) pointer_to_intptr(dpy));
}
if (fd < 0)
return NULL;
}
struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy)
+native_create_probe(void *dpy)
{
return NULL;
}
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler)
+native_create_display(void *dpy, struct native_event_handler *event_handler)
{
struct sw_winsys *winsys;
struct pipe_screen *screen;
}
struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy)
+native_create_probe(void *dpy)
{
return NULL;
}
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler)
+native_create_display(void *dpy, struct native_event_handler *event_handler)
{
struct native_display *ndpy = NULL;
int fd;
}
struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
+x11_create_dri2_display(Display *dpy,
struct native_event_handler *event_handler,
struct drm_api *api)
{
}
struct native_probe *
-native_create_probe(EGLNativeDisplayType dpy)
+native_create_probe(void *dpy)
{
struct native_probe *nprobe;
struct x11_screen *xscr;
}
struct native_display *
-native_create_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler)
+native_create_display(void *dpy, struct native_event_handler *event_handler)
{
struct native_display *ndpy = NULL;
boolean force_sw;
force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
if (api && !force_sw) {
- ndpy = x11_create_dri2_display(dpy, event_handler, api);
+ ndpy = x11_create_dri2_display((Display *) dpy, event_handler, api);
}
if (!ndpy) {
EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
_eglLog(level, "use software fallback");
- ndpy = x11_create_ximage_display(dpy, event_handler);
+ ndpy = x11_create_ximage_display((Display *) dpy, event_handler);
}
return ndpy;
#include "common/native.h"
struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
+x11_create_ximage_display(Display *dpy,
struct native_event_handler *event_handler);
struct native_display *
-x11_create_dri2_display(EGLNativeDisplayType dpy,
+x11_create_dri2_display(Display *dpy,
struct native_event_handler *event_handler,
struct drm_api *api);
}
struct native_display *
-x11_create_ximage_display(EGLNativeDisplayType dpy,
+x11_create_ximage_display(Display *dpy,
struct native_event_handler *event_handler)
{
struct ximage_display *xdpy;