summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jamie Gennis <jgennis@google.com> 2011-11-17 16:00:44 -0800
committer Jamie Gennis <jgennis@google.com> 2011-11-17 16:00:44 -0800
commite36d05483fa525be1c98dbf98ac3d6244e6cdb47 (patch)
treea3b6f7e0bd68fdcee4a93c24f864ff33e60359d0
parentcce32110e6f42378a76e0eb2495d24b6c8bc8ae7 (diff)
SurfaceTexture: fix a bug with buffer reallocation
This change fixes an issue involving buffer reallocation and the ALLOW_DEQUEUE_CURRENT_BUFFER mode in SurfaceTexture. The bug happened when the buffer slot currently attached to the GL texture was selected for dequeuing, but the dequeue operation caused the buffer to be reallocated. Because the buffer is new, the image producer could fill the buffer and queue it before an updateTexImage call, which would result in the "slot %d is current" error in queueBuffer. Bug: 5631630 Change-Id: Icdd8bc5cad3c7db43953446d9be2603aaea11a8d
-rw-r--r--libs/gui/SurfaceTexture.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 374f3c524019..ab154edff1ff 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -434,6 +434,11 @@ status_t SurfaceTexture::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
mSlots[buf].mEglImage = EGL_NO_IMAGE_KHR;
mSlots[buf].mEglDisplay = EGL_NO_DISPLAY;
}
+ if (mCurrentTexture == buf) {
+ // The current texture no longer references the buffer in this slot
+ // since we just allocated a new buffer.
+ mCurrentTexture = INVALID_BUFFER_SLOT;
+ }
returnFlags |= ISurfaceTexture::BUFFER_NEEDS_REALLOCATION;
}
ST_LOGV("dequeueBuffer: returning slot=%d buf=%p flags=%#x", buf,