summaryrefslogtreecommitdiff
path: root/lib/mesa/src/egl/main/eglsurface.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/egl/main/eglsurface.c')
-rw-r--r--lib/mesa/src/egl/main/eglsurface.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/mesa/src/egl/main/eglsurface.c b/lib/mesa/src/egl/main/eglsurface.c
index 4fa43f3e2..3af337fef 100644
--- a/lib/mesa/src/egl/main/eglsurface.c
+++ b/lib/mesa/src/egl/main/eglsurface.c
@@ -71,6 +71,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
EGLint type = surf->Type;
EGLint texture_type = EGL_PBUFFER_BIT;
EGLint i, err = EGL_SUCCESS;
+ EGLint attr = EGL_NONE;
+ EGLint val = EGL_NONE;
if (!attrib_list)
return EGL_SUCCESS;
@@ -79,8 +81,8 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
texture_type |= EGL_PIXMAP_BIT;
for (i = 0; attrib_list[i] != EGL_NONE; i++) {
- EGLint attr = attrib_list[i++];
- EGLint val = attrib_list[i];
+ attr = attrib_list[i++];
+ val = attrib_list[i];
switch (attr) {
/* common attributes */
@@ -186,6 +188,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
err = EGL_BAD_ATTRIBUTE;
break;
}
+
switch (val) {
case EGL_TEXTURE_RGB:
case EGL_TEXTURE_RGBA:
@@ -204,6 +207,7 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
err = EGL_BAD_ATTRIBUTE;
break;
}
+
switch (val) {
case EGL_TEXTURE_2D:
case EGL_NO_TEXTURE:
@@ -229,12 +233,21 @@ _eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list)
break;
}
- if (err != EGL_SUCCESS) {
- _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
+ if (err != EGL_SUCCESS)
break;
+ }
+
+ if (err == EGL_SUCCESS && type == EGL_PBUFFER_BIT) {
+ if ((surf->TextureTarget == EGL_NO_TEXTURE && surf->TextureFormat != EGL_NO_TEXTURE) ||
+ (surf->TextureFormat == EGL_NO_TEXTURE && surf->TextureTarget != EGL_NO_TEXTURE)) {
+ attr = surf->TextureTarget == EGL_NO_TEXTURE ? EGL_TEXTURE_TARGET : EGL_TEXTURE_FORMAT;
+ err = EGL_BAD_MATCH;
}
}
+ if (err != EGL_SUCCESS)
+ _eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr);
+
return err;
}
@@ -249,9 +262,13 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
{
const char *func;
EGLint renderBuffer = EGL_BACK_BUFFER;
- EGLint swapBehavior = EGL_BUFFER_PRESERVED;
+ EGLint swapBehavior = EGL_BUFFER_DESTROYED;
EGLint err;
+ /* Swap behavior can be preserved only if config supports this. */
+ if (conf->SurfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)
+ swapBehavior = EGL_BUFFER_PRESERVED;
+
switch (type) {
case EGL_WINDOW_BIT:
func = "eglCreateWindowSurface";
@@ -307,6 +324,12 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
if (err != EGL_SUCCESS)
return _eglError(err, func);
+ /* if EGL_LARGEST_PBUFFER in use, clamp width and height */
+ if (surf->LargestPbuffer) {
+ surf->Width = MIN2(surf->Width, _EGL_MAX_PBUFFER_WIDTH);
+ surf->Height = MIN2(surf->Height, _EGL_MAX_PBUFFER_HEIGHT);
+ }
+
return EGL_TRUE;
}