summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri/egldri.c2
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c434
-rw-r--r--src/egl/main/eglapi.c286
-rw-r--r--src/egl/main/eglcompiler.h5
-rw-r--r--src/egl/main/eglconfig.c8
-rw-r--r--src/egl/main/eglconfig.h17
-rw-r--r--src/egl/main/egldisplay.c6
-rw-r--r--src/egl/main/egldisplay.h26
-rw-r--r--src/egl/main/egldriver.c8
-rw-r--r--src/egl/main/egltypedefs.h2
10 files changed, 504 insertions, 290 deletions
diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c
index ca6821dad06..6a8bf89985b 100644
--- a/src/egl/drivers/dri/egldri.c
+++ b/src/egl/drivers/dri/egldri.c
@@ -812,7 +812,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable,
return GL_FALSE;
}
- cliprect = (drm_clip_rect_t*) _mesa_malloc(sizeof(drm_clip_rect_t));
+ cliprect = (drm_clip_rect_t*) malloc(sizeof(drm_clip_rect_t));
cliprect->x1 = drawable->x;
cliprect->y1 = drawable->y;
cliprect->x2 = drawable->x + drawable->w;
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 5d36c49b2c9..15b3529cd29 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -42,7 +42,6 @@
#include <X11/Xlib-xcb.h>
#include <glapi/glapi.h>
-#include "eglconfigutil.h"
#include "eglconfig.h"
#include "eglcontext.h"
#include "egldisplay.h"
@@ -50,6 +49,7 @@
#include "eglcurrent.h"
#include "egllog.h"
#include "eglsurface.h"
+#include "eglimage.h"
struct dri2_egl_driver
{
@@ -62,15 +62,21 @@ struct dri2_egl_display
int dri2_major;
int dri2_minor;
__DRIscreen *dri_screen;
+ const __DRIconfig **driver_configs;
void *driver;
__DRIcoreExtension *core;
__DRIdri2Extension *dri2;
__DRI2flushExtension *flush;
__DRItexBufferExtension *tex_buffer;
+ __DRIimageExtension *image;
int fd;
+ char *device_name;
+ char *driver_name;
+
__DRIdri2LoaderExtension loader_extension;
- const __DRIextension *extensions[2];
+ __DRIimageLookupExtension image_lookup_extension;
+ const __DRIextension *extensions[3];
};
struct dri2_egl_context
@@ -93,12 +99,19 @@ struct dri2_egl_surface
struct dri2_egl_config
{
- _EGLConfig base;
+ _EGLConfig base;
const __DRIconfig *dri_config;
};
+struct dri2_egl_image
+{
+ _EGLImage base;
+ __DRIimage *dri_image;
+};
+
/* standard typecasts */
_EGL_DRIVER_STANDARD_TYPECASTS(dri2_egl)
+_EGL_DRIVER_TYPECAST(dri2_egl_image, _EGLImage, obj)
EGLint dri2_to_egl_attribute_map[] = {
0,
@@ -346,6 +359,25 @@ dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
#endif
}
+static __DRIimage *
+dri2_lookup_egl_image(__DRIcontext *context, void *image, void *data)
+{
+ struct dri2_egl_context *dri2_ctx = data;
+ _EGLDisplay *disp = dri2_ctx->base.Resource.Display;
+ struct dri2_egl_image *dri2_img;
+ _EGLImage *img;
+
+ img = _eglLookupImage(image, disp);
+ if (img == NULL) {
+ _eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image");
+ return NULL;
+ }
+
+ dri2_img = dri2_egl_image(image);
+
+ return dri2_img->dri_image;
+}
+
static __DRIbuffer *
dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
int *width, int *height,
@@ -383,9 +415,9 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable,
}
#ifdef GLX_USE_TLS
-static const char dri_driver_format[] = "%.*s/tls/%.*s_dri.so";
+static const char dri_driver_format[] = "%.*s/tls/%s_dri.so";
#else
-static const char dri_driver_format[] = "%.*s/%.*s_dri.so";
+static const char dri_driver_format[] = "%.*s/%s_dri.so";
#endif
static const char dri_driver_path[] = DEFAULT_DRIVER_DIR;
@@ -405,6 +437,7 @@ static struct dri2_extension_match dri2_driver_extensions[] = {
static struct dri2_extension_match dri2_core_extensions[] = {
{ __DRI2_FLUSH, 1, offsetof(struct dri2_egl_display, flush) },
{ __DRI_TEX_BUFFER, 2, offsetof(struct dri2_egl_display, tex_buffer) },
+ { __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
{ NULL }
};
@@ -441,45 +474,32 @@ dri2_bind_extensions(struct dri2_egl_display *dri2_dpy,
return ret;
}
-/**
- * Called via eglInitialize(), GLX_drv->API.Initialize().
- */
+static char *
+dri2_strndup(const char *s, int length)
+{
+ char *d;
+
+ d = malloc(length + 1);
+ if (d == NULL)
+ return NULL;
+
+ memcpy(d, s, length);
+ d[length] = '\0';
+
+ return d;
+}
+
static EGLBoolean
-dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
- EGLint *major, EGLint *minor)
+dri2_connect(struct dri2_egl_display *dri2_dpy)
{
- const __DRIextension **extensions;
- const __DRIconfig **driver_configs;
- struct dri2_egl_display *dri2_dpy;
- char path[PATH_MAX], *search_paths, *p, *next, *end;
xcb_xfixes_query_version_reply_t *xfixes_query;
xcb_xfixes_query_version_cookie_t xfixes_query_cookie;
xcb_dri2_query_version_reply_t *dri2_query;
xcb_dri2_query_version_cookie_t dri2_query_cookie;
xcb_dri2_connect_reply_t *connect;
xcb_dri2_connect_cookie_t connect_cookie;
- xcb_dri2_authenticate_reply_t *authenticate;
- xcb_dri2_authenticate_cookie_t authenticate_cookie;
xcb_generic_error_t *error;
- drm_magic_t magic;
xcb_screen_iterator_t s;
- xcb_depth_iterator_t d;
- xcb_visualtype_t *visuals;
- int i, j, id;
-
- dri2_dpy = malloc(sizeof *dri2_dpy);
- if (!dri2_dpy)
- return _eglError(EGL_BAD_ALLOC, "eglInitialize");
-
- disp->DriverData = (void *) dri2_dpy;
- if (disp->NativeDisplay != NULL)
- dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
- else
- dri2_dpy->conn = xcb_connect(0, 0);
- if (!dri2_dpy->conn) {
- _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
- goto cleanup_dpy;
- }
xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id);
xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri2_id);
@@ -504,7 +524,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
error != NULL || xfixes_query->major_version < 2) {
_eglLog(_EGL_FATAL, "DRI2: failed to query xfixes version");
free(error);
- goto cleanup_conn;
+ return EGL_FALSE;
}
free(xfixes_query);
@@ -513,7 +533,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (dri2_query == NULL || error != NULL) {
_eglLog(_EGL_FATAL, "DRI2: failed to query version");
free(error);
- goto cleanup_conn;
+ return EGL_FALSE;
}
dri2_dpy->dri2_major = dri2_query->major_version;
dri2_dpy->dri2_minor = dri2_query->minor_version;
@@ -523,7 +543,126 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (connect == NULL ||
connect->driver_name_length + connect->device_name_length == 0) {
_eglLog(_EGL_FATAL, "DRI2: failed to authenticate");
- goto cleanup_connect;
+ return EGL_FALSE;
+ }
+
+ dri2_dpy->device_name =
+ dri2_strndup(xcb_dri2_connect_device_name (connect),
+ xcb_dri2_connect_device_name_length (connect));
+
+ dri2_dpy->driver_name =
+ dri2_strndup(xcb_dri2_connect_driver_name (connect),
+ xcb_dri2_connect_driver_name_length (connect));
+
+ if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
+ free(dri2_dpy->device_name);
+ free(dri2_dpy->driver_name);
+ free(connect);
+ return EGL_FALSE;
+ }
+ free(connect);
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+dri2_authenticate(struct dri2_egl_display *dri2_dpy)
+{
+ xcb_dri2_authenticate_reply_t *authenticate;
+ xcb_dri2_authenticate_cookie_t authenticate_cookie;
+ xcb_screen_iterator_t s;
+ drm_magic_t magic;
+
+ if (drmGetMagic(dri2_dpy->fd, &magic)) {
+ _eglLog(_EGL_FATAL, "DRI2: failed to get drm magic");
+ return EGL_FALSE;
+ }
+
+ s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
+ authenticate_cookie =
+ xcb_dri2_authenticate_unchecked(dri2_dpy->conn, s.data->root, magic);
+ authenticate =
+ xcb_dri2_authenticate_reply(dri2_dpy->conn, authenticate_cookie, NULL);
+ if (authenticate == NULL || !authenticate->authenticated) {
+ _eglLog(_EGL_FATAL, "DRI2: failed to authenticate");
+ free(authenticate);
+ return EGL_FALSE;
+ }
+
+ free(authenticate);
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
+ _EGLDisplay *disp)
+{
+ xcb_screen_iterator_t s;
+ xcb_depth_iterator_t d;
+ xcb_visualtype_t *visuals;
+ int i, j, id;
+
+ s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
+ d = xcb_screen_allowed_depths_iterator(s.data);
+ id = 1;
+ while (d.rem > 0) {
+ EGLBoolean class_added[6] = { 0, };
+
+ visuals = xcb_depth_visuals(d.data);
+ for (i = 0; i < xcb_depth_visuals_length(d.data); i++) {
+ if (class_added[visuals[i]._class])
+ continue;
+
+ class_added[visuals[i]._class] = EGL_TRUE;
+ for (j = 0; dri2_dpy->driver_configs[j]; j++)
+ dri2_add_config(disp, dri2_dpy->driver_configs[j],
+ id++, d.data->depth, &visuals[i]);
+ }
+
+ xcb_depth_next(&d);
+ }
+
+ if (!disp->NumConfigs) {
+ _eglLog(_EGL_WARNING, "DRI2: failed to create any config");
+ return EGL_FALSE;
+ }
+
+ return EGL_TRUE;
+}
+
+/**
+ * Called via eglInitialize(), GLX_drv->API.Initialize().
+ */
+static EGLBoolean
+dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
+ EGLint *major, EGLint *minor)
+{
+ const __DRIextension **extensions;
+ struct dri2_egl_display *dri2_dpy;
+ char path[PATH_MAX], *search_paths, *p, *next, *end;
+
+ dri2_dpy = malloc(sizeof *dri2_dpy);
+ if (!dri2_dpy)
+ return _eglError(EGL_BAD_ALLOC, "eglInitialize");
+
+ disp->DriverData = (void *) dri2_dpy;
+ if (disp->NativeDisplay == NULL) {
+ dri2_dpy->conn = xcb_connect(0, 0);
+ if (!dri2_dpy->conn) {
+ _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
+ goto cleanup_dpy;
+ }
+ } else {
+ dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
+ }
+
+ if (dri2_dpy->conn == NULL)
+ goto cleanup_conn;
+
+ if (dri2_dpy->conn) {
+ if (!dri2_connect(dri2_dpy))
+ goto cleanup_conn;
}
search_paths = NULL;
@@ -542,11 +681,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
next = end;
snprintf(path, sizeof path,
- dri_driver_format,
- (int) (next - p), p,
- xcb_dri2_connect_driver_name_length (connect),
- xcb_dri2_connect_driver_name (connect));
-
+ dri_driver_format, (int) (next - p), p, dri2_dpy->driver_name);
dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
}
@@ -554,7 +689,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
_eglLog(_EGL_FATAL,
"DRI2: failed to open any driver (search paths %s)",
search_paths);
- goto cleanup_connect;
+ goto cleanup_conn;
}
_eglLog(_EGL_DEBUG, "DRI2: dlopen(%s)", path);
@@ -568,32 +703,18 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (!dri2_bind_extensions(dri2_dpy, dri2_driver_extensions, extensions))
goto cleanup_driver;
- snprintf(path, sizeof path, "%.*s",
- xcb_dri2_connect_device_name_length (connect),
- xcb_dri2_connect_device_name (connect));
- dri2_dpy->fd = open (path, O_RDWR);
+ dri2_dpy->fd = open(dri2_dpy->device_name, O_RDWR);
if (dri2_dpy->fd == -1) {
_eglLog(_EGL_FATAL,
"DRI2: could not open %s (%s)", path, strerror(errno));
goto cleanup_driver;
}
- if (drmGetMagic(dri2_dpy->fd, &magic)) {
- _eglLog(_EGL_FATAL, "DRI2: failed to get drm magic");
- goto cleanup_fd;
- }
-
- authenticate_cookie = xcb_dri2_authenticate_unchecked (dri2_dpy->conn,
- s.data->root, magic);
- authenticate = xcb_dri2_authenticate_reply (dri2_dpy->conn,
- authenticate_cookie, NULL);
- if (authenticate == NULL || !authenticate->authenticated) {
- _eglLog(_EGL_FATAL, "DRI2: failed to authenticate");
- free(authenticate);
- goto cleanup_fd;
+ if (dri2_dpy->conn) {
+ if (!dri2_authenticate(dri2_dpy))
+ goto cleanup_fd;
}
- free(authenticate);
if (dri2_dpy->dri2_minor >= 1) {
dri2_dpy->loader_extension.base.name = __DRI_DRI2_LOADER;
dri2_dpy->loader_extension.base.version = 3;
@@ -609,12 +730,17 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
dri2_dpy->loader_extension.getBuffersWithFormat = NULL;
}
+ dri2_dpy->image_lookup_extension.base.name = __DRI_IMAGE_LOOKUP;
+ dri2_dpy->image_lookup_extension.base.version = 1;
+ dri2_dpy->image_lookup_extension.lookupEGLImage = dri2_lookup_egl_image;
+
dri2_dpy->extensions[0] = &dri2_dpy->loader_extension.base;
- dri2_dpy->extensions[1] = NULL;
+ dri2_dpy->extensions[1] = &dri2_dpy->image_lookup_extension.base;
+ dri2_dpy->extensions[2] = NULL;
dri2_dpy->dri_screen =
dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd, dri2_dpy->extensions,
- &driver_configs, dri2_dpy);
+ &dri2_dpy->driver_configs, dri2_dpy);
if (dri2_dpy->dri_screen == NULL) {
_eglLog(_EGL_FATAL, "DRI2: failed to create dri screen");
@@ -625,38 +751,20 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
if (!dri2_bind_extensions(dri2_dpy, dri2_core_extensions, extensions))
goto cleanup_dri_screen;
- s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
- d = xcb_screen_allowed_depths_iterator(s.data);
- id = 1;
- while (d.rem > 0) {
- EGLBoolean class_added[6] = { 0, };
-
- visuals = xcb_depth_visuals(d.data);
- for (i = 0; i < xcb_depth_visuals_length(d.data); i++) {
- if (class_added[visuals[i]._class])
- continue;
-
- class_added[visuals[i]._class] = EGL_TRUE;
- for (j = 0; driver_configs[j]; j++)
- dri2_add_config(disp, driver_configs[j],
- id++, d.data->depth, &visuals[i]);
-
- }
-
- xcb_depth_next(&d);
- }
-
- if (!disp->NumConfigs) {
- _eglLog(_EGL_WARNING, "DRI2: failed to create any config");
- goto cleanup_configs;
+ if (dri2_dpy->conn) {
+ if (!dri2_add_configs_for_visuals(dri2_dpy, disp))
+ goto cleanup_configs;
}
disp->ClientAPIsMask = EGL_OPENGL_BIT;
+ disp->Extensions.KHR_image_base = EGL_TRUE;
+ disp->Extensions.KHR_image_pixmap = EGL_TRUE;
+ disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
/* we're supporting EGL 1.4 */
*major = 1;
*minor = 4;
- free (connect);
+
return EGL_TRUE;
cleanup_configs:
@@ -667,8 +775,6 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
close(dri2_dpy->fd);
cleanup_driver:
dlclose(dri2_dpy->driver);
- cleanup_connect:
- free(connect);
cleanup_conn:
if (disp->NativeDisplay == NULL)
xcb_disconnect(dri2_dpy->conn);
@@ -1064,6 +1170,152 @@ dri2_release_tex_image(_EGLDriver *drv,
return EGL_TRUE;
}
+static _EGLImage *
+dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx,
+ EGLClientBuffer buffer, const EGLint *attr_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+ struct dri2_egl_image *dri2_img;
+ unsigned int attachments[1];
+ xcb_drawable_t drawable;
+ xcb_dri2_get_buffers_cookie_t buffers_cookie;
+ xcb_dri2_get_buffers_reply_t *buffers_reply;
+ xcb_dri2_dri2_buffer_t *buffers;
+ xcb_get_geometry_cookie_t geometry_cookie;
+ xcb_get_geometry_reply_t *geometry_reply;
+ xcb_generic_error_t *error;
+ int stride, format;
+
+ drawable = (xcb_drawable_t) buffer;
+ xcb_dri2_create_drawable (dri2_dpy->conn, drawable);
+ attachments[0] = XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT;
+ buffers_cookie =
+ xcb_dri2_get_buffers_unchecked (dri2_dpy->conn,
+ drawable, 1, 1, attachments);
+ geometry_cookie = xcb_get_geometry (dri2_dpy->conn, drawable);
+ buffers_reply = xcb_dri2_get_buffers_reply (dri2_dpy->conn,
+ buffers_cookie, NULL);
+ buffers = xcb_dri2_get_buffers_buffers (buffers_reply);
+ if (buffers == NULL) {
+ return NULL;
+ }
+
+ geometry_reply = xcb_get_geometry_reply (dri2_dpy->conn,
+ geometry_cookie, &error);
+ if (geometry_reply == NULL || error != NULL) {
+ _eglError(EGL_BAD_ALLOC, "xcb_get_geometry");
+ free(error);
+ free(buffers_reply);
+ }
+
+ switch (geometry_reply->depth) {
+ case 16:
+ format = __DRI_IMAGE_FORMAT_RGB565;
+ break;
+ case 24:
+ format = __DRI_IMAGE_FORMAT_XRGB8888;
+ break;
+ case 32:
+ format = __DRI_IMAGE_FORMAT_ARGB8888;
+ break;
+ default:
+ _eglError(EGL_BAD_PARAMETER,
+ "dri2_create_image_khr: unsupported pixmap depth");
+ free(buffers_reply);
+ free(geometry_reply);
+ return NULL;
+ }
+
+ dri2_img = malloc(sizeof *dri2_img);
+ if (!dri2_img) {
+ free(buffers_reply);
+ free(geometry_reply);
+ _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ if (!_eglInitImage(&dri2_img->base, disp, attr_list)) {
+ free(buffers_reply);
+ free(geometry_reply);
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ stride = buffers[0].pitch / buffers[0].cpp;
+ dri2_img->dri_image =
+ dri2_dpy->image->createImageFromName(dri2_ctx->dri_context,
+ buffers_reply->width,
+ buffers_reply->height,
+ format,
+ buffers[0].name,
+ stride,
+ dri2_img);
+
+ free(buffers_reply);
+ free(geometry_reply);
+
+ return &dri2_img->base;
+}
+
+static _EGLImage *
+dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
+ EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+ struct dri2_egl_image *dri2_img;
+ GLuint renderbuffer = (GLuint) buffer;
+
+ if (renderbuffer == 0) {
+ _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ dri2_img = malloc(sizeof *dri2_img);
+ if (!dri2_img) {
+ _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ if (!_eglInitImage(&dri2_img->base, disp, attr_list))
+ return EGL_NO_IMAGE_KHR;
+
+ dri2_img->dri_image =
+ dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
+ renderbuffer,
+ dri2_img);
+
+ return &dri2_img->base;
+}
+
+static _EGLImage *
+dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
+ _EGLContext *ctx, EGLenum target,
+ EGLClientBuffer buffer, const EGLint *attr_list)
+{
+ switch (target) {
+ case EGL_NATIVE_PIXMAP_KHR:
+ return dri2_create_image_khr_pixmap(disp, ctx, buffer, attr_list);
+ case EGL_GL_RENDERBUFFER_KHR:
+ return dri2_create_image_khr_renderbuffer(disp, ctx, buffer, attr_list);
+ default:
+ _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+}
+
+static EGLBoolean
+dri2_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_image *dri2_img = dri2_egl_image(image);
+
+ dri2_dpy->image->destroyImage(dri2_img->dri_image);
+ free(dri2_img);
+
+ return EGL_TRUE;
+}
/**
* This is the main entrypoint into the driver, called by libEGL.
@@ -1094,6 +1346,8 @@ _eglMain(const char *args)
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers;
dri2_drv->base.API.BindTexImage = dri2_bind_tex_image;
dri2_drv->base.API.ReleaseTexImage = dri2_release_tex_image;
+ dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
+ dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.Name = "DRI2";
dri2_drv->base.Unload = dri2_unload;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 2de1ac33184..647be652207 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -74,49 +74,57 @@
*
* These macros will unlock the display and record the error code.
*/
-#define _EGL_ERROR(disp, err, ret) \
- ({ \
+#define RETURN_EGL_ERROR(disp, err, ret) \
+ do { \
if (disp) \
_eglUnlockDisplay(disp); \
/* EGL error codes are non-zero */ \
if (err) \
_eglError(err, __FUNCTION__); \
- ret; \
- })
-#define _EGL_SUCCESS(disp, ret) _EGL_ERROR(disp, EGL_SUCCESS, ret)
+ return ret; \
+ } while (0)
+
+#define RETURN_EGL_SUCCESS(disp, ret) \
+ RETURN_EGL_ERROR(disp, EGL_SUCCESS, ret)
+
/* record EGL_SUCCESS only when ret evaluates to true */
-#define _EGL_EVAL(disp, ret) _EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret)
+#define RETURN_EGL_EVAL(disp, ret) \
+ RETURN_EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret)
-/**
+/*
* A bunch of macros and checks to simplify error checking.
*/
-#define _EGL_CHECK_DISPLAY(disp, ret) \
- ({ \
- _EGLDriver *__drv = _eglCheckDisplay(disp, __FUNCTION__); \
- if (!__drv) \
- return _EGL_ERROR(disp, 0, ret); \
- __drv; \
- })
-
-
-#define _EGL_CHECK_OBJECT(disp, type, obj, ret) \
- ({ \
- _EGLDriver *__drv = _eglCheck ## type(disp, obj, __FUNCTION__); \
- if (!__drv) \
- return _EGL_ERROR(disp, 0, ret); \
- __drv; \
- })
-#define _EGL_CHECK_SURFACE(disp, surf, ret) \
- _EGL_CHECK_OBJECT(disp, Surface, surf, ret)
-#define _EGL_CHECK_CONTEXT(disp, context, ret) \
- _EGL_CHECK_OBJECT(disp, Context, context, ret)
-#define _EGL_CHECK_CONFIG(disp, conf, ret) \
- _EGL_CHECK_OBJECT(disp, Config, conf, ret)
-#define _EGL_CHECK_SCREEN(disp, scrn, ret) \
- _EGL_CHECK_OBJECT(disp, Screen, scrn, ret)
-#define _EGL_CHECK_MODE(disp, m, ret) \
- _EGL_CHECK_OBJECT(disp, Mode, m, ret)
+
+#define _EGL_CHECK_DISPLAY(disp, ret, drv) \
+ do { \
+ drv = _eglCheckDisplay(disp, __FUNCTION__); \
+ if (!drv) \
+ RETURN_EGL_ERROR(disp, 0, ret); \
+ } while (0)
+
+#define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \
+ do { \
+ drv = _eglCheck ## type(disp, obj, __FUNCTION__); \
+ if (!drv) \
+ RETURN_EGL_ERROR(disp, 0, ret); \
+ } while (0)
+
+#define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \
+ _EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv)
+
+#define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \
+ _EGL_CHECK_OBJECT(disp, Context, context, ret, drv)
+
+#define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \
+ _EGL_CHECK_OBJECT(disp, Config, conf, ret, drv)
+
+#define _EGL_CHECK_SCREEN(disp, scrn, ret, drv) \
+ _EGL_CHECK_OBJECT(disp, Screen, scrn, ret, drv)
+
+#define _EGL_CHECK_MODE(disp, m, ret, drv) \
+ _EGL_CHECK_OBJECT(disp, Mode, m, ret, drv)
+
static INLINE _EGLDriver *
@@ -256,7 +264,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
EGLint major_int, minor_int;
if (!disp)
- return _EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
+ RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
if (!disp->Initialized) {
_EGLDriver *drv = disp->Driver;
@@ -265,12 +273,12 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
_eglPreloadDrivers();
drv = _eglMatchDriver(disp);
if (!drv)
- return _EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
}
/* Initialize the particular display now */
if (!drv->API.Initialize(drv, disp, &major_int, &minor_int))
- return _EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE);
disp->APImajor = major_int;
disp->APIminor = minor_int;
@@ -293,7 +301,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
*minor = minor_int;
}
- return _EGL_SUCCESS(disp, EGL_TRUE);
+ RETURN_EGL_SUCCESS(disp, EGL_TRUE);
}
@@ -303,7 +311,7 @@ eglTerminate(EGLDisplay dpy)
_EGLDisplay *disp = _eglLockDisplay(dpy);
if (!disp)
- return _EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
+ RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
if (disp->Initialized) {
_EGLDriver *drv = disp->Driver;
@@ -313,7 +321,7 @@ eglTerminate(EGLDisplay dpy)
disp->Initialized = EGL_FALSE;
}
- return _EGL_SUCCESS(disp, EGL_TRUE);
+ RETURN_EGL_SUCCESS(disp, EGL_TRUE);
}
@@ -324,10 +332,10 @@ eglQueryString(EGLDisplay dpy, EGLint name)
_EGLDriver *drv;
const char *ret;
- drv = _EGL_CHECK_DISPLAY(disp, NULL);
+ _EGL_CHECK_DISPLAY(disp, NULL, drv);
ret = drv->API.QueryString(drv, disp, name);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -339,10 +347,10 @@ eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
ret = drv->API.GetConfigs(drv, disp, configs, config_size, num_config);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -354,11 +362,11 @@ eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
ret = drv->API.ChooseConfig(drv, disp, attrib_list, configs,
config_size, num_config);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -371,10 +379,10 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv);
ret = drv->API.GetConfigAttrib(drv, disp, conf, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -389,14 +397,14 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
_EGLContext *context;
EGLContext ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv);
if (!share && share_list != EGL_NO_CONTEXT)
- return _EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
context = drv->API.CreateContext(drv, disp, conf, share, attrib_list);
ret = (context) ? _eglLinkContext(context, disp) : EGL_NO_CONTEXT;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -408,11 +416,11 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE);
+ _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv);
_eglUnlinkContext(context);
ret = drv->API.DestroyContext(drv, disp, context);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -428,27 +436,27 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
EGLBoolean ret;
if (!disp)
- return _EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE);
drv = disp->Driver;
/* display is allowed to be uninitialized under certain condition */
if (!disp->Initialized) {
if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE ||
ctx != EGL_NO_CONTEXT)
- return _EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE);
}
if (!drv)
- return _EGL_SUCCESS(disp, EGL_TRUE);
+ RETURN_EGL_SUCCESS(disp, EGL_TRUE);
if (!context && ctx != EGL_NO_CONTEXT)
- return _EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
if ((!draw_surf && draw != EGL_NO_SURFACE) ||
(!read_surf && read != EGL_NO_SURFACE))
- return _EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -461,10 +469,10 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE);
+ _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv);
ret = drv->API.QueryContext(drv, disp, context, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -478,12 +486,12 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
_EGLSurface *surf;
EGLSurface ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list);
ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -497,12 +505,12 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
_EGLSurface *surf;
EGLSurface ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list);
ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -516,12 +524,12 @@ eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
_EGLSurface *surf;
EGLSurface ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list);
ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -533,11 +541,11 @@ eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
_eglUnlinkSurface(surf);
ret = drv->API.DestroySurface(drv, disp, surf);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
EGLBoolean EGLAPIENTRY
@@ -549,10 +557,10 @@ eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
ret = drv->API.QuerySurface(drv, disp, surf, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
EGLBoolean EGLAPIENTRY
@@ -564,10 +572,10 @@ eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
ret = drv->API.SurfaceAttrib(drv, disp, surf, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -579,10 +587,10 @@ eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
ret = drv->API.BindTexImage(drv, disp, surf, buffer);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -594,10 +602,10 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -610,18 +618,18 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
if (!ctx || !_eglIsContextLinked(ctx) || ctx->Resource.Display != disp)
- return _EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
surf = ctx->DrawSurface;
if (!_eglIsSurfaceLinked(surf))
- return _EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
ret = drv->API.SwapInterval(drv, disp, surf, interval);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -634,15 +642,15 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
/* surface must be bound to current context in EGL 1.4 */
if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface)
- return _EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
ret = drv->API.SwapBuffers(drv, disp, surf);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -654,10 +662,10 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE);
+ _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
ret = drv->API.CopyBuffers(drv, disp, surf, target);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -670,21 +678,21 @@ eglWaitClient(void)
EGLBoolean ret;
if (!ctx)
- return _EGL_SUCCESS(NULL, EGL_TRUE);
+ RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
_eglLockMutex(&disp->Mutex);
/* let bad current context imply bad current surface */
if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
- return _EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
/* a valid current context implies an initialized current display */
assert(disp->Initialized);
drv = disp->Driver;
ret = drv->API.WaitClient(drv, disp, ctx);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -698,7 +706,7 @@ eglWaitGL(void)
EGLBoolean ret;
if (api_index != es_index && _eglIsCurrentThreadDummy())
- return _EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
+ RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
t->CurrentAPIIndex = es_index;
ret = eglWaitClient();
@@ -719,21 +727,21 @@ eglWaitNative(EGLint engine)
EGLBoolean ret;
if (!ctx)
- return _EGL_SUCCESS(NULL, EGL_TRUE);
+ RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
_eglLockMutex(&disp->Mutex);
/* let bad current context imply bad current surface */
if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface))
- return _EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
/* a valid current context implies an initialized current display */
assert(disp->Initialized);
drv = disp->Driver;
ret = drv->API.WaitNative(drv, disp, engine);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -745,7 +753,7 @@ eglGetCurrentDisplay(void)
ret = (ctx) ? _eglGetDisplayHandle(ctx->Resource.Display) : EGL_NO_DISPLAY;
- return _EGL_SUCCESS(NULL, ret);
+ RETURN_EGL_SUCCESS(NULL, ret);
}
@@ -757,7 +765,7 @@ eglGetCurrentContext(void)
ret = _eglGetContextHandle(ctx);
- return _EGL_SUCCESS(NULL, ret);
+ RETURN_EGL_SUCCESS(NULL, ret);
}
@@ -770,7 +778,7 @@ eglGetCurrentSurface(EGLint readdraw)
EGLSurface ret;
if (!ctx)
- return _EGL_SUCCESS(NULL, EGL_NO_SURFACE);
+ RETURN_EGL_SUCCESS(NULL, EGL_NO_SURFACE);
switch (readdraw) {
case EGL_DRAW:
@@ -787,7 +795,7 @@ eglGetCurrentSurface(EGLint readdraw)
ret = _eglGetSurfaceHandle(surf);
- return _EGL_ERROR(NULL, err, ret);
+ RETURN_EGL_ERROR(NULL, err, ret);
}
@@ -834,7 +842,7 @@ eglGetProcAddress(const char *procname)
_EGLProc ret;
if (!procname)
- return _EGL_SUCCESS(NULL, NULL);
+ RETURN_EGL_SUCCESS(NULL, NULL);
ret = NULL;
if (strncmp(procname, "egl", 3) == 0) {
@@ -846,7 +854,7 @@ eglGetProcAddress(const char *procname)
}
}
if (ret)
- return _EGL_SUCCESS(NULL, ret);
+ RETURN_EGL_SUCCESS(NULL, ret);
_eglPreloadDrivers();
@@ -858,7 +866,7 @@ eglGetProcAddress(const char *procname)
break;
}
- return _EGL_SUCCESS(NULL, ret);
+ RETURN_EGL_SUCCESS(NULL, ret);
}
@@ -879,11 +887,11 @@ eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.ChooseModeMESA(drv, disp, scrn, attrib_list,
modes, modes_size, num_modes);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -896,10 +904,10 @@ eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.GetModesMESA(drv, disp, scrn, modes, mode_size, num_mode);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -912,10 +920,10 @@ eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_MODE(disp, m, EGL_FALSE);
+ _EGL_CHECK_MODE(disp, m, EGL_FALSE, drv);
ret = drv->API.GetModeAttribMESA(drv, disp, m, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -929,14 +937,14 @@ eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_CONTEXT(disp, source_context, EGL_FALSE);
+ _EGL_CHECK_CONTEXT(disp, source_context, EGL_FALSE, drv);
if (!dest_context)
- return _EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
ret = drv->API.CopyContextMESA(drv, disp,
source_context, dest_context, mask);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -948,10 +956,10 @@ eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
ret = drv->API.GetScreensMESA(drv, disp, screens, max_screens, num_screens);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -965,12 +973,12 @@ eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config,
_EGLSurface *surf;
EGLSurface ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
surf = drv->API.CreateScreenSurfaceMESA(drv, disp, conf, attrib_list);
ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -985,15 +993,15 @@ eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
if (!surf && surface != EGL_NO_SURFACE)
- return _EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
if (!m && mode != EGL_NO_MODE_MESA)
- return _EGL_ERROR(disp, EGL_BAD_MODE_MESA, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_MODE_MESA, EGL_FALSE);
ret = drv->API.ShowScreenSurfaceMESA(drv, disp, scrn, surf, m);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1005,10 +1013,10 @@ eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.ScreenPositionMESA(drv, disp, scrn, x, y);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1021,10 +1029,10 @@ eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen,
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.QueryScreenMESA(drv, disp, scrn, attribute, value);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1038,12 +1046,12 @@ eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen,
_EGLSurface *surf;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.QueryScreenSurfaceMESA(drv, disp, scrn, &surf);
if (ret && surface)
*surface = _eglGetSurfaceHandle(surf);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1056,12 +1064,12 @@ eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode)
_EGLMode *m;
EGLBoolean ret;
- drv = _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE);
+ _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv);
ret = drv->API.QueryScreenModeMESA(drv, disp, scrn, &m);
if (ret && mode)
*mode = m->Handle;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1073,10 +1081,10 @@ eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode)
_EGLDriver *drv;
const char *ret;
- drv = _EGL_CHECK_MODE(disp, m, NULL);
+ _EGL_CHECK_MODE(disp, m, NULL, drv);
ret = drv->API.QueryModeStringMESA(drv, disp, m);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1107,14 +1115,14 @@ eglBindAPI(EGLenum api)
_EGLThreadInfo *t = _eglGetCurrentThread();
if (_eglIsCurrentThreadDummy())
- return _EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
+ RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
if (!_eglIsApiValid(api))
- return _EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE);
+ RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE);
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
- return _EGL_SUCCESS(NULL, EGL_TRUE);
+ RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
}
@@ -1130,7 +1138,7 @@ eglQueryAPI(void)
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */
ret = _eglConvertApiFromIndex(t->CurrentAPIIndex);
- return _EGL_SUCCESS(NULL, ret);
+ RETURN_EGL_SUCCESS(NULL, ret);
}
@@ -1145,13 +1153,13 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
_EGLSurface *surf;
EGLSurface ret;
- drv = _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE);
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
surf = drv->API.CreatePbufferFromClientBuffer(drv, disp, buftype, buffer,
conf, attrib_list);
ret = (surf) ? _eglLinkSurface(surf, disp) : EGL_NO_SURFACE;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1184,7 +1192,7 @@ eglReleaseThread(void)
_eglDestroyCurrentThread();
- return _EGL_SUCCESS(NULL, EGL_TRUE);
+ RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
}
@@ -1204,15 +1212,15 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
_EGLImage *img;
EGLImageKHR ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR);
+ _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
if (!context && ctx != EGL_NO_CONTEXT)
- return _EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+ RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
img = drv->API.CreateImageKHR(drv,
disp, context, target, buffer, attr_list);
ret = (img) ? _eglLinkImage(img, disp) : EGL_NO_IMAGE_KHR;
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
@@ -1224,14 +1232,14 @@ eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
_EGLDriver *drv;
EGLBoolean ret;
- drv = _EGL_CHECK_DISPLAY(disp, EGL_FALSE);
+ _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
if (!img)
- return _EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+ RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
_eglUnlinkImage(img);
ret = drv->API.DestroyImageKHR(drv, disp, img);
- return _EGL_EVAL(disp, ret);
+ RETURN_EGL_EVAL(disp, ret);
}
diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h
index d844fbb0efb..401a9cf56ad 100644
--- a/src/egl/main/eglcompiler.h
+++ b/src/egl/main/eglcompiler.h
@@ -64,8 +64,7 @@
/**
* Function visibility
*/
-#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define PUBLIC __attribute__((visibility("default")))
#else
# define PUBLIC
@@ -79,7 +78,7 @@
#ifndef __FUNCTION__
# if defined(__VMS)
# define __FUNCTION__ "VMS$NL:"
-# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
+# elif (!defined __GNUC__) && (!defined __xlC__) && \
(!defined(_MSC_VER) || _MSC_VER < 1300)
# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
(defined(__SUNPRO_C) && defined(__C99FEATURES__))
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 1190f8cdd57..21d13cba904 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -76,9 +76,6 @@ _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf)
}
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
EGLBoolean
_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
{
@@ -96,9 +93,6 @@ _eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
}
-#endif /* _EGL_SKIP_HANDLE_CHECK */
-
-
enum {
/* types */
ATTRIB_TYPE_INTEGER,
@@ -112,7 +106,7 @@ enum {
ATTRIB_CRITERION_ATLEAST,
ATTRIB_CRITERION_MASK,
ATTRIB_CRITERION_SPECIAL,
- ATTRIB_CRITERION_IGNORE,
+ ATTRIB_CRITERION_IGNORE
};
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index 56ec95fe9ad..ced060f7797 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -92,27 +92,10 @@ PUBLIC EGLConfig
_eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf);
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
extern EGLBoolean
_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy);
-#else
-
-
-static INLINE EGLBoolean
-_eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy)
-{
- _EGLConfig *conf = (_EGLConfig *) config;
- return (dpy && conf && conf->Display == dpy);
-}
-
-
-#endif /* _EGL_SKIP_HANDLE_CHECK */
-
-
/**
* Lookup a handle to find the linked config.
* Return NULL if the handle has no corresponding linked config.
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index f7dbe8ec22a..5dc5fd9719a 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -134,9 +134,6 @@ _eglCleanupDisplay(_EGLDisplay *disp)
}
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
/**
* Return EGL_TRUE if the given handle is a valid handle to a display.
*/
@@ -181,9 +178,6 @@ _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy)
}
-#endif /* !_EGL_SKIP_HANDLE_CHECK */
-
-
/**
* Link a resource to a display.
*/
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 43b39bda9d8..21bf22b5fee 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -14,6 +14,8 @@ enum _egl_resource_type {
_EGL_NUM_RESOURCES
};
+/* this cannot and need not go into egltypedefs.h */
+typedef enum _egl_resource_type _EGLResourceType;
/**
@@ -99,9 +101,6 @@ PUBLIC void
_eglCleanupDisplay(_EGLDisplay *disp);
-#ifndef _EGL_SKIP_HANDLE_CHECK
-
-
extern EGLBoolean
_eglCheckDisplayHandle(EGLDisplay dpy);
@@ -110,27 +109,6 @@ PUBLIC EGLBoolean
_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
-#else /* !_EGL_SKIP_HANDLE_CHECK */
-
-/* Only do a quick check. This is NOT standard compliant. */
-
-static INLINE EGLBoolean
-_eglCheckDisplayHandle(EGLDisplay dpy)
-{
- return ((_EGLDisplay *) dpy != NULL);
-}
-
-
-static INLINE EGLBoolean
-_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
-{
- return (((_EGLResource *) res)->Display == dpy);
-}
-
-
-#endif /* _EGL_SKIP_HANDLE_CHECK */
-
-
/**
* Lookup a handle to find the linked display.
* Return NULL if the handle has no corresponding linked display.
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 8748fe5f467..6384242b093 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -144,7 +144,13 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle)
mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
#elif defined(_EGL_PLATFORM_POSIX)
if (lib) {
- mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
+ union {
+ _EGLMain_t func;
+ void *ptr;
+ } tmp = { NULL };
+ /* direct cast gives a warning when compiled with -pedantic */
+ tmp.ptr = dlsym(lib, "_eglMain");
+ mainFunc = tmp.func;
if (!mainFunc)
error = dlerror();
}
diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h
index e0c95762c67..166b133909e 100644
--- a/src/egl/main/egltypedefs.h
+++ b/src/egl/main/egltypedefs.h
@@ -8,8 +8,6 @@
#include "eglcompiler.h"
-typedef enum _egl_resource_type _EGLResourceType;
-
typedef struct _egl_api _EGLAPI;
typedef struct _egl_config _EGLConfig;