diff options
author | Jamie Gennis <jgennis@google.com> | 2011-05-19 13:33:00 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2011-05-25 12:27:33 -0700 |
commit | a218715a7fca98c868feccee4751c94e38b676ff (patch) | |
tree | 3386ef4297d74a48b940e2b9d61fdd6f9c209cd0 /libs | |
parent | 4ece6db47ec33ed439ae2177fbc0cc3e7e79cdca (diff) | |
download | frameworks_base-a218715a7fca98c868feccee4751c94e38b676ff.zip frameworks_base-a218715a7fca98c868feccee4751c94e38b676ff.tar.gz frameworks_base-a218715a7fca98c868feccee4751c94e38b676ff.tar.bz2 |
SurfaceTexture: clean up some comments, tests, etc.
This change fixes up some stale comments, member variable names, log
messages and disables a failing test.
Change-Id: Ic1d3344b18066cf710e4a42838b2417c6b1f2f6c
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gui/SurfaceTexture.cpp | 88 | ||||
-rw-r--r-- | libs/gui/SurfaceTextureClient.cpp | 3 | ||||
-rw-r--r-- | libs/gui/tests/SurfaceTextureClient_test.cpp | 4 |
3 files changed, 48 insertions, 47 deletions
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index b08a5a8..bcf7a63 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -390,49 +390,49 @@ status_t SurfaceTexture::queueBuffer(int buf, int64_t timestamp) { sp<FrameAvailableListener> listener; { // scope for the lock - Mutex::Autolock lock(mMutex); - if (buf < 0 || buf >= mBufferCount) { - LOGE("queueBuffer: slot index out of range [0, %d]: %d", - mBufferCount, buf); - return -EINVAL; - } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) { - LOGE("queueBuffer: slot %d is not owned by the client (state=%d)", - buf, mSlots[buf].mBufferState); - return -EINVAL; - } else if (buf == mCurrentTexture) { - LOGE("queueBuffer: slot %d is current!", buf); - return -EINVAL; - } else if (!mSlots[buf].mRequestBufferCalled) { - LOGE("queueBuffer: slot %d was enqueued without requesting a buffer", - buf); - return -EINVAL; - } - - if (mQueue.empty()) { - listener = mFrameAvailableListener; - } + Mutex::Autolock lock(mMutex); + if (buf < 0 || buf >= mBufferCount) { + LOGE("queueBuffer: slot index out of range [0, %d]: %d", + mBufferCount, buf); + return -EINVAL; + } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) { + LOGE("queueBuffer: slot %d is not owned by the client (state=%d)", + buf, mSlots[buf].mBufferState); + return -EINVAL; + } else if (buf == mCurrentTexture) { + LOGE("queueBuffer: slot %d is current!", buf); + return -EINVAL; + } else if (!mSlots[buf].mRequestBufferCalled) { + LOGE("queueBuffer: slot %d was enqueued without requesting a " + "buffer", buf); + return -EINVAL; + } - if (mSynchronousMode) { - // in synchronous mode we queue all buffers in a FIFO - mQueue.push_back(buf); - } else { - // in asynchronous mode we only keep the most recent buffer if (mQueue.empty()) { + listener = mFrameAvailableListener; + } + + if (mSynchronousMode) { + // in synchronous mode we queue all buffers in a FIFO mQueue.push_back(buf); } else { - Fifo::iterator front(mQueue.begin()); - // buffer currently queued is freed - mSlots[*front].mBufferState = BufferSlot::FREE; - // and we record the new buffer index in the queued list - *front = buf; + // in asynchronous mode we only keep the most recent buffer + if (mQueue.empty()) { + mQueue.push_back(buf); + } else { + Fifo::iterator front(mQueue.begin()); + // buffer currently queued is freed + mSlots[*front].mBufferState = BufferSlot::FREE; + // and we record the new buffer index in the queued list + *front = buf; + } } - } - mSlots[buf].mBufferState = BufferSlot::QUEUED; - mSlots[buf].mLastQueuedCrop = mNextCrop; - mSlots[buf].mLastQueuedTransform = mNextTransform; - mSlots[buf].mLastQueuedTimestamp = timestamp; - mDequeueCondition.signal(); + mSlots[buf].mBufferState = BufferSlot::QUEUED; + mSlots[buf].mCrop = mNextCrop; + mSlots[buf].mTransform = mNextTransform; + mSlots[buf].mTimestamp = timestamp; + mDequeueCondition.signal(); } // scope for the lock // call back without lock held @@ -540,9 +540,9 @@ status_t SurfaceTexture::updateTexImage() { mCurrentTexture = buf; mCurrentTextureTarget = target; mCurrentTextureBuf = mSlots[buf].mGraphicBuffer; - mCurrentCrop = mSlots[buf].mLastQueuedCrop; - mCurrentTransform = mSlots[buf].mLastQueuedTransform; - mCurrentTimestamp = mSlots[buf].mLastQueuedTimestamp; + mCurrentCrop = mSlots[buf].mCrop; + mCurrentTransform = mSlots[buf].mTransform; + mCurrentTimestamp = mSlots[buf].mTimestamp; mDequeueCondition.signal(); } else { // We always bind the texture even if we don't update its contents. @@ -826,12 +826,10 @@ void SurfaceTexture::dump(String8& result, const char* prefix, const BufferSlot& slot(mSlots[i]); snprintf(buffer, SIZE, "%s%s[%02d] state=%-8s, crop=[%d,%d,%d,%d], transform=0x%02x, " - "timestamp=%lld\n" - , + "timestamp=%lld\n", prefix, (i==mCurrentTexture)?">":" ", i, stateName(slot.mBufferState), - slot.mLastQueuedCrop.left, slot.mLastQueuedCrop.top, - slot.mLastQueuedCrop.right, slot.mLastQueuedCrop.bottom, - slot.mLastQueuedTransform, slot.mLastQueuedTimestamp + slot.mCrop.left, slot.mCrop.top, slot.mCrop.right, slot.mCrop.bottom, + slot.mTransform, slot.mTimestamp ); result.append(buffer); } diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 6f10320..c20fcf2 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -117,7 +117,8 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) { mReqFormat, mReqUsage); if (result < 0) { LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)" - "failed: %d", result, mReqWidth, mReqHeight, mReqFormat, mReqUsage); + "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage, + result); return result; } sp<GraphicBuffer>& gbuf(mSlots[buf]); diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp index 59a4cc5..8340337 100644 --- a/libs/gui/tests/SurfaceTextureClient_test.cpp +++ b/libs/gui/tests/SurfaceTextureClient_test.cpp @@ -400,7 +400,9 @@ TEST_F(SurfaceTextureClientTest, SurfaceTextureSyncModeDQQR) { EXPECT_EQ(st->getCurrentBuffer().get(), buf[2]); } -TEST_F(SurfaceTextureClientTest, SurfaceTextureSyncModeDequeueCurrent) { +// XXX: We currently have no hardware that properly handles dequeuing the +// buffer that is currently bound to the texture. +TEST_F(SurfaceTextureClientTest, DISABLED_SurfaceTextureSyncModeDequeueCurrent) { sp<ANativeWindow> anw(mSTC); sp<SurfaceTexture> st(mST); android_native_buffer_t* buf[3]; |