Recreate EGLImage for previously used slots

SurfaceTexture would only create an EGLImage for a buffer slot when
BufferQueue returns a GraphicBuffer, i.e. either the slot was acquired
for the first time ever, or the buffer for the slot was reallocated.
But the EGLImage may also need to be re-created for a
previously-acquired buffer if the slot's EGLImage was destroyed during
detachFromContext(); in this case BufferQueue won't return a
GraphicBuffer since SurfaceTexture already has a reference to the
correct buffer.

Bug: 6461693
Change-Id: Ib95d0d757192efe336c5fda0866f857481a6617d
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 1e58a21..feaf07a 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -228,14 +228,16 @@
             mEGLSlots[buf].mGraphicBuffer = item.mGraphicBuffer;
         }
 
-        // Update the GL texture object.
+        // Update the GL texture object. We may have to do this even when
+        // item.mGraphicBuffer == NULL, if we destroyed the EGLImage when
+        // detaching from a context but the buffer has not been re-allocated.
         EGLImageKHR image = mEGLSlots[buf].mEglImage;
         if (image == EGL_NO_IMAGE_KHR) {
-            if (item.mGraphicBuffer == 0) {
+            if (mEGLSlots[buf].mGraphicBuffer == NULL) {
                 ST_LOGE("updateTexImage: buffer at slot %d is null", buf);
                 return BAD_VALUE;
             }
-            image = createImage(dpy, item.mGraphicBuffer);
+            image = createImage(dpy, mEGLSlots[buf].mGraphicBuffer);
             mEGLSlots[buf].mEglImage = image;
             if (image == EGL_NO_IMAGE_KHR) {
                 // NOTE: if dpy was invalid, createImage() is guaranteed to