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

Commit 468051e2 authored by Irvel's avatar Irvel
Browse files

Integrate SurfaceInterceptor into SurfaceFlinger

Change-Id: If18d967f2b69ed219f17a9afedb61884ad5f1dc8
parent 2b8ae01e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@ public:
    // needed gralloc buffers.
    static void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
            sp<IGraphicBufferConsumer>* outConsumer,
            const sp<IGraphicBufferAlloc>& allocator = NULL);
            const sp<IGraphicBufferAlloc>& allocator = NULL,
            bool consumerIsSurfaceFlinger = false);

private:
    BufferQueue(); // Create through createBufferQueue
+5 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class BufferQueueProducer : public BnGraphicBufferProducer,
public:
    friend class BufferQueue; // Needed to access binderDied

    BufferQueueProducer(const sp<BufferQueueCore>& core);
    BufferQueueProducer(const sp<BufferQueueCore>& core, bool consumerIsSurfaceFlinger = false);
    virtual ~BufferQueueProducer();

    // requestBuffer returns the GraphicBuffer for slot N.
@@ -225,6 +225,10 @@ private:

    uint32_t mStickyTransform;

    // This controls whether the GraphicBuffer pointer in the BufferItem is
    // cleared after being queued
    bool mConsumerIsSurfaceFlinger;

    // This saves the fence from the last queueBuffer, such that the
    // next queueBuffer call can throttle buffer production. The prior
    // queueBuffer's fence is not nessessarily available elsewhere,
+2 −1
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ public:
    // previous frames are pending. Frames queued while in synchronous mode
    // always trigger the callback. The item passed to the callback will contain
    // all of the information about the queued frame except for its
    // GraphicBuffer pointer, which will always be null.
    // GraphicBuffer pointer, which will always be null (except if the consumer
    // is SurfaceFlinger).
    //
    // This is called without any lock held and can be called concurrently
    // by multiple threads.
+3 −2
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ bool BufferQueue::ProxyConsumerListener::getFrameTimestamps(

void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
        sp<IGraphicBufferConsumer>* outConsumer,
        const sp<IGraphicBufferAlloc>& allocator) {
        const sp<IGraphicBufferAlloc>& allocator,
        bool consumerIsSurfaceFlinger) {
    LOG_ALWAYS_FATAL_IF(outProducer == NULL,
            "BufferQueue: outProducer must not be NULL");
    LOG_ALWAYS_FATAL_IF(outConsumer == NULL,
@@ -82,7 +83,7 @@ void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
    LOG_ALWAYS_FATAL_IF(core == NULL,
            "BufferQueue: failed to create BufferQueueCore");

    sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core));
    sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core, consumerIsSurfaceFlinger));
    LOG_ALWAYS_FATAL_IF(producer == NULL,
            "BufferQueue: failed to create BufferQueueProducer");

+11 −4
Original line number Diff line number Diff line
@@ -41,11 +41,13 @@

namespace android {

BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core) :
BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core,
        bool consumerIsSurfaceFlinger) :
    mCore(core),
    mSlots(core->mSlots),
    mConsumerName(),
    mStickyTransform(0),
    mConsumerIsSurfaceFlinger(consumerIsSurfaceFlinger),
    mLastQueueBufferFence(Fence::NO_FENCE),
    mLastQueuedTransform(0),
    mCallbackMutex(),
@@ -913,9 +915,14 @@ status_t BufferQueueProducer::queueBuffer(int slot,
        VALIDATE_CONSISTENCY();
    } // Autolock scope

    // Don't send the GraphicBuffer through the callback, and don't send
    // the slot number, since the consumer shouldn't need it
    // It is okay not to clear the GraphicBuffer when the consumer is SurfaceFlinger because
    // it is guaranteed that the BufferQueue is inside SurfaceFlinger's process and
    // there will be no Binder call
    if (!mConsumerIsSurfaceFlinger) {
        item.mGraphicBuffer.clear();
    }

    // Don't send the slot number through the callback since the consumer shouldn't need it
    item.mSlot = BufferItem::INVALID_BUFFER_SLOT;

    // Call back without the main BufferQueue lock held, but with the callback
Loading