libgui: Allow for pending releases in GLConsumer
Adds the ability for GLConsumer to record a pending release instead of
releasing the buffer immediately. This will be used by SurfaceFlinger
to latch a new buffer without having to immediately release the old
one, since it needs to get a fence from HWC before releasing.
Change-Id: I8cc3ce7d5ff80e2ea4b4d681b028db042352d229
diff --git a/include/gui/GLConsumer.h b/include/gui/GLConsumer.h
index 0e4acee..61f631f 100644
--- a/include/gui/GLConsumer.h
+++ b/include/gui/GLConsumer.h
@@ -253,10 +253,25 @@
static bool isExternalFormat(PixelFormat format);
+ struct PendingRelease {
+ PendingRelease() : isPending(false), currentTexture(-1),
+ graphicBuffer(), display(nullptr), fence(nullptr) {}
+
+ bool isPending;
+ int currentTexture;
+ sp<GraphicBuffer> graphicBuffer;
+ EGLDisplay display;
+ EGLSyncKHR fence;
+ };
+
// This releases the buffer in the slot referenced by mCurrentTexture,
// then updates state to refer to the BufferItem, which must be a
- // newly-acquired buffer.
- status_t updateAndReleaseLocked(const BufferItem& item);
+ // newly-acquired buffer. If pendingRelease is not null, the parameters
+ // which would have been passed to releaseBufferLocked upon the successful
+ // completion of the method will instead be returned to the caller, so that
+ // it may call releaseBufferLocked itself later.
+ status_t updateAndReleaseLocked(const BufferItem& item,
+ PendingRelease* pendingRelease = nullptr);
// Binds mTexName and the current buffer to mTexTarget. Uses
// mCurrentTexture if it's set, mCurrentTextureImage if not. If the