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

Commit b03bd4e9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "CCodec: use null wrapper instead of empty buffer" into sc-dev

parents 050b31fb 6f116907
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -1301,17 +1301,7 @@ RawGraphicOutputBuffers::RawGraphicOutputBuffers(

sp<Codec2Buffer> RawGraphicOutputBuffers::wrap(const std::shared_ptr<C2Buffer> &buffer) {
    if (buffer == nullptr) {
        sp<Codec2Buffer> c2buffer = ConstGraphicBlockBuffer::AllocateEmpty(
                mFormat,
                [lbp = mLocalBufferPool](size_t capacity) {
                    return lbp->newBuffer(capacity);
                });
        if (c2buffer == nullptr) {
            ALOGD("[%s] ConstGraphicBlockBuffer::AllocateEmpty failed", mName);
            return nullptr;
        }
        c2buffer->setRange(0, 0);
        return c2buffer;
        return new Codec2Buffer(mFormat, new ABuffer(nullptr, 0));
    } else {
        return ConstGraphicBlockBuffer::Allocate(
                mFormat,
+13 −0
Original line number Diff line number Diff line
@@ -106,6 +106,19 @@ TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
    }
}

TEST(RawGraphicOutputBuffersTest, WrapNullBuffer) {
    constexpr int32_t kWidth = 320;
    constexpr int32_t kHeight = 240;

    std::shared_ptr<RawGraphicOutputBuffers> buffers =
        GetRawGraphicOutputBuffers(kWidth, kHeight);

    sp<Codec2Buffer> buffer = buffers->wrap(nullptr);
    ASSERT_EQ(nullptr, buffer->base());
    ASSERT_EQ(0, buffer->size());
    ASSERT_EQ(0, buffer->offset());
}

TEST(RawGraphicOutputBuffersTest, FlexYuvColorFormat) {
    constexpr int32_t kWidth = 320;
    constexpr int32_t kHeight = 240;