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

Commit 7fb9e5a0 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Create layers with layerid

When recreating layer states from transaction traces
we need to create layers with a specific layer id.

Add the layer id as part of LayerCreationArgs and pass
the struct around instead of individual args.

Test: presubmit
Bug: 200284593
Change-Id: I029cdb5362d1926deaf2ce64f70a1882a418705b
parent c9963a2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -523,7 +523,7 @@ void BufferQueueLayer::gatherBufferInfo() {
}

sp<Layer> BufferQueueLayer::createClone() {
    LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, 0, 0, LayerMetadata());
    LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, LayerMetadata());
    args.textureName = mTextureName;
    sp<BufferQueueLayer> layer = mFlinger->getFactory().createBufferQueueLayer(args);
    layer->setInitialValuesForClone(this);
+5 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ public:
    status_t setDefaultBufferProperties(uint32_t w, uint32_t h, PixelFormat format);
    sp<IGraphicBufferProducer> getProducer() const;

    void setSizeForTest(uint32_t w, uint32_t h) {
        mDrawingState.active_legacy.w = w;
        mDrawingState.active_legacy.h = h;
    }

protected:
    void gatherBufferInfo() override;

+1 −1
Original line number Diff line number Diff line
@@ -890,7 +890,7 @@ Rect BufferStateLayer::computeBufferCrop(const State& s) {
}

sp<Layer> BufferStateLayer::createClone() {
    LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, 0, 0, LayerMetadata());
    LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, LayerMetadata());
    args.textureName = mTextureName;
    sp<BufferStateLayer> layer = mFlinger->getFactory().createBufferStateLayer(args);
    layer->mHwcSlotGenerator = mHwcSlotGenerator;
+19 −26
Original line number Diff line number Diff line
@@ -72,37 +72,30 @@ sp<Layer> Client::getLayerUser(const sp<IBinder>& handle) const
    return lbc;
}

status_t Client::createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format,
                               uint32_t flags, const sp<IBinder>& parentHandle,
                               LayerMetadata metadata, sp<IBinder>* handle,
                               sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
                               uint32_t* outTransformHint) {
status_t Client::createSurface(const String8& name, uint32_t /* w */, uint32_t /* h */,
                               PixelFormat /* format */, uint32_t flags,
                               const sp<IBinder>& parentHandle, LayerMetadata metadata,
                               sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* /* gbp */,
                               int32_t* outLayerId, uint32_t* outTransformHint) {
    // We rely on createLayer to check permissions.
    return mFlinger->createLayer(name, this, w, h, format, flags, std::move(metadata), handle, gbp,
                                 parentHandle, outLayerId, nullptr, outTransformHint);
}

status_t Client::createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h,
                                         PixelFormat format, uint32_t flags,
                                         const sp<IGraphicBufferProducer>& parent,
                                         LayerMetadata metadata, sp<IBinder>* handle,
                                         sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
                                         uint32_t* outTransformHint) {
    if (mFlinger->authenticateSurfaceTexture(parent) == false) {
        ALOGE("failed to authenticate surface texture");
        return BAD_VALUE;
    }

    const auto& layer = (static_cast<MonitoredProducer*>(parent.get()))->getLayer();
    if (layer == nullptr) {
        ALOGE("failed to find parent layer");
    LayerCreationArgs args(mFlinger.get(), this, name.c_str(), flags, std::move(metadata));
    return mFlinger->createLayer(args, outHandle, parentHandle, outLayerId, nullptr,
                                 outTransformHint);
}

status_t Client::createWithSurfaceParent(const String8& /* name */, uint32_t /* w */,
                                         uint32_t /* h */, PixelFormat /* format */,
                                         uint32_t /* flags */,
                                         const sp<IGraphicBufferProducer>& /* parent */,
                                         LayerMetadata /* metadata */, sp<IBinder>* /* handle */,
                                         sp<IGraphicBufferProducer>* /* gbp */,
                                         int32_t* /* outLayerId */,
                                         uint32_t* /* outTransformHint */) {
    // This api does not make sense with blast since SF no longer tracks IGBP. This api should be
    // removed.
    return BAD_VALUE;
}

    return mFlinger->createLayer(name, this, w, h, format, flags, std::move(metadata), handle, gbp,
                                 nullptr, outLayerId, layer, outTransformHint);
}

status_t Client::mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle,
                               int32_t* outLayerId) {
    return mFlinger->mirrorLayer(this, mirrorFromHandle, outHandle, outLayerId);
+1 −2
Original line number Diff line number Diff line
@@ -36,8 +36,7 @@ bool ContainerLayer::isVisible() const {

sp<Layer> ContainerLayer::createClone() {
    sp<ContainerLayer> layer = mFlinger->getFactory().createContainerLayer(
            LayerCreationArgs(mFlinger.get(), nullptr, mName + " (Mirror)", 0, 0, 0,
                              LayerMetadata()));
            LayerCreationArgs(mFlinger.get(), nullptr, mName + " (Mirror)", 0, LayerMetadata()));
    layer->setInitialValuesForClone(this);
    return layer;
}
Loading