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
return err;
}
-status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item)
+status_t GLConsumer::updateAndReleaseLocked(const BufferItem& item,
+ PendingRelease* pendingRelease)
{
status_t err = NO_ERROR;
// release old buffer
if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
- status_t status = releaseBufferLocked(
- mCurrentTexture, mCurrentTextureImage->graphicBuffer(),
- mEglDisplay, mEglSlots[mCurrentTexture].mEglFence);
- if (status < NO_ERROR) {
- GLC_LOGE("updateAndRelease: failed to release buffer: %s (%d)",
- strerror(-status), status);
- err = status;
- // keep going, with error raised [?]
+ if (pendingRelease == nullptr) {
+ status_t status = releaseBufferLocked(
+ mCurrentTexture, mCurrentTextureImage->graphicBuffer(),
+ mEglDisplay, mEglSlots[mCurrentTexture].mEglFence);
+ if (status < NO_ERROR) {
+ GLC_LOGE("updateAndRelease: failed to release buffer: %s (%d)",
+ strerror(-status), status);
+ err = status;
+ // keep going, with error raised [?]
+ }
+ } else {
+ pendingRelease->currentTexture = mCurrentTexture;
+ pendingRelease->graphicBuffer =
+ mCurrentTextureImage->graphicBuffer();
+ pendingRelease->display = mEglDisplay;
+ pendingRelease->fence = mEglSlots[mCurrentTexture].mEglFence;
+ pendingRelease->isPending = true;
}
}