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

Commit 70162527 authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge "Omit DISPLAY_DECORATION layers from CachedSets"

parents e22425bd 01b867f2
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -401,6 +401,19 @@ bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers
    return true;
}

namespace {
bool isDisplayDecoration(const CachedSet& cachedSet) {
    return cachedSet.getLayerCount() == 1 &&
            cachedSet.getFirstLayer()
                    .getState()
                    ->getOutputLayer()
                    ->getLayerFE()
                    .getCompositionState()
                    ->compositionType ==
            aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION;
}
} // namespace

std::vector<Flattener::Run> Flattener::findCandidateRuns(time_point now) const {
    ATRACE_CALL();
    std::vector<Run> runs;
@@ -424,7 +437,7 @@ std::vector<Flattener::Run> Flattener::findCandidateRuns(time_point now) const {
        }

        if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
            !currentSet->hasUnsupportedDataspace()) {
            !currentSet->hasUnsupportedDataspace() && !isDisplayDecoration(*currentSet)) {
            if (isPartOfRun) {
                builder.increment();
            } else {
+51 −0
Original line number Diff line number Diff line
@@ -1337,5 +1337,56 @@ TEST_F(FlattenerTest, flattenLayers_skipsColorLayers) {
    EXPECT_NE(nullptr, overrideBuffer4);
}

TEST_F(FlattenerTest, flattenLayers_skips_DISPLAY_DECORATION) {
    auto& layerState1 = mTestLayers[0]->layerState;
    const auto& overrideBuffer1 = layerState1->getOutputLayer()->getState().overrideInfo.buffer;

    auto& layerState2 = mTestLayers[1]->layerState;
    const auto& overrideBuffer2 = layerState2->getOutputLayer()->getState().overrideInfo.buffer;

    // The third layer uses DISPLAY_DECORATION, which should never be cached.
    auto& layerState3 = mTestLayers[2]->layerState;
    const auto& overrideBuffer3 = layerState3->getOutputLayer()->getState().overrideInfo.buffer;
    mTestLayers[2]->layerFECompositionState.compositionType =
            aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION;
    mTestLayers[2]->layerState->update(&mTestLayers[2]->outputLayer);

    const std::vector<const LayerState*> layers = {
            layerState1.get(),
            layerState2.get(),
            layerState3.get(),
    };

    initializeFlattener(layers);

    mTime += 200ms;
    initializeOverrideBuffer(layers);
    EXPECT_EQ(getNonBufferHash(layers),
              mFlattener->flattenLayers(layers, getNonBufferHash(layers), mTime));

    // This will render a CachedSet.
    EXPECT_CALL(mRenderEngine, drawLayers(_, _, _, _, _))
            .WillOnce(Return(ByMove(
                    futureOf<renderengine::RenderEngineResult>({NO_ERROR, base::unique_fd()}))));
    mFlattener->renderCachedSets(mOutputState, std::nullopt);

    // We've rendered a CachedSet, but we haven't merged it in.
    EXPECT_EQ(nullptr, overrideBuffer1);
    EXPECT_EQ(nullptr, overrideBuffer2);
    EXPECT_EQ(nullptr, overrideBuffer3);

    // This time we merge the CachedSet in, so we have a new hash, and we should
    // only have two sets.
    EXPECT_CALL(mRenderEngine, drawLayers(_, _, _, _, _)).Times(0);
    initializeOverrideBuffer(layers);
    EXPECT_NE(getNonBufferHash(layers),
              mFlattener->flattenLayers(layers, getNonBufferHash(layers), mTime));
    mFlattener->renderCachedSets(mOutputState, std::nullopt);

    EXPECT_NE(nullptr, overrideBuffer1);
    EXPECT_EQ(overrideBuffer1, overrideBuffer2);
    EXPECT_EQ(nullptr, overrideBuffer3);
}

} // namespace
} // namespace android::compositionengine