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

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

Merge "SF: Add GL texture pool" into pi-dev

parents 0a3e7847 9fdb7e0c
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ BufferLayer::BufferLayer(SurfaceFlinger* flinger, const sp<Client>& client, cons
        mRefreshPending(false) {
        mRefreshPending(false) {
    ALOGV("Creating Layer %s", name.string());
    ALOGV("Creating Layer %s", name.string());


    mFlinger->getRenderEngine().genTextures(1, &mTextureName);
    mTextureName = mFlinger->getNewTexture();
    mTexture.init(Texture::TEXTURE_EXTERNAL, mTextureName);
    mTexture.init(Texture::TEXTURE_EXTERNAL, mTextureName);


    if (flags & ISurfaceComposerClient::eNonPremultiplied) mPremultipliedAlpha = false;
    if (flags & ISurfaceComposerClient::eNonPremultiplied) mPremultipliedAlpha = false;
@@ -706,8 +706,12 @@ void BufferLayer::onFirstRef() {
    sp<IGraphicBufferConsumer> consumer;
    sp<IGraphicBufferConsumer> consumer;
    BufferQueue::createBufferQueue(&producer, &consumer, true);
    BufferQueue::createBufferQueue(&producer, &consumer, true);
    mProducer = new MonitoredProducer(producer, mFlinger, this);
    mProducer = new MonitoredProducer(producer, mFlinger, this);
    mConsumer = new BufferLayerConsumer(consumer,
    {
            mFlinger->getRenderEngine(), mTextureName, this);
        // Grab the SF state lock during this since it's the only safe way to access RenderEngine
        Mutex::Autolock lock(mFlinger->mStateLock);
        mConsumer = new BufferLayerConsumer(consumer, mFlinger->getRenderEngine(), mTextureName,
                                            this);
    }
    mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
    mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
    mConsumer->setContentsChangedListener(this);
    mConsumer->setContentsChangedListener(this);
    mConsumer->setName(mName);
    mConsumer->setName(mName);
+2 −42
Original line number Original line Diff line number Diff line
@@ -170,48 +170,8 @@ status_t Client::createSurface(
        }
        }
    }
    }


    /*
    return mFlinger->createLayer(name, this, w, h, format, flags, windowType,
     * createSurface must be called from the GL thread so that it can
                                 ownerUid, handle, gbp, &parent);
     * have access to the GL context.
     */
    class MessageCreateLayer : public MessageBase {
        SurfaceFlinger* flinger;
        Client* client;
        sp<IBinder>* handle;
        sp<IGraphicBufferProducer>* gbp;
        status_t result;
        const String8& name;
        uint32_t w, h;
        PixelFormat format;
        uint32_t flags;
        sp<Layer>* parent;
        int32_t windowType;
        int32_t ownerUid;
    public:
        MessageCreateLayer(SurfaceFlinger* flinger,
                const String8& name, Client* client,
                uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
                sp<IBinder>* handle, int32_t windowType, int32_t ownerUid,
                sp<IGraphicBufferProducer>* gbp,
                sp<Layer>* parent)
            : flinger(flinger), client(client),
              handle(handle), gbp(gbp), result(NO_ERROR),
              name(name), w(w), h(h), format(format), flags(flags),
              parent(parent), windowType(windowType), ownerUid(ownerUid) {
        }
        status_t getResult() const { return result; }
        virtual bool handler() {
            result = flinger->createLayer(name, client, w, h, format, flags,
                    windowType, ownerUid, handle, gbp, parent);
            return true;
        }
    };

    sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(),
            name, this, w, h, format, flags, handle,
            windowType, ownerUid, gbp, &parent);
    mFlinger->postMessageSync(msg);
    return static_cast<MessageCreateLayer*>( msg.get() )->getResult();
}
}


status_t Client::destroySurface(const sp<IBinder>& handle) {
status_t Client::destroySurface(const sp<IBinder>& handle) {
+2 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,8 @@ public:
    bool isVisible() const override;
    bool isVisible() const override;


    void setPerFrameData(const sp<const DisplayDevice>& displayDevice) override;
    void setPerFrameData(const sp<const DisplayDevice>& displayDevice) override;

    bool isCreatedFromMainThread() const override { return true; }
};
};


} // namespace android
} // namespace android
+15 −6
Original line number Original line Diff line number Diff line
@@ -130,17 +130,26 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
    // drawing state & current state are identical
    // drawing state & current state are identical
    mDrawingState = mCurrentState;
    mDrawingState = mCurrentState;


    const auto& hwc = flinger->getHwComposer();
    const auto& activeConfig = hwc.getActiveConfig(HWC_DISPLAY_PRIMARY);
    nsecs_t displayPeriod = activeConfig->getVsyncPeriod();
    mFrameTracker.setDisplayRefreshPeriod(displayPeriod);

    CompositorTiming compositorTiming;
    CompositorTiming compositorTiming;
    flinger->getCompositorTiming(&compositorTiming);
    flinger->getCompositorTiming(&compositorTiming);
    mFrameEventHistory.initializeCompositorTiming(compositorTiming);
    mFrameEventHistory.initializeCompositorTiming(compositorTiming);
}
}


void Layer::onFirstRef() {}
void Layer::onFirstRef() NO_THREAD_SAFETY_ANALYSIS {
    if (!isCreatedFromMainThread()) {
        // Grab the SF state lock during this since it's the only way to safely access HWC
        mFlinger->mStateLock.lock();
    }

    const auto& hwc = mFlinger->getHwComposer();
    const auto& activeConfig = hwc.getActiveConfig(HWC_DISPLAY_PRIMARY);
    nsecs_t displayPeriod = activeConfig->getVsyncPeriod();
    mFrameTracker.setDisplayRefreshPeriod(displayPeriod);

    if (!isCreatedFromMainThread()) {
        mFlinger->mStateLock.unlock();
    }
}


Layer::~Layer() {
Layer::~Layer() {
    sp<Client> c(mClientRef.promote());
    sp<Client> c(mClientRef.promote());
+5 −0
Original line number Original line Diff line number Diff line
@@ -360,6 +360,11 @@ public:
     */
     */
    virtual bool isFixedSize() const { return true; }
    virtual bool isFixedSize() const { return true; }


    // Most layers aren't created from the main thread, and therefore need to
    // grab the SF state lock to access HWC, but ContainerLayer does, so we need
    // to avoid grabbing the lock again to avoid deadlock
    virtual bool isCreatedFromMainThread() const { return false; }



    bool isPendingRemoval() const { return mPendingRemoval; }
    bool isPendingRemoval() const { return mPendingRemoval; }


Loading