SurfaceTexture: use eglWaitSync
This change adds a compile-option to use eglWaitSyncANDROID to ensure that
texturing operations that access the current buffer of a SurfaceTexture do not
occur until the buffer is completely written. It also moves this
synchronization into a new SurfaceTexture method called doGLFenceWait and
changes SurfaceFlinger's Layer class to use that method rather than performing
its own wait on the fence.
Change-Id: I70afa88086ca7ff49a80e3cd03d423767db7cb88
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 80a010b..6e5a478 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -77,6 +77,9 @@
//
// This call may only be made while the OpenGL ES context to which the
// target texture belongs is bound to the calling thread.
+ //
+ // After calling this method the doGLFenceWait method must be called
+ // before issuing OpenGL ES commands that access the texture contents.
status_t updateTexImage();
// setReleaseFence stores a fence file descriptor that will signal when the
@@ -154,6 +157,12 @@
// ready to be read from.
sp<Fence> getCurrentFence() const;
+ // doGLFenceWait inserts a wait command into the OpenGL ES command stream
+ // to ensure that it is safe for future OpenGL ES commands to access the
+ // current texture buffer. This must be called each time updateTexImage
+ // is called before issuing OpenGL ES commands that access the texture.
+ status_t doGLFenceWait() const;
+
// isSynchronousMode returns whether the SurfaceTexture is currently in
// synchronous mode.
bool isSynchronousMode() const;