egl: set preserved behavior for surface only if config supports it
authorTapani Pälli <tapani.palli@intel.com>
Wed, 26 Oct 2016 10:54:51 +0000 (13:54 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 27 Oct 2016 04:12:51 +0000 (07:12 +0300)
Otherwise we can end up with mismatching behavior between config and
surface when client queries surface attributes. As example, configs
for DRI3 do not support preserved behavior but here we were setting
preserved behavior for pixmap and pbuffer.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98326
Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Tested-by: Mark Janes <mark.a.janes@intel.com>
src/egl/main/eglsurface.c

index eb0bdfeca284221f20c684f865300525a1a4a64e..8e56919a429605176f6f273bbfc8ab3d45f177ee 100644 (file)
@@ -262,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";