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

Commit 200316cc authored by Pablo Ceballos's avatar Pablo Ceballos Committed by Android (Google) Code Review
Browse files

Merge "BQ: get rid of async in producer interface"

parents 4e547008 567dbbb6
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -85,25 +85,25 @@ private:
    // getMinUndequeuedBufferCountLocked returns the minimum number of buffers
    // that must remain in a state other than DEQUEUED. The async parameter
    // tells whether we're in asynchronous mode.
    int getMinUndequeuedBufferCountLocked(bool async) const;
    int getMinUndequeuedBufferCountLocked() const;

    // getMinMaxBufferCountLocked returns the minimum number of buffers allowed
    // given the current BufferQueue state. The async parameter tells whether
    // we're in asynchonous mode.
    int getMinMaxBufferCountLocked(bool async) const;
    int getMinMaxBufferCountLocked() const;

    // getMaxBufferCountLocked returns the maximum number of buffers that can be
    // allocated at once. This value depends on the following member variables:
    //
    //     mDequeueBufferCannotBlock
    //     mMaxDequeuedBufferCount
    //     mMaxAcquiredBufferCount
    //     mDefaultMaxBufferCount
    //     mOverrideMaxBufferCount
    //     async parameter
    //     mMaxBufferCount
    //     mAsyncMode
    //     mDequeueBufferCannotBlock
    //
    // Any time one of these member variables is changed while a producer is
    // connected, mDequeueCondition must be broadcast.
    int getMaxBufferCountLocked(bool async) const;
    int getMaxBufferCountLocked() const;

    // freeBufferLocked frees the GraphicBuffer and sync resources for the
    // given slot.
+4 −4
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public:
    // In both cases, the producer will need to call requestBuffer to get a
    // GraphicBuffer handle for the returned slot.
    virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence,
            bool async, uint32_t width, uint32_t height, PixelFormat format,
            uint32_t width, uint32_t height, PixelFormat format,
            uint32_t usage);

    // See IGraphicBufferProducer::detachBuffer
@@ -158,7 +158,7 @@ public:
    virtual status_t setSidebandStream(const sp<NativeHandle>& stream);

    // See IGraphicBufferProducer::allocateBuffers
    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
    virtual void allocateBuffers(uint32_t width, uint32_t height,
            PixelFormat format, uint32_t usage);

    // See IGraphicBufferProducer::allowAllocation
@@ -179,8 +179,8 @@ private:
    // mode (producer and consumer controlled by the application). If it blocks,
    // it will release mCore->mMutex while blocked so that other operations on
    // the BufferQueue may succeed.
    status_t waitForFreeSlotThenRelock(const char* caller, bool async,
            int* found, status_t* returnFlags) const;
    status_t waitForFreeSlotThenRelock(const char* caller, int* found,
            status_t* returnFlags) const;

    sp<BufferQueueCore> mCore;

+9 −16
Original line number Diff line number Diff line
@@ -147,9 +147,6 @@ public:
    // fence signals. If the fence is Fence::NO_FENCE, the buffer may be written
    // immediately.
    //
    // The async parameter sets whether we're in asynchronous mode for this
    // dequeueBuffer() call.
    //
    // The width and height parameters must be no greater than the minimum of
    // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
    // An error due to invalid dimensions might not be reported until
@@ -187,8 +184,8 @@ public:
    //
    // All other negative values are an unknown error returned downstream
    // from the graphics allocator (typically errno).
    virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
            uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0;
    virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w,
            uint32_t h, PixelFormat format, uint32_t usage) = 0;

    // detachBuffer attempts to remove all ownership of the buffer in the given
    // slot from the buffer queue. If this call succeeds, the slot will be
@@ -297,23 +294,21 @@ public:
        // crop - a crop rectangle that's used as a hint to the consumer
        // scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
        // transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
        // async - if the buffer is queued in asynchronous mode
        // fence - a fence that the consumer must wait on before reading the buffer,
        //         set this to Fence::NO_FENCE if the buffer is ready immediately
        // sticky - the sticky transform set in Surface (only used by the LEGACY
        //          camera mode).
        inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
                android_dataspace dataSpace, const Rect& crop, int scalingMode,
                uint32_t transform, bool async, const sp<Fence>& fence,
                uint32_t sticky = 0)
                uint32_t transform, const sp<Fence>& fence, uint32_t sticky = 0)
                : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
                  dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
                  transform(transform), stickyTransform(sticky),
                  async(async), fence(fence), surfaceDamage() { }
                  transform(transform), stickyTransform(sticky), fence(fence),
                  surfaceDamage() { }
        inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
                android_dataspace* outDataSpace,
                Rect* outCrop, int* outScalingMode,
                uint32_t* outTransform, bool* outAsync, sp<Fence>* outFence,
                uint32_t* outTransform, sp<Fence>* outFence,
                uint32_t* outStickyTransform = NULL) const {
            *outTimestamp = timestamp;
            *outIsAutoTimestamp = bool(isAutoTimestamp);
@@ -321,7 +316,6 @@ public:
            *outCrop = crop;
            *outScalingMode = scalingMode;
            *outTransform = transform;
            *outAsync = bool(async);
            *outFence = fence;
            if (outStickyTransform != NULL) {
                *outStickyTransform = stickyTransform;
@@ -345,7 +339,6 @@ public:
        int scalingMode;
        uint32_t transform;
        uint32_t stickyTransform;
        int async;
        sp<Fence> fence;
        Region surfaceDamage;
    };
@@ -381,8 +374,8 @@ public:
        uint32_t numPendingBuffers;
    };

    virtual status_t queueBuffer(int slot,
            const QueueBufferInput& input, QueueBufferOutput* output) = 0;
    virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
            QueueBufferOutput* output) = 0;

    // cancelBuffer indicates that the client does not wish to fill in the
    // buffer associated with slot and transfers ownership of the slot back to
@@ -493,7 +486,7 @@ public:
    // allocated. This is most useful to avoid an allocation delay during
    // dequeueBuffer. If there are already the maximum number of buffers
    // allocated, this function has no effect.
    virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
    virtual void allocateBuffers(uint32_t width, uint32_t height,
            PixelFormat format, uint32_t usage) = 0;

    // Sets whether dequeueBuffer is allowed to allocate new buffers.
+4 −2
Original line number Diff line number Diff line
@@ -527,11 +527,13 @@ status_t BufferQueueConsumer::setMaxAcquiredBufferCount(
    }

    if ((maxAcquiredBuffers + mCore->mMaxDequeuedBufferCount +
            (mCore->mAsyncMode ? 1 : 0)) > mCore->mMaxBufferCount) {
            (mCore->mAsyncMode || mCore->mDequeueBufferCannotBlock ? 1 : 0)) >
            mCore->mMaxBufferCount) {
        BQ_LOGE("setMaxAcquiredBufferCount: %d acquired buffers would exceed "
                "the maxBufferCount (%d) (maxDequeued %d async %d)",
                maxAcquiredBuffers, mCore->mMaxBufferCount,
                mCore->mMaxDequeuedBufferCount, mCore->mAsyncMode);
                mCore->mMaxDequeuedBufferCount, mCore->mAsyncMode ||
                mCore->mDequeueBufferCannotBlock);
        return BAD_VALUE;
    }

+13 −12
Original line number Diff line number Diff line
@@ -101,12 +101,13 @@ void BufferQueueCore::dump(String8& result, const char* prefix) const {
    }

    result.appendFormat("%s-BufferQueue mMaxAcquiredBufferCount=%d, "
            "mMaxDequeuedBufferCount=%d, mDequeueBufferCannotBlock=%d, "
            "default-size=[%dx%d], default-format=%d, transform-hint=%02x, "
            "FIFO(%zu)={%s}\n",
            prefix, mMaxAcquiredBufferCount, mMaxDequeuedBufferCount,
            mDequeueBufferCannotBlock, mDefaultWidth, mDefaultHeight,
            mDefaultBufferFormat, mTransformHint, mQueue.size(), fifo.string());
            "mMaxDequeuedBufferCount=%d, mDequeueBufferCannotBlock=%d "
            "mAsyncMode=%d, default-size=[%dx%d], default-format=%d, "
            "transform-hint=%02x, FIFO(%zu)={%s}\n", prefix,
            mMaxAcquiredBufferCount, mMaxDequeuedBufferCount,
            mDequeueBufferCannotBlock, mAsyncMode, mDefaultWidth,
            mDefaultHeight, mDefaultBufferFormat, mTransformHint, mQueue.size(),
            fifo.string());

    // Trim the free buffers so as to not spam the dump
    int maxBufferCount = 0;
@@ -137,23 +138,23 @@ void BufferQueueCore::dump(String8& result, const char* prefix) const {
    }
}

int BufferQueueCore::getMinUndequeuedBufferCountLocked(bool async) const {
int BufferQueueCore::getMinUndequeuedBufferCountLocked() const {
    // If dequeueBuffer is allowed to error out, we don't have to add an
    // extra buffer.
    if (mDequeueBufferCannotBlock || async) {
    if (mAsyncMode || mDequeueBufferCannotBlock) {
        return mMaxAcquiredBufferCount + 1;
    }

    return mMaxAcquiredBufferCount;
}

int BufferQueueCore::getMinMaxBufferCountLocked(bool async) const {
    return getMinUndequeuedBufferCountLocked(async) + 1;
int BufferQueueCore::getMinMaxBufferCountLocked() const {
    return getMinUndequeuedBufferCountLocked() + 1;
}

int BufferQueueCore::getMaxBufferCountLocked(bool async) const {
int BufferQueueCore::getMaxBufferCountLocked() const {
    int maxBufferCount = mMaxAcquiredBufferCount + mMaxDequeuedBufferCount +
            (async ? 1 : 0);
            (mAsyncMode || mDequeueBufferCannotBlock ? 1 : 0);

    // limit maxBufferCount by mMaxBufferCount always
    maxBufferCount = std::min(mMaxBufferCount, maxBufferCount);
Loading