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

Commit 328dea05 authored by Anton Ivanov's avatar Anton Ivanov Committed by Android (Google) Code Review
Browse files

Merge "Harden construction sites of android::StrongPointer." into main

parents 7ad24b9b 81793808
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -197,12 +197,12 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, bool updateDestinati
        mUpdateDestinationFrame(updateDestinationFrame) {
    createBufferQueue(&mProducer, &mConsumer);
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
    mBufferItemConsumer = new BLASTBufferItemConsumer(mProducer, mConsumer,
    mBufferItemConsumer = sp<BLASTBufferItemConsumer>::make(mProducer, mConsumer,
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                            1, false, this);
#else
    mBufferItemConsumer = new BLASTBufferItemConsumer(mConsumer,
    mBufferItemConsumer = sp<BLASTBufferItemConsumer>::make(mConsumer,
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                            1, false, this);
@@ -637,7 +637,8 @@ status_t BLASTBufferQueue::acquireNextBufferLocked(
                           bufferItem.mScalingMode, crop);

    auto releaseBufferCallback = makeReleaseBufferCallbackThunk();
    sp<Fence> fence = bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE;
    sp<Fence> fence =
            bufferItem.mFence ? sp<Fence>::make(bufferItem.mFence->dup()) : Fence::NO_FENCE;

    nsecs_t dequeueTime = -1;
    {
@@ -1014,7 +1015,8 @@ sp<Surface> BLASTBufferQueue::getSurface(bool includeSurfaceControlHandle) {
    if (includeSurfaceControlHandle && mSurfaceControl) {
        scHandle = mSurfaceControl->getHandle();
    }
    return new BBQSurface(mProducer, true, scHandle, this);
    return sp<BBQSurface>::make(mProducer, true, scHandle,
                                sp<BLASTBufferQueue>::fromExisting(this));
}

void BLASTBufferQueue::mergeWithNextTransaction(SurfaceComposerClient::Transaction* t,
@@ -1177,7 +1179,7 @@ public:
            return BufferQueueProducer::connect(listener, api, producerControlledByApp, output);
        }

        return BufferQueueProducer::connect(new AsyncProducerListener(listener), api,
        return BufferQueueProducer::connect(sp<AsyncProducerListener>::make(listener), api,
                                            producerControlledByApp, output);
    }

+2 −2
Original line number Diff line number Diff line
@@ -215,14 +215,14 @@ status_t BufferItem::unflatten(
    FlattenableUtils::read(buffer, size, flags);

    if (flags & 1) {
        mGraphicBuffer = new GraphicBuffer();
        mGraphicBuffer = sp<GraphicBuffer>::make();
        status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
        if (err) return err;
        size -= FlattenableUtils::align<4>(buffer);
    }

    if (flags & 2) {
        mFence = new Fence();
        mFence = sp<Fence>::make();
        status_t err = mFence->unflatten(buffer, size, fds, count);
        if (err) return err;
        size -= FlattenableUtils::align<4>(buffer);
+4 −3
Original line number Diff line number Diff line
@@ -125,15 +125,16 @@ void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
    LOG_ALWAYS_FATAL_IF(outConsumer == nullptr,
            "BufferQueue: outConsumer must not be NULL");

    sp<BufferQueueCore> core(new BufferQueueCore());
    sp<BufferQueueCore> core = sp<BufferQueueCore>::make();
    LOG_ALWAYS_FATAL_IF(core == nullptr,
            "BufferQueue: failed to create BufferQueueCore");

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

    sp<IGraphicBufferConsumer> consumer(new BufferQueueConsumer(core));
    sp<IGraphicBufferConsumer> consumer = sp<BufferQueueConsumer>::make(core);
    LOG_ALWAYS_FATAL_IF(consumer == nullptr,
            "BufferQueue: failed to create BufferQueueConsumer");

+9 −10
Original line number Diff line number Diff line
@@ -693,11 +693,11 @@ status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* ou
                .requestorName = {mConsumerName.c_str(), mConsumerName.size()},
                .extras = std::move(tempOptions),
        };
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest);
        sp<GraphicBuffer> graphicBuffer = sp<GraphicBuffer>::make(allocRequest);
#else
        sp<GraphicBuffer> graphicBuffer =
                new GraphicBuffer(width, height, format, BQ_LAYER_COUNT, usage,
                                  {mConsumerName.c_str(), mConsumerName.size()});
                sp<GraphicBuffer>::make(width, height, format, BQ_LAYER_COUNT, usage,
                                        std::string{mConsumerName.c_str(), mConsumerName.size()});
#endif

        status_t error = graphicBuffer->initCheck();
@@ -1464,7 +1464,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
#ifndef NO_BINDER
                if (IInterface::asBinder(listener)->remoteBinder() != nullptr) {
                    status = IInterface::asBinder(listener)->linkToDeath(
                            static_cast<IBinder::DeathRecipient*>(this));
                            sp<IBinder::DeathRecipient>::fromExisting(this));
                    if (status != NO_ERROR) {
                        BQ_LOGE("connect: linkToDeath failed: %s (%d)",
                                strerror(-status), status);
@@ -1553,8 +1553,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) {
                                IInterface::asBinder(mCore->mLinkedToDeath);
                        // This can fail if we're here because of the death
                        // notification, but we just ignore it
                        token->unlinkToDeath(
                                static_cast<IBinder::DeathRecipient*>(this));
                        token->unlinkToDeath(sp<IBinder::DeathRecipient>::fromExisting(this));
                    }
#endif
                    mCore->mSharedBufferSlot =
@@ -1685,10 +1684,10 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
#endif

#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest);
        sp<GraphicBuffer> graphicBuffer = sp<GraphicBuffer>::make(allocRequest);
#else
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
                allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
        sp<GraphicBuffer> graphicBuffer =
                sp<GraphicBuffer>::make(allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
                                        allocUsage, allocName);
#endif

+2 −2
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ status_t BufferReleaseChannel::Message::flatten(void*& buffer, size_t& size, int

status_t BufferReleaseChannel::Message::unflatten(void const*& buffer, size_t& size,
                                                  int const*& fds, size_t& count) {
    releaseFence = new Fence();
    releaseFence = sp<Fence>::make();
    if (status_t err = releaseFence->unflatten(buffer, size, fds, count); err != OK) {
        return err;
    }
Loading