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

Commit d7ba0ce7 authored by Leon Scroggins's avatar Leon Scroggins Committed by Automerger Merge Worker
Browse files

Merge "Remove fatal assert from CachedSet::render" into sc-dev am: 3b71371d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14826088

Change-Id: I0337f57f76329d874634e6e40978d68613d7989f
parents d6f82a5b 3b71371d
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -228,7 +228,6 @@ void CachedSet::render(renderengine::RenderEngine& renderEngine,
        // Assume that the final layer contains the buffer that we want to
        // Assume that the final layer contains the buffer that we want to
        // replace with a hole punch.
        // replace with a hole punch.
        holePunchSettings = clientCompositionList.back();
        holePunchSettings = clientCompositionList.back();
        LOG_ALWAYS_FATAL_IF(!holePunchSettings.source.buffer.buffer, "Expected to have a buffer!");
        // This mimics Layer::prepareClearClientComposition
        // This mimics Layer::prepareClearClientComposition
        holePunchSettings.source.buffer.buffer = nullptr;
        holePunchSettings.source.buffer.buffer = nullptr;
        holePunchSettings.source.solidColor = half3(0.0f, 0.0f, 0.0f);
        holePunchSettings.source.solidColor = half3(0.0f, 0.0f, 0.0f);
+50 −0
Original line number Original line Diff line number Diff line
@@ -557,6 +557,56 @@ TEST_F(CachedSetTest, addHolePunch) {
    cachedSet.render(mRenderEngine, mOutputState);
    cachedSet.render(mRenderEngine, mOutputState);
}
}


TEST_F(CachedSetTest, addHolePunch_noBuffer) {
    // Same as addHolePunch, except that clientCompList3 does not contain a
    // buffer. This imitates the case where the buffer had protected content, so
    // BufferLayer did not add it to the LayerSettings. This should not assert.
    mTestLayers[0]->outputLayerCompositionState.displayFrame = Rect(0, 0, 5, 5);
    CachedSet::Layer& layer1 = *mTestLayers[0]->cachedSetLayer.get();
    sp<mock::LayerFE> layerFE1 = mTestLayers[0]->layerFE;

    CachedSet::Layer& layer2 = *mTestLayers[1]->cachedSetLayer.get();
    sp<mock::LayerFE> layerFE2 = mTestLayers[1]->layerFE;

    CachedSet::Layer& layer3 = *mTestLayers[2]->cachedSetLayer.get();
    sp<mock::LayerFE> layerFE3 = mTestLayers[2]->layerFE;

    CachedSet cachedSet(layer1);
    cachedSet.addLayer(layer2.getState(), kStartTime + 10ms);

    cachedSet.addHolePunchLayerIfFeasible(layer3, true);

    std::vector<compositionengine::LayerFE::LayerSettings> clientCompList1;
    clientCompList1.push_back({});
    std::vector<compositionengine::LayerFE::LayerSettings> clientCompList2;
    clientCompList2.push_back({});
    std::vector<compositionengine::LayerFE::LayerSettings> clientCompList3;
    clientCompList3.push_back({});

    EXPECT_CALL(*layerFE1, prepareClientCompositionList(_)).WillOnce(Return(clientCompList1));
    EXPECT_CALL(*layerFE2, prepareClientCompositionList(_)).WillOnce(Return(clientCompList2));
    EXPECT_CALL(*layerFE3, prepareClientCompositionList(_)).WillOnce(Return(clientCompList3));

    const auto drawLayers = [&](const renderengine::DisplaySettings&,
                                const std::vector<const renderengine::LayerSettings*>& layers,
                                const std::shared_ptr<renderengine::ExternalTexture>&, const bool,
                                base::unique_fd&&, base::unique_fd*) -> size_t {
        // If the highlight layer is enabled, it will increase the size by 1.
        // We're interested in the third layer either way.
        EXPECT_GE(layers.size(), 3u);
        const auto* holePunchSettings = layers[2];
        EXPECT_EQ(nullptr, holePunchSettings->source.buffer.buffer);
        EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchSettings->source.solidColor);
        EXPECT_TRUE(holePunchSettings->disableBlending);
        EXPECT_EQ(0.0f, holePunchSettings->alpha);

        return NO_ERROR;
    };

    EXPECT_CALL(mRenderEngine, drawLayers(_, _, _, _, _, _)).WillOnce(Invoke(drawLayers));
    cachedSet.render(mRenderEngine, mOutputState);
}

TEST_F(CachedSetTest, decompose_removesHolePunch) {
TEST_F(CachedSetTest, decompose_removesHolePunch) {
    mTestLayers[0]->outputLayerCompositionState.displayFrame = Rect(0, 0, 5, 5);
    mTestLayers[0]->outputLayerCompositionState.displayFrame = Rect(0, 0, 5, 5);
    CachedSet::Layer& layer1 = *mTestLayers[0]->cachedSetLayer.get();
    CachedSet::Layer& layer1 = *mTestLayers[0]->cachedSetLayer.get();