summaryrefslogtreecommitdiffstats
path: root/include/gui
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-06-14 14:45:17 -0700
committerJesse Hall <jessehall@google.com>2012-06-21 22:21:12 -0700
commitef19414bd8b77a26f5751f3845be79025a8263fe (patch)
tree9624b3d718e065747bedff50cb969151d675a471 /include/gui
parenta74cbc06493ed941a8a54f2f1d0074f03fc9aafb (diff)
downloadframeworks_native-ef19414bd8b77a26f5751f3845be79025a8263fe.zip
frameworks_native-ef19414bd8b77a26f5751f3845be79025a8263fe.tar.gz
frameworks_native-ef19414bd8b77a26f5751f3845be79025a8263fe.tar.bz2
Transfer HWC release fences to BufferQueue
After a HWC set, each SurfaceFlinger Layer retrieves the release fence HWC returned and gives it to the layer's SurfaceTexture. The SurfaceTexture accumulates the fences into a merged fence until the next updateTexImage, then passes the merged fence to the BufferQueue in releaseBuffer. In a follow-on change, BufferQueue will return the fence along with the buffer slot in dequeueBuffer. For now, dequeueBuffer waits for the fence to signal before returning. The releaseFence default value for BufferQueue::releaseBuffer() is temporary to avoid transient build breaks with a multi-project checkin. It'll disappear in the next change. Change-Id: Iaa9a0d5775235585d9cbf453d3a64623d08013d9
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/BufferQueue.h8
-rw-r--r--include/gui/SurfaceTexture.h15
2 files changed, 22 insertions, 1 deletions
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index 04a2f52..6db2c87 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -23,6 +23,7 @@
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceTexture.h>
+#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
#include <utils/String8.h>
@@ -218,7 +219,8 @@ public:
//
// Note that the dependencies on EGL will be removed once we switch to using
// the Android HW Sync HAL.
- status_t releaseBuffer(int buf, EGLDisplay display, EGLSyncKHR fence);
+ status_t releaseBuffer(int buf, EGLDisplay display, EGLSyncKHR fence,
+ const sp<Fence>& releaseFence = Fence::NO_FENCE);
// consumerConnect connects a consumer to the BufferQueue. Only one
// consumer may be connected, and when that consumer disconnects the
@@ -378,6 +380,10 @@ private:
// on a compile-time option) set to a new sync object in updateTexImage.
EGLSyncKHR mFence;
+ // mReleaseFence is a fence which must signal before the contents of
+ // the buffer associated with this buffer slot may be overwritten.
+ sp<Fence> mReleaseFence;
+
// Indicates whether this buffer has been seen by a consumer yet
bool mAcquireCalled;
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 2635e2f..622724e 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -91,6 +91,14 @@ public:
// target texture belongs is bound to the calling thread.
status_t updateTexImage();
+ // setReleaseFence stores a fence file descriptor that will signal when the
+ // current buffer is no longer being read. This fence will be returned to
+ // the producer when the current buffer is released by updateTexImage().
+ // Multiple fences can be set for a given buffer; they will be merged into
+ // a single union fence. The SurfaceTexture will close the file descriptor
+ // when finished with it.
+ void setReleaseFence(int fenceFd);
+
// setBufferCountServer set the buffer count. If the client has requested
// a buffer count using setBufferCount, the server-buffer count will
// take effect once the client sets the count back to zero.
@@ -349,6 +357,13 @@ private:
// to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based
// on a compile-time option) set to a new sync object in updateTexImage.
EGLSyncKHR mFence;
+
+ // mReleaseFence is a fence which will signal when the buffer
+ // associated with this buffer slot is no longer being used by the
+ // consumer and can be overwritten. The buffer can be dequeued before
+ // the fence signals; the producer is responsible for delaying writes
+ // until it signals.
+ sp<Fence> mReleaseFence;
};
// mEglDisplay is the EGLDisplay with which this SurfaceTexture is currently