summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-06-28 14:27:53 -0700
committerJesse Hall <jessehall@google.com>2012-06-30 21:38:51 -0700
commitb42b1ac1587aebda5e2f334d95b620271fafba4e (patch)
tree5852fb46f80587194d109b3baa04a91af443181b /libs
parentc777b0b3b9b0ea5d8e378fccde6935765e28e329 (diff)
downloadframeworks_native-b42b1ac1587aebda5e2f334d95b620271fafba4e.zip
frameworks_native-b42b1ac1587aebda5e2f334d95b620271fafba4e.tar.gz
frameworks_native-b42b1ac1587aebda5e2f334d95b620271fafba4e.tar.bz2
Return fence from acquireBuffer
Change-Id: Iab22054c1dc4fd84affab3cc5bbdcd5a1e689666
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/BufferQueue.cpp2
-rw-r--r--libs/gui/CpuConsumer.cpp9
-rw-r--r--libs/gui/SurfaceTexture.cpp14
3 files changed, 21 insertions, 4 deletions
diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp
index a868537..23e3a4f 100644
--- a/libs/gui/BufferQueue.cpp
+++ b/libs/gui/BufferQueue.cpp
@@ -885,11 +885,13 @@ status_t BufferQueue::acquireBuffer(BufferItem *buffer) {
buffer->mFrameNumber = mSlots[buf].mFrameNumber;
buffer->mTimestamp = mSlots[buf].mTimestamp;
buffer->mBuf = buf;
+ buffer->mFence = mSlots[buf].mFence;
mSlots[buf].mAcquireCalled = true;
mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
mQueue.erase(front);
mDequeueCondition.broadcast();
+ mSlots[buf].mFence.clear();
ATRACE_INT(mConsumerName.string(), mQueue.size());
} else {
diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp
index bf2539f..513828c 100644
--- a/libs/gui/CpuConsumer.cpp
+++ b/libs/gui/CpuConsumer.cpp
@@ -114,6 +114,15 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
mBufferSlot[buf] = b.mGraphicBuffer;
}
+ if (b.mFence.get()) {
+ err = b.mFence->wait(Fence::TIMEOUT_NEVER);
+ if (err != OK) {
+ CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
+ strerror(-err), err);
+ return err;
+ }
+ }
+
err = mBufferSlot[buf]->lock(
GraphicBuffer::USAGE_SW_READ_OFTEN,
b.mCrop,
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index 9a36bf9..435a665 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -236,8 +236,7 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
// not accept this buffer. this is used by SurfaceFlinger to
// reject buffers which have the wrong size
if (rejecter && rejecter->reject(mEGLSlots[buf].mGraphicBuffer, item)) {
- mBufferQueue->releaseBuffer(buf, dpy, EGL_NO_SYNC_KHR,
- Fence::NO_FENCE);
+ mBufferQueue->releaseBuffer(buf, dpy, EGL_NO_SYNC_KHR, item.mFence);
glBindTexture(mTexTarget, mTexName);
return NO_ERROR;
}
@@ -261,6 +260,14 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
}
}
+ // Temporary; fence will be provided to clients soon
+ if (item.mFence.get()) {
+ err = item.mFence->wait(Fence::TIMEOUT_NEVER);
+ if (err != OK) {
+ ST_LOGE("updateTexImage: failure waiting for fence: %d", err);
+ }
+ }
+
if (err == NO_ERROR) {
GLint error;
while ((error = glGetError()) != GL_NO_ERROR) {
@@ -284,8 +291,7 @@ status_t SurfaceTexture::updateTexImage(BufferRejecter* rejecter) {
if (err != NO_ERROR) {
// Release the buffer we just acquired. It's not safe to
// release the old buffer, so instead we just drop the new frame.
- mBufferQueue->releaseBuffer(buf, dpy, EGL_NO_SYNC_KHR,
- Fence::NO_FENCE);
+ mBufferQueue->releaseBuffer(buf, dpy, EGL_NO_SYNC_KHR, item.mFence);
return err;
}