Don't crash on makeCurrent fail

Bug: 22444755

WindowManager may decide to yank the surface at any point, so
attempt to kinda handle this

Change-Id: Id2f665d2f0f93bccd4ec977fbf52dca4dc1ec891
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp
index cb34e00..eb332d5 100644
--- a/libs/hwui/renderthread/EglManager.cpp
+++ b/libs/hwui/renderthread/EglManager.cpp
@@ -217,7 +217,7 @@
     mCurrentSurface = EGL_NO_SURFACE;
 }
 
-bool EglManager::makeCurrent(EGLSurface surface) {
+bool EglManager::makeCurrent(EGLSurface surface, EGLint* errOut) {
     if (isCurrent(surface)) return false;
 
     if (surface == EGL_NO_SURFACE) {
@@ -225,8 +225,14 @@
         surface = mPBufferSurface;
     }
     if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
-        LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s",
-                (void*)surface, egl_error_str());
+        if (errOut) {
+            *errOut = eglGetError();
+            ALOGW("Failed to make current on surface %p, error=%s",
+                    (void*)surface, egl_error_str(*errOut));
+        } else {
+            LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s",
+                    (void*)surface, egl_error_str());
+        }
     }
     mCurrentSurface = surface;
     return true;