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

Commit bb409682 authored by John Reck's avatar John Reck
Browse files

Avoid caching EGL_SINGLE_BUFFER layers

Bug: 217776226
Test: pendemo test app updates
Change-Id: I6dde657aac1e260b5479d34120e6ca360e2616be
parent 37ac7569
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -311,6 +311,7 @@ void BufferLayer::preparePerFrameCompositionState() {
            ? 0
            ? 0
            : mBufferInfo.mBufferSlot;
            : mBufferInfo.mBufferSlot;
    compositionState->acquireFence = mBufferInfo.mFence;
    compositionState->acquireFence = mBufferInfo.mFence;
    compositionState->frameNumber = mBufferInfo.mFrameNumber;
    compositionState->sidebandStreamHasFrame = false;
    compositionState->sidebandStreamHasFrame = false;
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -166,6 +166,7 @@ struct LayerFECompositionState {
    int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
    int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
    sp<Fence> acquireFence = Fence::NO_FENCE;
    sp<Fence> acquireFence = Fence::NO_FENCE;
    Region surfaceDamage;
    Region surfaceDamage;
    uint64_t frameNumber = 0;


    // The handle to use for a sideband stream for this layer
    // The handle to use for a sideband stream for this layer
    sp<NativeHandle> sidebandStream;
    sp<NativeHandle> sidebandStream;
+8 −1
Original line number Original line Diff line number Diff line
@@ -405,6 +405,12 @@ private:
                                                                  : nullptr)};
                                                                  : nullptr)};
                    }};
                    }};


    // Even if the same buffer is passed to BLAST's setBuffer(), we still increment the frame
    // number and need to treat it as if the buffer changed. Otherwise we break existing
    // front-buffer rendering paths (such as egl's EGL_SINGLE_BUFFER).
    OutputLayerState<uint64_t, LayerStateField::Buffer> mFrameNumber{
            [](auto layer) { return layer->getLayerFE().getCompositionState()->frameNumber; }};

    int64_t mFramesSinceBufferUpdate = 0;
    int64_t mFramesSinceBufferUpdate = 0;


    OutputLayerState<half4, LayerStateField::SolidColor>
    OutputLayerState<half4, LayerStateField::SolidColor>
@@ -453,7 +459,7 @@ private:
                                      return hash;
                                      return hash;
                                  }};
                                  }};


    static const constexpr size_t kNumNonUniqueFields = 16;
    static const constexpr size_t kNumNonUniqueFields = 17;


    std::array<StateInterface*, kNumNonUniqueFields> getNonUniqueFields() {
    std::array<StateInterface*, kNumNonUniqueFields> getNonUniqueFields() {
        std::array<const StateInterface*, kNumNonUniqueFields> constFields =
        std::array<const StateInterface*, kNumNonUniqueFields> constFields =
@@ -472,6 +478,7 @@ private:
                &mAlpha,        &mLayerMetadata,  &mVisibleRegion,        &mOutputDataspace,
                &mAlpha,        &mLayerMetadata,  &mVisibleRegion,        &mOutputDataspace,
                &mPixelFormat,  &mColorTransform, &mCompositionType,      &mSidebandStream,
                &mPixelFormat,  &mColorTransform, &mCompositionType,      &mSidebandStream,
                &mBuffer,       &mSolidColor,     &mBackgroundBlurRadius, &mBlurRegions,
                &mBuffer,       &mSolidColor,     &mBackgroundBlurRadius, &mBlurRegions,
                &mFrameNumber,
        };
        };
    }
    }
};
};
+24 −0
Original line number Original line Diff line number Diff line
@@ -359,6 +359,30 @@ TEST_F(LayerStateTest, updateBuffer) {
    EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
    EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
}
}


TEST_F(LayerStateTest, updateBufferSingleBufferedLegacy) {
    OutputLayerCompositionState outputLayerCompositionState;
    LayerFECompositionState layerFECompositionState;
    layerFECompositionState.buffer = new GraphicBuffer();
    setupMocksForLayer(mOutputLayer, *mLayerFE, outputLayerCompositionState,
                       layerFECompositionState);
    mLayerState = std::make_unique<LayerState>(&mOutputLayer);

    mock::OutputLayer newOutputLayer;
    sp<mock::LayerFE> newLayerFE = sp<mock::LayerFE>::make();
    LayerFECompositionState layerFECompositionStateTwo;
    layerFECompositionStateTwo.buffer = new GraphicBuffer();
    setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
                       layerFECompositionStateTwo);

    for (uint64_t i = 0; i < 10; i++) {
        layerFECompositionStateTwo.frameNumber = i;
        setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
                           layerFECompositionStateTwo);
        Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
        EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
    }
}

TEST_F(LayerStateTest, compareBuffer) {
TEST_F(LayerStateTest, compareBuffer) {
    OutputLayerCompositionState outputLayerCompositionState;
    OutputLayerCompositionState outputLayerCompositionState;
    LayerFECompositionState layerFECompositionState;
    LayerFECompositionState layerFECompositionState;