Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 17 | #include <compositionengine/CompositionRefreshArgs.h> |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 18 | #include <compositionengine/LayerFECompositionState.h> |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 19 | #include <compositionengine/impl/CompositionEngine.h> |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 20 | #include <compositionengine/mock/LayerFE.h> |
| 21 | #include <compositionengine/mock/Output.h> |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 22 | #include <compositionengine/mock/OutputLayer.h> |
Leon Scroggins III | 2f60d73 | 2022-09-12 14:42:38 -0400 | [diff] [blame^] | 23 | #include <ftl/future.h> |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 24 | #include <gtest/gtest.h> |
Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 25 | #include <renderengine/mock/RenderEngine.h> |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 26 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 27 | #include "MockHWComposer.h" |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 28 | #include "TimeStats/TimeStats.h" |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 29 | |
Leon Scroggins III | 2f60d73 | 2022-09-12 14:42:38 -0400 | [diff] [blame^] | 30 | #include <variant> |
| 31 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 32 | namespace android::compositionengine { |
| 33 | namespace { |
| 34 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 35 | using ::testing::_; |
Haibo Huang | f66b752 | 2020-09-10 18:20:30 -0700 | [diff] [blame] | 36 | using ::testing::DoAll; |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 37 | using ::testing::InSequence; |
| 38 | using ::testing::Ref; |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 39 | using ::testing::Return; |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 40 | using ::testing::ReturnRef; |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 41 | using ::testing::SaveArg; |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 42 | using ::testing::StrictMock; |
| 43 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 44 | struct CompositionEngineTest : public testing::Test { |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 45 | std::shared_ptr<TimeStats> mTimeStats; |
| 46 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 47 | impl::CompositionEngine mEngine; |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 48 | CompositionRefreshArgs mRefreshArgs; |
| 49 | |
| 50 | std::shared_ptr<mock::Output> mOutput1{std::make_shared<StrictMock<mock::Output>>()}; |
| 51 | std::shared_ptr<mock::Output> mOutput2{std::make_shared<StrictMock<mock::Output>>()}; |
| 52 | std::shared_ptr<mock::Output> mOutput3{std::make_shared<StrictMock<mock::Output>>()}; |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 55 | TEST_F(CompositionEngineTest, canInstantiateCompositionEngine) { |
| 56 | auto engine = impl::createCompositionEngine(); |
| 57 | EXPECT_TRUE(engine.get() != nullptr); |
| 58 | } |
| 59 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 60 | TEST_F(CompositionEngineTest, canSetHWComposer) { |
Ady Abraham | eca9d75 | 2021-03-03 12:20:00 -0800 | [diff] [blame] | 61 | android::mock::HWComposer* hwc = new StrictMock<android::mock::HWComposer>(); |
| 62 | mEngine.setHwComposer(std::unique_ptr<android::HWComposer>(hwc)); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 63 | |
Ady Abraham | eca9d75 | 2021-03-03 12:20:00 -0800 | [diff] [blame] | 64 | EXPECT_EQ(hwc, &mEngine.getHwComposer()); |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 67 | TEST_F(CompositionEngineTest, canSetRenderEngine) { |
Patrick Williams | 0a525a4 | 2022-10-26 20:20:50 +0000 | [diff] [blame] | 68 | auto renderEngine = std::make_unique<StrictMock<renderengine::mock::RenderEngine>>(); |
| 69 | mEngine.setRenderEngine(renderEngine.get()); |
Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 70 | |
Patrick Williams | 0a525a4 | 2022-10-26 20:20:50 +0000 | [diff] [blame] | 71 | EXPECT_EQ(renderEngine.get(), &mEngine.getRenderEngine()); |
Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 74 | TEST_F(CompositionEngineTest, canSetTimeStats) { |
| 75 | mEngine.setTimeStats(mTimeStats); |
| 76 | |
Patrick Williams | 74c0bf6 | 2022-11-02 23:59:26 +0000 | [diff] [blame] | 77 | EXPECT_EQ(mTimeStats.get(), mEngine.getTimeStats()); |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 80 | /* |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 81 | * CompositionEngine::present |
| 82 | */ |
| 83 | |
| 84 | struct CompositionEnginePresentTest : public CompositionEngineTest { |
| 85 | struct CompositionEnginePartialMock : public impl::CompositionEngine { |
| 86 | // These are the overridable functions CompositionEngine::present() may |
| 87 | // call, and have separate test coverage. |
| 88 | MOCK_METHOD1(preComposition, void(CompositionRefreshArgs&)); |
| 89 | }; |
| 90 | |
| 91 | StrictMock<CompositionEnginePartialMock> mEngine; |
| 92 | }; |
| 93 | |
| 94 | TEST_F(CompositionEnginePresentTest, worksWithEmptyRequest) { |
| 95 | // present() always calls preComposition() |
| 96 | EXPECT_CALL(mEngine, preComposition(Ref(mRefreshArgs))); |
| 97 | |
| 98 | mEngine.present(mRefreshArgs); |
| 99 | } |
| 100 | |
| 101 | TEST_F(CompositionEnginePresentTest, worksAsExpected) { |
| 102 | // Expect calls to in a certain sequence |
| 103 | InSequence seq; |
| 104 | |
| 105 | // present() always calls preComposition() |
| 106 | EXPECT_CALL(mEngine, preComposition(Ref(mRefreshArgs))); |
| 107 | |
| 108 | // The first step in presenting is to make sure all outputs are prepared. |
| 109 | EXPECT_CALL(*mOutput1, prepare(Ref(mRefreshArgs), _)); |
| 110 | EXPECT_CALL(*mOutput2, prepare(Ref(mRefreshArgs), _)); |
| 111 | EXPECT_CALL(*mOutput3, prepare(Ref(mRefreshArgs), _)); |
| 112 | |
Leon Scroggins III | 2f60d73 | 2022-09-12 14:42:38 -0400 | [diff] [blame^] | 113 | if (FlagManager::getInstance().multithreaded_present()) { |
| 114 | EXPECT_CALL(*mOutput1, getDisplayId()).WillOnce(Return(std::nullopt)); |
| 115 | EXPECT_CALL(*mOutput2, getDisplayId()).WillOnce(Return(std::nullopt)); |
| 116 | EXPECT_CALL(*mOutput3, getDisplayId()).WillOnce(Return(std::nullopt)); |
| 117 | } |
| 118 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 119 | // The last step is to actually present each output. |
Leon Scroggins III | 2f60d73 | 2022-09-12 14:42:38 -0400 | [diff] [blame^] | 120 | EXPECT_CALL(*mOutput1, present(Ref(mRefreshArgs))) |
| 121 | .WillOnce(Return(ftl::yield<std::monostate>({}))); |
| 122 | EXPECT_CALL(*mOutput2, present(Ref(mRefreshArgs))) |
| 123 | .WillOnce(Return(ftl::yield<std::monostate>({}))); |
| 124 | EXPECT_CALL(*mOutput3, present(Ref(mRefreshArgs))) |
| 125 | .WillOnce(Return(ftl::yield<std::monostate>({}))); |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 126 | |
| 127 | mRefreshArgs.outputs = {mOutput1, mOutput2, mOutput3}; |
| 128 | mEngine.present(mRefreshArgs); |
| 129 | } |
| 130 | |
| 131 | /* |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 132 | * CompositionEngine::updateCursorAsync |
| 133 | */ |
| 134 | |
| 135 | struct CompositionEngineUpdateCursorAsyncTest : public CompositionEngineTest { |
| 136 | public: |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 137 | struct Layer { |
Ady Abraham | eca9d75 | 2021-03-03 12:20:00 -0800 | [diff] [blame] | 138 | Layer() { EXPECT_CALL(outputLayer, getLayerFE()).WillRepeatedly(ReturnRef(*layerFE)); } |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 139 | |
| 140 | StrictMock<mock::OutputLayer> outputLayer; |
Ady Abraham | eca9d75 | 2021-03-03 12:20:00 -0800 | [diff] [blame] | 141 | sp<StrictMock<mock::LayerFE>> layerFE = sp<StrictMock<mock::LayerFE>>::make(); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 142 | LayerFECompositionState layerFEState; |
| 143 | }; |
| 144 | |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 145 | CompositionEngineUpdateCursorAsyncTest() { |
Lloyd Pique | 0a45623 | 2020-01-16 17:51:13 -0800 | [diff] [blame] | 146 | EXPECT_CALL(*mOutput1, getOutputLayerCount()).WillRepeatedly(Return(0u)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 147 | EXPECT_CALL(*mOutput1, getOutputLayerOrderedByZByIndex(_)).Times(0); |
| 148 | |
Lloyd Pique | 0a45623 | 2020-01-16 17:51:13 -0800 | [diff] [blame] | 149 | EXPECT_CALL(*mOutput2, getOutputLayerCount()).WillRepeatedly(Return(1u)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 150 | EXPECT_CALL(*mOutput2, getOutputLayerOrderedByZByIndex(0)) |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 151 | .WillRepeatedly(Return(&mOutput2Layer1.outputLayer)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 152 | |
Lloyd Pique | 0a45623 | 2020-01-16 17:51:13 -0800 | [diff] [blame] | 153 | EXPECT_CALL(*mOutput3, getOutputLayerCount()).WillRepeatedly(Return(2u)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 154 | EXPECT_CALL(*mOutput3, getOutputLayerOrderedByZByIndex(0)) |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 155 | .WillRepeatedly(Return(&mOutput3Layer1.outputLayer)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 156 | EXPECT_CALL(*mOutput3, getOutputLayerOrderedByZByIndex(1)) |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 157 | .WillRepeatedly(Return(&mOutput3Layer2.outputLayer)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 160 | Layer mOutput2Layer1; |
| 161 | Layer mOutput3Layer1; |
| 162 | Layer mOutput3Layer2; |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 163 | }; |
| 164 | |
| 165 | TEST_F(CompositionEngineUpdateCursorAsyncTest, handlesNoOutputs) { |
| 166 | mEngine.updateCursorAsync(mRefreshArgs); |
| 167 | } |
| 168 | |
| 169 | TEST_F(CompositionEngineUpdateCursorAsyncTest, handlesNoLayersBeingCursorLayers) { |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 170 | EXPECT_CALL(mOutput3Layer1.outputLayer, isHardwareCursor()).WillRepeatedly(Return(false)); |
| 171 | EXPECT_CALL(mOutput3Layer2.outputLayer, isHardwareCursor()).WillRepeatedly(Return(false)); |
| 172 | EXPECT_CALL(mOutput2Layer1.outputLayer, isHardwareCursor()).WillRepeatedly(Return(false)); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 173 | |
| 174 | mRefreshArgs.outputs = {mOutput1, mOutput2, mOutput3}; |
| 175 | |
| 176 | mEngine.updateCursorAsync(mRefreshArgs); |
| 177 | } |
| 178 | |
| 179 | TEST_F(CompositionEngineUpdateCursorAsyncTest, handlesMultipleLayersBeingCursorLayers) { |
| 180 | { |
| 181 | InSequence seq; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 182 | EXPECT_CALL(mOutput2Layer1.outputLayer, isHardwareCursor()).WillRepeatedly(Return(true)); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 183 | EXPECT_CALL(mOutput2Layer1.outputLayer, writeCursorPositionToHWC()); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | { |
| 187 | InSequence seq; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 188 | EXPECT_CALL(mOutput3Layer1.outputLayer, isHardwareCursor()).WillRepeatedly(Return(true)); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 189 | EXPECT_CALL(mOutput3Layer1.outputLayer, writeCursorPositionToHWC()); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | { |
| 193 | InSequence seq; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 194 | EXPECT_CALL(mOutput3Layer2.outputLayer, isHardwareCursor()).WillRepeatedly(Return(true)); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 195 | EXPECT_CALL(mOutput3Layer2.outputLayer, writeCursorPositionToHWC()); |
Lloyd Pique | aed56ab | 2019-11-13 22:34:11 -0800 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | mRefreshArgs.outputs = {mOutput1, mOutput2, mOutput3}; |
| 199 | |
| 200 | mEngine.updateCursorAsync(mRefreshArgs); |
| 201 | } |
| 202 | |
| 203 | /* |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 204 | * CompositionEngine::preComposition |
| 205 | */ |
| 206 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 207 | struct CompositionTestPreComposition : public CompositionEngineTest { |
Ady Abraham | e0eafa8 | 2022-02-02 19:30:47 -0800 | [diff] [blame] | 208 | sp<StrictMock<mock::LayerFE>> mLayer1FE = sp<StrictMock<mock::LayerFE>>::make(); |
| 209 | sp<StrictMock<mock::LayerFE>> mLayer2FE = sp<StrictMock<mock::LayerFE>>::make(); |
| 210 | sp<StrictMock<mock::LayerFE>> mLayer3FE = sp<StrictMock<mock::LayerFE>>::make(); |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 211 | }; |
| 212 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 213 | TEST_F(CompositionTestPreComposition, preCompositionSetsFrameTimestamp) { |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 214 | const nsecs_t before = systemTime(SYSTEM_TIME_MONOTONIC); |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 215 | mEngine.preComposition(mRefreshArgs); |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 216 | const nsecs_t after = systemTime(SYSTEM_TIME_MONOTONIC); |
| 217 | |
| 218 | // The frame timestamp should be between the before and after timestamps |
| 219 | EXPECT_GE(mEngine.getLastFrameRefreshTimestamp(), before); |
| 220 | EXPECT_LE(mEngine.getLastFrameRefreshTimestamp(), after); |
| 221 | } |
| 222 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 223 | TEST_F(CompositionTestPreComposition, preCompositionInvokesLayerPreCompositionWithFrameTimestamp) { |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 224 | nsecs_t ts1 = 0; |
| 225 | nsecs_t ts2 = 0; |
| 226 | nsecs_t ts3 = 0; |
Vishnu Nair | ba35410 | 2022-08-01 00:14:18 +0000 | [diff] [blame] | 227 | EXPECT_CALL(*mLayer1FE, onPreComposition(_, _)) |
| 228 | .WillOnce(DoAll(SaveArg<0>(&ts1), Return(false))); |
| 229 | EXPECT_CALL(*mLayer2FE, onPreComposition(_, _)) |
| 230 | .WillOnce(DoAll(SaveArg<0>(&ts2), Return(false))); |
| 231 | EXPECT_CALL(*mLayer3FE, onPreComposition(_, _)) |
| 232 | .WillOnce(DoAll(SaveArg<0>(&ts3), Return(false))); |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 233 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 234 | mRefreshArgs.outputs = {mOutput1}; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 235 | mRefreshArgs.layers = {mLayer1FE, mLayer2FE, mLayer3FE}; |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 236 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 237 | mEngine.preComposition(mRefreshArgs); |
| 238 | |
| 239 | // Each of the onPreComposition calls should used the same refresh timestamp |
| 240 | EXPECT_EQ(ts1, mEngine.getLastFrameRefreshTimestamp()); |
| 241 | EXPECT_EQ(ts2, mEngine.getLastFrameRefreshTimestamp()); |
| 242 | EXPECT_EQ(ts3, mEngine.getLastFrameRefreshTimestamp()); |
| 243 | } |
| 244 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 245 | TEST_F(CompositionTestPreComposition, preCompositionDefaultsToNoUpdateNeeded) { |
Vishnu Nair | ba35410 | 2022-08-01 00:14:18 +0000 | [diff] [blame] | 246 | EXPECT_CALL(*mLayer1FE, onPreComposition(_, _)).WillOnce(Return(false)); |
| 247 | EXPECT_CALL(*mLayer2FE, onPreComposition(_, _)).WillOnce(Return(false)); |
| 248 | EXPECT_CALL(*mLayer3FE, onPreComposition(_, _)).WillOnce(Return(false)); |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 249 | |
| 250 | mEngine.setNeedsAnotherUpdateForTest(true); |
| 251 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 252 | mRefreshArgs.outputs = {mOutput1}; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 253 | mRefreshArgs.layers = {mLayer1FE, mLayer2FE, mLayer3FE}; |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 254 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 255 | mEngine.preComposition(mRefreshArgs); |
| 256 | |
| 257 | // The call should have cleared the needsAnotherUpdate flag |
| 258 | EXPECT_FALSE(mEngine.needsAnotherUpdate()); |
| 259 | } |
| 260 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 261 | TEST_F(CompositionTestPreComposition, |
| 262 | preCompositionSetsNeedsAnotherUpdateIfAtLeastOneLayerRequestsIt) { |
Vishnu Nair | ba35410 | 2022-08-01 00:14:18 +0000 | [diff] [blame] | 263 | EXPECT_CALL(*mLayer1FE, onPreComposition(_, _)).WillOnce(Return(true)); |
| 264 | EXPECT_CALL(*mLayer2FE, onPreComposition(_, _)).WillOnce(Return(false)); |
| 265 | EXPECT_CALL(*mLayer3FE, onPreComposition(_, _)).WillOnce(Return(false)); |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 266 | |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 267 | mRefreshArgs.outputs = {mOutput1}; |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 268 | mRefreshArgs.layers = {mLayer1FE, mLayer2FE, mLayer3FE}; |
Lloyd Pique | e82ed2d | 2019-11-13 19:28:12 -0800 | [diff] [blame] | 269 | |
Lloyd Pique | ab039b5 | 2019-02-13 14:22:42 -0800 | [diff] [blame] | 270 | mEngine.preComposition(mRefreshArgs); |
| 271 | |
| 272 | EXPECT_TRUE(mEngine.needsAnotherUpdate()); |
| 273 | } |
| 274 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 275 | } // namespace |
| 276 | } // namespace android::compositionengine |