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 Original line Diff line number Diff line
@@ -98,13 +98,12 @@ public:
    // This calls doGLFenceWait to ensure proper synchronization.
    // This calls doGLFenceWait to ensure proper synchronization.
    status_t updateTexImage();
    status_t updateTexImage();


    // setReleaseFence stores a fence file descriptor that will signal when the
    // setReleaseFence stores a fence that will signal when the current buffer
    // current buffer is no longer being read. This fence will be returned to
    // is no longer being read. This fence will be returned to the producer
    // the producer when the current buffer is released by updateTexImage().
    // when the current buffer is released by updateTexImage(). Multiple
    // Multiple fences can be set for a given buffer; they will be merged into
    // fences can be set for a given buffer; they will be merged into a single
    // a single union fence. The GLConsumer will close the file descriptor
    // union fence.
    // when finished with it.
    void setReleaseFence(const sp<Fence>& fence);
    void setReleaseFence(int fenceFd);


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


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


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


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


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


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


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


status_t FramebufferSurface::compositionComplete()
status_t FramebufferSurface::compositionComplete()
{
{
Loading