Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13f01cbd authored by Jesse Hall's avatar Jesse Hall
Browse files

Pass sp<Fence>s around instead of file descriptors

Change-Id: Iac70584a2207940730e8f803a543e4e9a4000c47
parent 8d8c7597
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -98,13 +98,12 @@ public:
    // This calls doGLFenceWait to ensure proper synchronization.
    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 GLConsumer will close the file descriptor
    // when finished with it.
    void setReleaseFence(int fenceFd);
    // setReleaseFence stores a fence 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.
    void setReleaseFence(const sp<Fence>& fence);

    // setDefaultMaxBufferCount sets the default limit on the maximum number
    // of buffers that will be allocated at one time. The image producer may
+8 −8
Original line number Diff line number Diff line
@@ -367,16 +367,16 @@ status_t GLConsumer::checkAndUpdateEglStateLocked() {
    return NO_ERROR;
}

void GLConsumer::setReleaseFence(int fenceFd) {
    sp<Fence> fence(new Fence(fenceFd));
    if (fenceFd == -1 || mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT)
        return;
void GLConsumer::setReleaseFence(const sp<Fence>& fence) {
    if (fence->isValid() &&
            mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
        status_t err = addReleaseFence(mCurrentTexture, fence);
        if (err != OK) {
            ST_LOGE("setReleaseFence: failed to add the fence: %s (%d)",
                    strerror(-err), err);
        }
    }
}

status_t GLConsumer::detachFromContext() {
    ATRACE_CALL();
+2 −2
Original line number Diff line number Diff line
@@ -235,8 +235,8 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const {

void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
    if (hwc.initCheck() == NO_ERROR) {
        int fd = hwc.getAndResetReleaseFenceFd(mType);
        mDisplaySurface->onFrameCommitted(fd);
        sp<Fence> fence = hwc.getAndResetReleaseFence(mType);
        mDisplaySurface->onFrameCommitted(fence);
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public:
    // hardware composer and a release fence is available for the buffer.
    // Further operations on the buffer can be queued as long as they wait for
    // the fence to signal.
    virtual void onFrameCommitted(int fenceFd) = 0;
    virtual void onFrameCommitted(const sp<Fence>& fence) = 0;

    virtual void dump(String8& result) const = 0;

+6 −8
Original line number Diff line number Diff line
@@ -140,16 +140,14 @@ void FramebufferSurface::freeBufferLocked(int slotIndex) {
    }
}

void FramebufferSurface::onFrameCommitted(int fenceFd) {
    if (fenceFd >= 0) {
        sp<Fence> fence(new Fence(fenceFd));
        if (mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) {
void FramebufferSurface::onFrameCommitted(const sp<Fence>& fence) {
    if (fence->isValid() &&
            mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) {
        status_t err = addReleaseFence(mCurrentBufferSlot, fence);
        ALOGE_IF(err, "setReleaseFenceFd: failed to add the fence: %s (%d)",
                strerror(-err), err);
    }
}
}

status_t FramebufferSurface::compositionComplete()
{
Loading