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/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f39de4a..e78059d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -333,11 +333,9 @@
return;
}
- // TODO: replace this with a server-side wait
- sp<Fence> fence = mSurfaceTexture->getCurrentFence();
- if (fence.get()) {
- status_t err = fence->wait(Fence::TIMEOUT_NEVER);
- ALOGW_IF(err != OK, "Layer::onDraw: failed waiting for fence: %d", err);
+ status_t err = mSurfaceTexture->doGLFenceWait();
+ if (err != OK) {
+ ALOGE("onDraw: failed waiting for fence: %d", err);
// Go ahead and draw the buffer anyway; no matter what we do the screen
// is probably going to have something visibly wrong.
}