hwui: set buffer destroyed swap mode explicitly
Not using EGL_SWAP_BEHAVIOR_PRESERVED_BIT as config attribute for
eglChooseConfig doesn't automatically mean the swap behavior is buffer
destroyed. This is driver implementation specific and on some hw this
can still be buffer preserved. Make sure it is buffer destroyed by
explicitly setting it for every new surface when requested.
Change-Id: Ie2c7c89b0d20e35832b488c6263bb4d9dd844a75
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index 466fef9d..805bec1 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -228,6 +228,13 @@
LOG_ALWAYS_FATAL_IF(surface == EGL_NO_SURFACE,
"Failed to create EGLSurface for window %p, eglErr = %s",
(void*) window, egl_error_str());
+
+ if (mSwapBehavior != SwapBehavior::Preserved) {
+ LOG_ALWAYS_FATAL_IF(eglSurfaceAttrib(mEglDisplay, surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED) == EGL_FALSE,
+ "Failed to set swap behavior to destroyed for window %p, eglErr = %s",
+ (void*) window, egl_error_str());
+ }
+
return surface;
}