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

Commit 8d8c7597 authored by Jesse Hall's avatar Jesse Hall Committed by Android (Google) Code Review
Browse files

Merge "Release virtual display buffer immediately after HWC set" into jb-mr2-dev

parents ed985574 74149656
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const {
void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
    if (hwc.initCheck() == NO_ERROR) {
        int fd = hwc.getAndResetReleaseFenceFd(mType);
        mDisplaySurface->setReleaseFenceFd(fd);
        mDisplaySurface->onFrameCommitted(fd);
    }
}

+1 −13
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#undef LOG_TAG
#define LOG_TAG "BQInterposer"
//#define LOG_NDEBUG 0

#include "BufferQueueInterposer.h"

@@ -42,19 +43,6 @@ BufferQueueInterposer::BufferQueueInterposer(
    mAcquired(false)
{
    BQI_LOGV("BufferQueueInterposer sink=%p", sink.get());

    // We need one additional dequeued buffer beyond what the source needs.
    // To have more than one (the default), we must call setBufferCount. But
    // we have no way of knowing what the sink has set as the minimum buffer
    // count, so if we just call setBufferCount(3) it may fail (and does, on
    // one device using a video encoder sink). So far on the devices we care
    // about, this is the smallest value that works.
    //
    // TODO: Change IGraphicBufferProducer and implementations to support this.
    // Maybe change it so both the consumer and producer declare how many
    // buffers they need, and the IGBP adds them? Then BQInterposer would just
    // add 1 to the source's buffer count.
    mSink->setBufferCount(6);
}

BufferQueueInterposer::~BufferQueueInterposer() {
+8 −8
Original line number Diff line number Diff line
@@ -59,20 +59,20 @@ namespace android {
//   existing interfaces have some problems when the implementation isn't the
//   final consumer.
//
// - The interposer needs at least one buffer in addition to those used by the
//   source and sink. setBufferCount and QueueBufferOutput both need to
//   account for this. It's not possible currently to do this generically,
//   since we can't find out how many buffers the source and sink need. (See
//   the horrible hack in the BufferQueueInterposer constructor).
// - The client of the interposer may need one or more buffers in addition to
//   those used by the source and sink. IGraphicBufferProducer will probably
//   need to change to allow the producer to specify how many buffers it needs
//   to dequeue at a time, and then the interposer can add its requirements to
//   those of the source.
//
// - Abandoning, disconnecting, and connecting need to pass through somehow.
//   There needs to be a way to tell the interposer client to release its
//   buffer immediately so it can be queued/released, e.g. when the source
//   calls disconnect().
//
// - Right now the source->BQI queue is synchronous even if the BQI->sink
//   queue is asynchronous. Need to figure out how asynchronous should behave
//   and implement that.
// - Right now the source->BQI queue is synchronous even if the BQI->sink queue
//   is asynchronous. Need to figure out how asynchronous should behave and
//   implement that.

class BufferQueueInterposer : public BnGraphicBufferProducer {
public:
+8 −7
Original line number Diff line number Diff line
@@ -43,15 +43,16 @@ public:
    // this frame. Some implementations may only push a new buffer to
    // HWComposer if GLES composition took place, others need to push a new
    // buffer on every frame.
    //
    // advanceFrame must be followed by a call to  onFrameCommitted before
    // advanceFrame may be called again.
    virtual status_t advanceFrame() = 0;

    // setReleaseFenceFd 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.
    virtual status_t setReleaseFenceFd(int fenceFd) = 0;
    // onFrameCommitted is called after the frame has been committed to the
    // 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 dump(String8& result) const = 0;

+2 −4
Original line number Diff line number Diff line
@@ -140,17 +140,15 @@ void FramebufferSurface::freeBufferLocked(int slotIndex) {
    }
}

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

status_t FramebufferSurface::compositionComplete()
Loading