summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-06-27 15:41:52 -0700
committerJamie Gennis <jgennis@google.com>2011-06-27 15:45:40 -0700
commit9fb5976367911d0ab42d296238f0f06d517e867d (patch)
tree98c01d0b42d77db071fba25d8c3e98dacfaa2dfc /libs
parentbd5404d0312752e7c8946e8540129f0d2d97bcd7 (diff)
downloadframeworks_base-9fb5976367911d0ab42d296238f0f06d517e867d.zip
frameworks_base-9fb5976367911d0ab42d296238f0f06d517e867d.tar.gz
frameworks_base-9fb5976367911d0ab42d296238f0f06d517e867d.tar.bz2
SurfaceTexture: consume buffers after err checks
This change moves the point at which queued buffers get consumed to after any error checks that could cause updateTexImage to fail. This way, if updateTexImage returns an error the buffer remains queued.
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/SurfaceTexture.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 96ab284..0925001 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -488,24 +488,14 @@ status_t SurfaceTexture::setTransform(uint32_t transform) {
status_t SurfaceTexture::updateTexImage() {
LOGV("SurfaceTexture::updateTexImage");
-
Mutex::Autolock lock(mMutex);
- int buf = mCurrentTexture;
+ // In asynchronous mode the list is guaranteed to be one buffer
+ // deep, while in synchronous mode we use the oldest buffer.
if (!mQueue.empty()) {
- // in asynchronous mode the list is guaranteed to be one buffer deep,
- // while in synchronous mode we use the oldest buffer
Fifo::iterator front(mQueue.begin());
- buf = *front;
- mQueue.erase(front);
- if (mQueue.isEmpty()) {
- mDequeueCondition.signal();
- }
- }
+ int buf = *front;
- // Initially both mCurrentTexture and buf are INVALID_BUFFER_SLOT,
- // so this check will fail until a buffer gets queued.
- if (mCurrentTexture != buf) {
// Update the GL texture object.
EGLImageKHR image = mSlots[buf].mEglImage;
if (image == EGL_NO_IMAGE_KHR) {
@@ -543,7 +533,7 @@ status_t SurfaceTexture::updateTexImage() {
}
if (mCurrentTexture != INVALID_BUFFER_SLOT) {
- // the current buffer becomes FREE if it was still in the queued
+ // The current buffer becomes FREE if it was still in the queued
// state. If it has already been given to the client
// (synchronous mode), then it stays in DEQUEUED state.
if (mSlots[mCurrentTexture].mBufferState == BufferSlot::QUEUED)
@@ -558,11 +548,16 @@ status_t SurfaceTexture::updateTexImage() {
mCurrentTransform = mSlots[buf].mTransform;
mCurrentTimestamp = mSlots[buf].mTimestamp;
computeCurrentTransformMatrix();
+
+ // Now that we've passed the point at which failures can happen,
+ // it's safe to remove the buffer from the front of the queue.
+ mQueue.erase(front);
mDequeueCondition.signal();
} else {
// We always bind the texture even if we don't update its contents.
glBindTexture(mCurrentTextureTarget, mTexName);
}
+
return OK;
}