summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c84
-rw-r--r--src/egl/main/eglapi.c6
-rw-r--r--src/egl/main/eglconfig.c2
-rw-r--r--src/egl/main/eglcontext.c91
-rw-r--r--src/egl/main/eglcurrent.c4
-rw-r--r--src/egl/main/egldisplay.h3
-rw-r--r--src/egl/main/egldriver.c1
-rw-r--r--src/egl/main/eglglobals.c1
-rw-r--r--src/egl/main/eglglobals.h2
-rw-r--r--src/egl/main/eglmisc.c4
-rw-r--r--src/egl/main/eglmode.c6
-rw-r--r--src/egl/main/eglmode.h6
-rw-r--r--src/egl/main/eglscreen.c19
-rw-r--r--src/egl/main/eglscreen.h6
-rw-r--r--src/egl/main/eglsurface.c66
15 files changed, 219 insertions, 82 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index c6d79a64e8a..efb93bcf06b 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -177,9 +177,9 @@ EGLint dri2_to_egl_attribute_map[] = {
EGL_Y_INVERTED_NOK, /* __DRI_ATTRIB_YINVERTED */
};
-static void
+static struct dri2_egl_config *
dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
- int depth, xcb_visualtype_t *visual)
+ int depth, EGLint surface_type)
{
struct dri2_egl_config *conf;
struct dri2_egl_display *dri2_dpy;
@@ -192,6 +192,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
_eglInitConfig(&base, disp, id);
i = 0;
+ double_buffer = 0;
+ bind_to_texture_rgb = 0;
+ bind_to_texture_rgba = 0;
+
while (dri2_dpy->core->indexConfigAttrib(dri_config, i++, &attrib, &value)) {
switch (attrib) {
case __DRI_ATTRIB_RENDER_TYPE:
@@ -242,35 +246,27 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
* return in the getBuffer callback to get the behaviour we want. */
if (double_buffer)
- return;
+ return NULL;
- if (visual != NULL) {
- if (depth != _eglGetConfigKey(&base, EGL_BUFFER_SIZE))
- return;
+ if (depth > 0 && depth != _eglGetConfigKey(&base, EGL_BUFFER_SIZE))
+ return NULL;
- _eglSetConfigKey(&base, EGL_SURFACE_TYPE,
- EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT |
- EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
+ _eglSetConfigKey(&base, EGL_NATIVE_RENDERABLE, EGL_TRUE);
- _eglSetConfigKey(&base, EGL_NATIVE_VISUAL_ID, visual->visual_id);
- _eglSetConfigKey(&base, EGL_NATIVE_VISUAL_TYPE, visual->_class);
- } else {
- _eglSetConfigKey(&base, EGL_SURFACE_TYPE,
- EGL_PIXMAP_BIT | EGL_PBUFFER_BIT);
+ _eglSetConfigKey(&base, EGL_SURFACE_TYPE, surface_type);
+ if (surface_type & (EGL_PIXMAP_BIT | EGL_PBUFFER_BIT)) {
+ _eglSetConfigKey(&base, EGL_BIND_TO_TEXTURE_RGB, bind_to_texture_rgb);
+ if (_eglGetConfigKey(&base, EGL_ALPHA_SIZE) > 0)
+ _eglSetConfigKey(&base,
+ EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
}
- _eglSetConfigKey(&base, EGL_NATIVE_RENDERABLE, EGL_TRUE);
- _eglSetConfigKey(&base, EGL_BIND_TO_TEXTURE_RGB, bind_to_texture_rgb);
- if (_eglGetConfigKey(&base, EGL_ALPHA_SIZE) > 0)
- _eglSetConfigKey(&base,
- EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
-
_eglSetConfigKey(&base, EGL_RENDERABLE_TYPE, disp->ClientAPIsMask);
_eglSetConfigKey(&base, EGL_CONFORMANT, disp->ClientAPIsMask);
if (!_eglValidateConfig(&base, EGL_FALSE)) {
_eglLog(_EGL_DEBUG, "DRI2: failed to validate config %d", id);
- return;
+ return NULL;
}
conf = malloc(sizeof *conf);
@@ -279,6 +275,8 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
conf->dri_config = dri_config;
_eglAddConfig(disp, &conf->base);
}
+
+ return conf;
}
/**
@@ -613,10 +611,19 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
xcb_depth_iterator_t d;
xcb_visualtype_t *visuals;
int i, j, id;
+ struct dri2_egl_config *conf;
+ EGLint surface_type;
s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
d = xcb_screen_allowed_depths_iterator(s.data);
id = 1;
+
+ surface_type =
+ EGL_WINDOW_BIT |
+ EGL_PIXMAP_BIT |
+ EGL_PBUFFER_BIT |
+ EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
+
while (d.rem > 0) {
EGLBoolean class_added[6] = { 0, };
@@ -626,9 +633,16 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
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]);
+ for (j = 0; dri2_dpy->driver_configs[j]; j++) {
+ conf = dri2_add_config(disp, dri2_dpy->driver_configs[j],
+ id++, d.data->depth, surface_type);
+ if (conf == NULL)
+ continue;
+ _eglSetConfigKey(&conf->base,
+ EGL_NATIVE_VISUAL_ID, visuals[i].visual_id);
+ _eglSetConfigKey(&conf->base,
+ EGL_NATIVE_VISUAL_TYPE, visuals[i]._class);
+ }
}
xcb_depth_next(&d);
@@ -738,6 +752,12 @@ dri2_create_screen(_EGLDisplay *disp)
if (api_mask & (1 << __DRI_API_GLES2))
disp->ClientAPIsMask |= EGL_OPENGL_ES2_BIT;
+ if (dri2_dpy->dri2->base.version >= 2) {
+ disp->Extensions.KHR_surfaceless_gles1 = EGL_TRUE;
+ disp->Extensions.KHR_surfaceless_gles2 = EGL_TRUE;
+ disp->Extensions.KHR_surfaceless_opengl = EGL_TRUE;
+ }
+
return EGL_TRUE;
cleanup_dri_screen:
@@ -948,6 +968,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp,
EGLint *major, EGLint *minor)
{
struct dri2_egl_display *dri2_dpy;
+ int i;
dri2_dpy = malloc(sizeof *dri2_dpy);
if (!dri2_dpy)
@@ -970,10 +991,17 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp,
if (!dri2_create_screen(disp))
goto cleanup_driver;
+ for (i = 0; dri2_dpy->driver_configs[i]; i++)
+ dri2_add_config(disp, dri2_dpy->driver_configs[i], i + 1, 0, 0);
+
disp->Extensions.KHR_image_base = EGL_TRUE;
disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE;
+ /* we're supporting EGL 1.4 */
+ *major = 1;
+ *minor = 4;
+
return EGL_TRUE;
cleanup_driver:
@@ -1041,6 +1069,7 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx_shared = dri2_egl_context(share_list);
struct dri2_egl_config *dri2_config = dri2_egl_config(conf);
+ const __DRIconfig *dri_config;
int api;
dri2_ctx = malloc(sizeof *dri2_ctx);
@@ -1074,11 +1103,16 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
return NULL;
}
+ if (conf != NULL)
+ dri_config = dri2_config->dri_config;
+ else
+ dri_config = NULL;
+
if (dri2_dpy->dri2->base.version >= 2) {
dri2_ctx->dri_context =
dri2_dpy->dri2->createNewContextForAPI(dri2_dpy->dri_screen,
api,
- dri2_config->dri_config,
+ dri_config,
dri2_ctx_shared ?
dri2_ctx_shared->dri_context : NULL,
dri2_ctx);
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 09271140b13..4dc8707cfbc 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -379,7 +379,11 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
_EGLContext *context;
EGLContext ret;
- _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv);
+ if (config)
+ _EGL_CHECK_CONFIG(disp, conf, EGL_NO_CONTEXT, drv);
+ else
+ drv = _eglCheckDisplay(disp, __FUNCTION__);
+
if (!share && share_list != EGL_NO_CONTEXT)
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index a9af3200976..ea8e47d02bb 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -314,8 +314,10 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
EGL_VG_ALPHA_FORMAT_PRE_BIT |
EGL_MULTISAMPLE_RESOLVE_BOX_BIT |
EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
+#ifdef EGL_MESA_screen_surface
if (conf->Display->Extensions.MESA_screen_surface)
mask |= EGL_SCREEN_BIT_MESA;
+#endif
break;
case EGL_RENDERABLE_TYPE:
case EGL_CONFORMANT:
diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index d5a1e79a994..9fc529613e5 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -83,7 +83,7 @@ _eglParseContextAttribList(_EGLContext *ctx, const EGLint *attrib_list)
}
}
- if (err == EGL_SUCCESS) {
+ if (err == EGL_SUCCESS && ctx->Config) {
EGLint renderable_type, api_bit;
renderable_type = GET_CONFIG_ATTRIB(ctx->Config, EGL_RENDERABLE_TYPE);
@@ -220,45 +220,49 @@ _eglBindContextToSurfaces(_EGLContext *newCtx,
* surface (oldDraw), the old bindings are broken first and the new one is
* created.
*/
- oldCtx = newDraw->CurrentContext;
- if (newCtx != oldCtx) {
- if (oldCtx) {
- assert(oldCtx->DrawSurface == newDraw);
- oldCtx->DrawSurface = NULL;
+ if (newDraw) {
+ oldCtx = newDraw->CurrentContext;
+ if (newCtx != oldCtx) {
+ if (oldCtx) {
+ assert(oldCtx->DrawSurface == newDraw);
+ oldCtx->DrawSurface = NULL;
+ }
+
+ newDraw->CurrentContext = newCtx;
}
+ }
- if (newCtx) {
- _EGLSurface *oldDraw = newCtx->DrawSurface;
- if (oldDraw)
- oldDraw->CurrentContext = NULL;
-
- newCtx->DrawSurface = newDraw;
- *draw = oldDraw;
- }
+ if (newCtx) {
+ _EGLSurface *oldDraw = newCtx->DrawSurface;
+ if (oldDraw)
+ oldDraw->CurrentContext = NULL;
- newDraw->CurrentContext = newCtx;
+ newCtx->DrawSurface = newDraw;
+ *draw = oldDraw;
}
/* likewise */
- if (newRead != newDraw)
+ if (newRead && newRead != newDraw) {
oldCtx = newRead->CurrentContext;
- if (newCtx != oldCtx) {
- if (oldCtx) {
- assert(oldCtx->ReadSurface == newRead);
- oldCtx->ReadSurface = NULL;
- }
+ if (newCtx != oldCtx) {
+ if (oldCtx) {
+ assert(oldCtx->ReadSurface == newRead);
+ oldCtx->ReadSurface = NULL;
+ }
- if (newCtx) {
- _EGLSurface *oldRead = newCtx->ReadSurface;
- if (oldRead)
- oldRead->CurrentContext = NULL;
-
- newCtx->ReadSurface = newRead;
- *read = oldRead;
+ newRead->CurrentContext = newCtx;
}
+ }
- newRead->CurrentContext = newCtx;
+ if (newCtx) {
+ _EGLSurface *oldRead = newCtx->ReadSurface;
+ if (oldRead)
+ oldRead->CurrentContext = NULL;
+
+ newCtx->ReadSurface = newRead;
+ *read = oldRead;
}
+
}
@@ -297,7 +301,9 @@ static EGLBoolean
_eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
{
_EGLThreadInfo *t = _eglGetCurrentThread();
+ _EGLDisplay *dpy;
EGLint conflict_api;
+ EGLBoolean surfaceless;
if (_eglIsCurrentThreadDummy())
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
@@ -309,8 +315,23 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
return EGL_TRUE;
}
- /* ctx/draw/read must be all given */
- if (draw == NULL || read == NULL)
+ dpy = ctx->Resource.Display;
+ switch (_eglGetContextAPIBit(ctx)) {
+ case EGL_OPENGL_ES_BIT:
+ surfaceless = dpy->Extensions.KHR_surfaceless_gles1;
+ break;
+ case EGL_OPENGL_ES2_BIT:
+ surfaceless = dpy->Extensions.KHR_surfaceless_gles2;
+ break;
+ case EGL_OPENGL_BIT:
+ surfaceless = dpy->Extensions.KHR_surfaceless_opengl;
+ break;
+ default:
+ surfaceless = EGL_FALSE;
+ break;
+ }
+
+ if (!surfaceless && (draw == NULL || read == NULL))
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
/* context stealing from another thread is not allowed */
@@ -331,12 +352,13 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
*
* The latter is more restrictive so we can check only the latter case.
*/
- if ((draw->CurrentContext && draw->CurrentContext != ctx) ||
- (read->CurrentContext && read->CurrentContext != ctx))
+ if ((draw && draw->CurrentContext && draw->CurrentContext != ctx) ||
+ (read && read->CurrentContext && read->CurrentContext != ctx))
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
/* simply require the configs to be equal */
- if (draw->Config != ctx->Config || read->Config != ctx->Config)
+ if ((draw && draw->Config != ctx->Config) ||
+ (read && read->Config != ctx->Config))
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
switch (ctx->ClientAPI) {
@@ -387,7 +409,6 @@ _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read)
*draw = oldCtx->DrawSurface;
*read = oldCtx->ReadSurface;
- assert(*draw && *read);
_eglBindContextToSurfaces(NULL, draw, read);
}
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index c697bf796dc..c0e8c119a94 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -1,9 +1,9 @@
#include <stdlib.h>
#include <string.h>
-#include "eglglobals.h"
#include "egllog.h"
#include "eglmutex.h"
#include "eglcurrent.h"
+#include "eglglobals.h"
/* This should be kept in sync with _eglInitThreadInfo() */
@@ -300,12 +300,14 @@ _eglError(EGLint errCode, const char *msg)
case EGL_BAD_SURFACE:
s = "EGL_BAD_SURFACE";
break;
+#ifdef EGL_MESA_screen_surface
case EGL_BAD_SCREEN_MESA:
s = "EGL_BAD_SCREEN_MESA";
break;
case EGL_BAD_MODE_MESA:
s = "EGL_BAD_MODE_MESA";
break;
+#endif
default:
s = "other";
}
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 0b2f26a4c07..a2cee08bf6f 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -60,6 +60,9 @@ struct _egl_extensions
EGLBoolean KHR_gl_texture_cubemap_image;
EGLBoolean KHR_gl_texture_3D_image;
EGLBoolean KHR_gl_renderbuffer_image;
+ EGLBoolean KHR_surfaceless_gles1;
+ EGLBoolean KHR_surfaceless_gles2;
+ EGLBoolean KHR_surfaceless_opengl;
EGLBoolean NOK_swap_region;
EGLBoolean NOK_texture_from_pixmap;
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 1e3d7d24aa7..8fc9e792b06 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -14,7 +14,6 @@
#include "egldefines.h"
#include "egldisplay.h"
#include "egldriver.h"
-#include "eglglobals.h"
#include "egllog.h"
#include "eglmisc.h"
#include "eglmode.h"
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index 725a25eca63..52eebb07f6c 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -11,7 +11,6 @@ struct _egl_global _eglGlobal =
{
&_eglGlobalMutex, /* Mutex */
NULL, /* DisplayList */
- 1, /* FreeScreenHandle */
2, /* NumAtExitCalls */
{
/* default AtExitCalls, called in reverse order */
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index e8bf5416e2a..c3771a8ef10 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -16,8 +16,6 @@ struct _egl_global
/* the list of all displays */
_EGLDisplay *DisplayList;
- EGLScreenMESA FreeScreenHandle;
-
EGLint NumAtExitCalls;
void (*AtExitCalls[10])(void);
};
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index 281138c7523..985d1e0069d 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -97,6 +97,10 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
_EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image);
_EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image);
+ _EGL_CHECK_EXTENSION(KHR_surfaceless_gles1);
+ _EGL_CHECK_EXTENSION(KHR_surfaceless_gles2);
+ _EGL_CHECK_EXTENSION(KHR_surfaceless_opengl);
+
_EGL_CHECK_EXTENSION(NOK_swap_region);
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap);
#undef _EGL_CHECK_EXTENSION
diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c
index 859e9318b4a..37594cdb42d 100644
--- a/src/egl/main/eglmode.c
+++ b/src/egl/main/eglmode.c
@@ -10,6 +10,9 @@
#include "eglstring.h"
+#ifdef EGL_MESA_screen_surface
+
+
#define MIN2(A, B) (((A) < (B)) ? (A) : (B))
@@ -353,3 +356,6 @@ _eglQueryModeStringMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *m)
{
return m->Name;
}
+
+
+#endif /* EGL_MESA_screen_surface */
diff --git a/src/egl/main/eglmode.h b/src/egl/main/eglmode.h
index a089a5e1943..9167cbc4b9b 100644
--- a/src/egl/main/eglmode.h
+++ b/src/egl/main/eglmode.h
@@ -4,6 +4,9 @@
#include "egltypedefs.h"
+#ifdef EGL_MESA_screen_surface
+
+
#define EGL_NO_MODE_MESA 0
@@ -54,4 +57,7 @@ extern const char *
_eglQueryModeStringMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *m);
+#endif /* EGL_MESA_screen_surface */
+
+
#endif /* EGLMODE_INCLUDED */
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c
index 8f96fd935c7..8b8966f3ffd 100644
--- a/src/egl/main/eglscreen.c
+++ b/src/egl/main/eglscreen.c
@@ -16,7 +16,6 @@
#include <string.h>
#include "egldisplay.h"
-#include "eglglobals.h"
#include "eglcurrent.h"
#include "eglmode.h"
#include "eglconfig.h"
@@ -25,6 +24,14 @@
#include "eglmutex.h"
+#ifdef EGL_MESA_screen_surface
+
+
+/* ugh, no atomic op? */
+static _EGL_DECLARE_MUTEX(_eglNextScreenHandleMutex);
+static EGLScreenMESA _eglNextScreenHandle = 1;
+
+
/**
* Return a new screen handle/ID.
* NOTE: we never reuse these!
@@ -33,10 +40,10 @@ static EGLScreenMESA
_eglAllocScreenHandle(void)
{
EGLScreenMESA s;
-
- _eglLockMutex(_eglGlobal.Mutex);
- s = _eglGlobal.FreeScreenHandle++;
- _eglUnlockMutex(_eglGlobal.Mutex);
+
+ _eglLockMutex(&_eglNextScreenHandleMutex);
+ s = _eglNextScreenHandle++;
+ _eglUnlockMutex(&_eglNextScreenHandleMutex);
return s;
}
@@ -263,3 +270,5 @@ _eglDestroyScreen(_EGLScreen *scrn)
free(scrn);
}
+
+#endif /* EGL_MESA_screen_surface */
diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h
index 0fd71f71fc8..3db20478ad6 100644
--- a/src/egl/main/eglscreen.h
+++ b/src/egl/main/eglscreen.h
@@ -5,6 +5,9 @@
#include "egltypedefs.h"
+#ifdef EGL_MESA_screen_surface
+
+
/**
* Per-screen information.
* Note that an EGL screen doesn't have a size. A screen may be set to
@@ -86,4 +89,7 @@ PUBLIC void
_eglDestroyScreen(_EGLScreen *scrn);
+#endif /* EGL_MESA_screen_surface */
+
+
#endif /* EGLSCREEN_INCLUDED */
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index d46bdb0672e..52f5c240c65 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -30,6 +30,50 @@ _eglClampSwapInterval(_EGLSurface *surf, EGLint interval)
}
+#ifdef EGL_MESA_screen_surface
+static EGLint
+_eglParseScreenSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
+{
+ EGLint i, err = EGL_SUCCESS;
+
+ if (!attrib_list)
+ return EGL_SUCCESS;
+
+ for (i = 0; attrib_list[i] != EGL_NONE; i++) {
+ EGLint attr = attrib_list[i++];
+ EGLint val = attrib_list[i];
+
+ switch (attr) {
+ case EGL_WIDTH:
+ if (val < 0) {
+ err = EGL_BAD_PARAMETER;
+ break;
+ }
+ surf->Width = val;
+ break;
+ case EGL_HEIGHT:
+ if (val < 0) {
+ err = EGL_BAD_PARAMETER;
+ break;
+ }
+ surf->Height = val;
+ break;
+ default:
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ if (err != EGL_SUCCESS) {
+ _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
+ break;
+ }
+ }
+
+ return err;
+}
+#endif /* EGL_MESA_screen_surface */
+
+
/**
* Parse the list of surface attributes and return the proper error code.
*/
@@ -44,6 +88,11 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
if (!attrib_list)
return EGL_SUCCESS;
+#ifdef EGL_MESA_screen_surface
+ if (type == EGL_SCREEN_BIT_MESA)
+ return _eglParseScreenSurfaceAttribList(surf, attrib_list);
+#endif
+
if (dpy->Extensions.NOK_texture_from_pixmap)
texture_type |= EGL_PIXMAP_BIT;
@@ -52,12 +101,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
EGLint val = attrib_list[i];
switch (attr) {
- /* common (except for screen surfaces) attributes */
+ /* common attributes */
case EGL_VG_COLORSPACE:
- if (type == EGL_SCREEN_BIT_MESA) {
- err = EGL_BAD_ATTRIBUTE;
- break;
- }
switch (val) {
case EGL_VG_COLORSPACE_sRGB:
case EGL_VG_COLORSPACE_LINEAR:
@@ -71,10 +116,6 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
surf->VGColorspace = val;
break;
case EGL_VG_ALPHA_FORMAT:
- if (type == EGL_SCREEN_BIT_MESA) {
- err = EGL_BAD_ATTRIBUTE;
- break;
- }
switch (val) {
case EGL_VG_ALPHA_FORMAT_NONPRE:
case EGL_VG_ALPHA_FORMAT_PRE:
@@ -101,7 +142,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
break;
/* pbuffer surface attributes */
case EGL_WIDTH:
- if (type != EGL_PBUFFER_BIT && type != EGL_SCREEN_BIT_MESA) {
+ if (type != EGL_PBUFFER_BIT) {
err = EGL_BAD_ATTRIBUTE;
break;
}
@@ -112,7 +153,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
surf->Width = val;
break;
case EGL_HEIGHT:
- if (type != EGL_PBUFFER_BIT && type != EGL_SCREEN_BIT_MESA) {
+ if (type != EGL_PBUFFER_BIT) {
err = EGL_BAD_ATTRIBUTE;
break;
}
@@ -129,6 +170,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
}
surf->LargestPbuffer = !!val;
break;
+ /* for eglBindTexImage */
case EGL_TEXTURE_FORMAT:
if (!(type & texture_type)) {
err = EGL_BAD_ATTRIBUTE;
@@ -210,10 +252,12 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
case EGL_PBUFFER_BIT:
func = "eglCreatePBufferSurface";
break;
+#ifdef EGL_MESA_screen_surface
case EGL_SCREEN_BIT_MESA:
func = "eglCreateScreenSurface";
renderBuffer = EGL_SINGLE_BUFFER; /* XXX correct? */
break;
+#endif
default:
_eglLog(_EGL_WARNING, "Bad type in _eglInitSurface");
return EGL_FALSE;