blob: 8401f0827b0c62bffd5a72ff02008f22d1b212a2 [file] [log] [blame]
Lloyd Pique45a165a2018-10-19 11:54:47 -07001/*
2 * Copyright 2019 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 Pique45a165a2018-10-19 11:54:47 -070017#include <cmath>
18
Lloyd Pique3d0c02e2018-10-19 18:38:12 -070019#include <compositionengine/DisplayColorProfileCreationArgs.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070020#include <compositionengine/DisplayCreationArgs.h>
Lloyd Pique31cb2942018-10-19 17:23:03 -070021#include <compositionengine/DisplaySurface.h>
22#include <compositionengine/RenderSurfaceCreationArgs.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070023#include <compositionengine/impl/Display.h>
24#include <compositionengine/mock/CompositionEngine.h>
Lloyd Piquef5275482019-01-29 18:42:42 -080025#include <compositionengine/mock/DisplayColorProfile.h>
Lloyd Piquedf336d92019-03-07 21:38:42 -080026#include <compositionengine/mock/Layer.h>
27#include <compositionengine/mock/LayerFE.h>
chaviw8beb4142019-04-11 13:09:05 -070028#include <compositionengine/mock/NativeWindow.h>
Lloyd Pique66d68602019-02-13 14:23:31 -080029#include <compositionengine/mock/OutputLayer.h>
Lloyd Pique31cb2942018-10-19 17:23:03 -070030#include <compositionengine/mock/RenderSurface.h>
Lloyd Pique32cbe282018-10-19 13:09:22 -070031#include <gtest/gtest.h>
Lloyd Pique45a165a2018-10-19 11:54:47 -070032
Lloyd Pique66d68602019-02-13 14:23:31 -080033#include "MockHWC2.h"
Lloyd Pique45a165a2018-10-19 11:54:47 -070034#include "MockHWComposer.h"
Lloyd Pique688abd42019-02-15 15:42:24 -080035#include "MockPowerAdvisor.h"
Lloyd Pique45a165a2018-10-19 11:54:47 -070036
37namespace android::compositionengine {
38namespace {
39
Lloyd Piquef5275482019-01-29 18:42:42 -080040using testing::_;
Lloyd Pique66d68602019-02-13 14:23:31 -080041using testing::DoAll;
Lloyd Pique31cb2942018-10-19 17:23:03 -070042using testing::Return;
Lloyd Pique45a165a2018-10-19 11:54:47 -070043using testing::ReturnRef;
Lloyd Pique66d68602019-02-13 14:23:31 -080044using testing::Sequence;
45using testing::SetArgPointee;
Lloyd Pique45a165a2018-10-19 11:54:47 -070046using testing::StrictMock;
47
48constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{42};
49
Lloyd Pique66d68602019-02-13 14:23:31 -080050struct DisplayTest : public testing::Test {
51 DisplayTest() {
52 EXPECT_CALL(mCompositionEngine, getHwComposer()).WillRepeatedly(ReturnRef(mHwComposer));
53 EXPECT_CALL(*mLayer1, getHwcLayer()).WillRepeatedly(Return(&mHWC2Layer1));
54 EXPECT_CALL(*mLayer2, getHwcLayer()).WillRepeatedly(Return(&mHWC2Layer2));
55 EXPECT_CALL(*mLayer3, getHwcLayer()).WillRepeatedly(Return(nullptr));
56
57 std::vector<std::unique_ptr<OutputLayer>> layers;
58 layers.emplace_back(mLayer1);
59 layers.emplace_back(mLayer2);
60 layers.emplace_back(mLayer3);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070061 mDisplay->setOutputLayersOrderedByZ(std::move(layers));
Lloyd Pique66d68602019-02-13 14:23:31 -080062 }
Lloyd Pique45a165a2018-10-19 11:54:47 -070063
64 StrictMock<android::mock::HWComposer> mHwComposer;
Lloyd Pique688abd42019-02-15 15:42:24 -080065 StrictMock<Hwc2::mock::PowerAdvisor> mPowerAdvisor;
Lloyd Pique45a165a2018-10-19 11:54:47 -070066 StrictMock<mock::CompositionEngine> mCompositionEngine;
chaviw8beb4142019-04-11 13:09:05 -070067 sp<mock::NativeWindow> mNativeWindow = new StrictMock<mock::NativeWindow>();
Lloyd Pique66d68602019-02-13 14:23:31 -080068 StrictMock<HWC2::mock::Layer> mHWC2Layer1;
69 StrictMock<HWC2::mock::Layer> mHWC2Layer2;
70 StrictMock<HWC2::mock::Layer> mHWC2LayerUnknown;
71 mock::OutputLayer* mLayer1 = new StrictMock<mock::OutputLayer>();
72 mock::OutputLayer* mLayer2 = new StrictMock<mock::OutputLayer>();
73 mock::OutputLayer* mLayer3 = new StrictMock<mock::OutputLayer>();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070074 std::shared_ptr<impl::Display> mDisplay =
75 impl::createDisplay(mCompositionEngine,
76 DisplayCreationArgsBuilder()
77 .setDisplayId(DEFAULT_DISPLAY_ID)
78 .setPowerAdvisor(&mPowerAdvisor)
79 .build());
Lloyd Pique45a165a2018-10-19 11:54:47 -070080};
81
Lloyd Pique66d68602019-02-13 14:23:31 -080082/*
Lloyd Pique45a165a2018-10-19 11:54:47 -070083 * Basic construction
84 */
85
86TEST_F(DisplayTest, canInstantiateDisplay) {
87 {
88 constexpr DisplayId display1 = DisplayId{123u};
89 auto display =
90 impl::createDisplay(mCompositionEngine,
91 DisplayCreationArgsBuilder().setDisplayId(display1).build());
92 EXPECT_FALSE(display->isSecure());
93 EXPECT_FALSE(display->isVirtual());
94 EXPECT_EQ(display1, display->getId());
95 }
96
97 {
98 constexpr DisplayId display2 = DisplayId{546u};
Lloyd Piquea38ea7e2019-04-16 18:10:26 -070099 auto display =
100 impl::createDisplay(mCompositionEngine,
101 DisplayCreationArgsBuilder().setDisplayId(display2).build());
102 EXPECT_FALSE(display->isSecure());
Lloyd Pique45a165a2018-10-19 11:54:47 -0700103 EXPECT_FALSE(display->isVirtual());
104 EXPECT_EQ(display2, display->getId());
105 }
106
107 {
108 constexpr DisplayId display3 = DisplayId{789u};
109 auto display = impl::createDisplay(mCompositionEngine,
110 DisplayCreationArgsBuilder()
111 .setIsVirtual(true)
112 .setDisplayId(display3)
113 .build());
114 EXPECT_FALSE(display->isSecure());
115 EXPECT_TRUE(display->isVirtual());
116 EXPECT_EQ(display3, display->getId());
117 }
118}
119
Lloyd Pique66d68602019-02-13 14:23:31 -0800120/*
Lloyd Pique45a165a2018-10-19 11:54:47 -0700121 * Display::disconnect()
122 */
123
124TEST_F(DisplayTest, disconnectDisconnectsDisplay) {
Lloyd Pique45a165a2018-10-19 11:54:47 -0700125 // The first call to disconnect will disconnect the display with the HWC and
126 // set mHwcId to -1.
127 EXPECT_CALL(mHwComposer, disconnectDisplay(DEFAULT_DISPLAY_ID)).Times(1);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700128 mDisplay->disconnect();
129 EXPECT_FALSE(mDisplay->getId());
Lloyd Pique45a165a2018-10-19 11:54:47 -0700130
131 // Subsequent calls will do nothing,
132 EXPECT_CALL(mHwComposer, disconnectDisplay(DEFAULT_DISPLAY_ID)).Times(0);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700133 mDisplay->disconnect();
134 EXPECT_FALSE(mDisplay->getId());
Lloyd Pique45a165a2018-10-19 11:54:47 -0700135}
136
Lloyd Pique66d68602019-02-13 14:23:31 -0800137/*
Lloyd Pique32cbe282018-10-19 13:09:22 -0700138 * Display::setColorTransform()
139 */
140
141TEST_F(DisplayTest, setColorTransformSetsTransform) {
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800142 // No change does nothing
143 CompositionRefreshArgs refreshArgs;
144 refreshArgs.colorTransformMatrix = std::nullopt;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700145 mDisplay->setColorTransform(refreshArgs);
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800146
Lloyd Pique32cbe282018-10-19 13:09:22 -0700147 // Identity matrix sets an identity state value
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800148 const mat4 kIdentity;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700149
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800150 EXPECT_CALL(mHwComposer, setColorTransform(DEFAULT_DISPLAY_ID, kIdentity)).Times(1);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700151
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800152 refreshArgs.colorTransformMatrix = kIdentity;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700153 mDisplay->setColorTransform(refreshArgs);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700154
155 // Non-identity matrix sets a non-identity state value
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800156 const mat4 kNonIdentity = mat4() * 2;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700157
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800158 EXPECT_CALL(mHwComposer, setColorTransform(DEFAULT_DISPLAY_ID, kNonIdentity)).Times(1);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700159
Lloyd Pique3eb1b212019-03-07 21:15:40 -0800160 refreshArgs.colorTransformMatrix = kNonIdentity;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700161 mDisplay->setColorTransform(refreshArgs);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700162}
163
Lloyd Pique66d68602019-02-13 14:23:31 -0800164/*
Lloyd Pique32cbe282018-10-19 13:09:22 -0700165 * Display::setColorMode()
166 */
167
168TEST_F(DisplayTest, setColorModeSetsModeUnlessNoChange) {
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800169 using ColorProfile = Output::ColorProfile;
170
Lloyd Pique31cb2942018-10-19 17:23:03 -0700171 mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700172 mDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface));
Lloyd Piquef5275482019-01-29 18:42:42 -0800173 mock::DisplayColorProfile* colorProfile = new StrictMock<mock::DisplayColorProfile>();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700174 mDisplay->setDisplayColorProfileForTest(std::unique_ptr<DisplayColorProfile>(colorProfile));
Lloyd Pique31cb2942018-10-19 17:23:03 -0700175
Lloyd Piquef5275482019-01-29 18:42:42 -0800176 EXPECT_CALL(*colorProfile, getTargetDataspace(_, _, _))
177 .WillRepeatedly(Return(ui::Dataspace::UNKNOWN));
Lloyd Pique32cbe282018-10-19 13:09:22 -0700178
179 // These values are expected to be the initial state.
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700180 ASSERT_EQ(ui::ColorMode::NATIVE, mDisplay->getState().colorMode);
181 ASSERT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().dataspace);
182 ASSERT_EQ(ui::RenderIntent::COLORIMETRIC, mDisplay->getState().renderIntent);
183 ASSERT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700184
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700185 // Otherwise if the values are unchanged, nothing happens
186 mDisplay->setColorProfile(ColorProfile{ui::ColorMode::NATIVE, ui::Dataspace::UNKNOWN,
187 ui::RenderIntent::COLORIMETRIC, ui::Dataspace::UNKNOWN});
Lloyd Pique32cbe282018-10-19 13:09:22 -0700188
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700189 EXPECT_EQ(ui::ColorMode::NATIVE, mDisplay->getState().colorMode);
190 EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().dataspace);
191 EXPECT_EQ(ui::RenderIntent::COLORIMETRIC, mDisplay->getState().renderIntent);
192 EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700193
194 // Otherwise if the values are different, updates happen
Lloyd Piqueef958122019-02-05 18:00:12 -0800195 EXPECT_CALL(*renderSurface, setBufferDataspace(ui::Dataspace::DISPLAY_P3)).Times(1);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700196 EXPECT_CALL(mHwComposer,
Lloyd Piqueef958122019-02-05 18:00:12 -0800197 setActiveColorMode(DEFAULT_DISPLAY_ID, ui::ColorMode::DISPLAY_P3,
Lloyd Pique32cbe282018-10-19 13:09:22 -0700198 ui::RenderIntent::TONE_MAP_COLORIMETRIC))
199 .Times(1);
200
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700201 mDisplay->setColorProfile(ColorProfile{ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3,
202 ui::RenderIntent::TONE_MAP_COLORIMETRIC,
203 ui::Dataspace::UNKNOWN});
Lloyd Pique32cbe282018-10-19 13:09:22 -0700204
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700205 EXPECT_EQ(ui::ColorMode::DISPLAY_P3, mDisplay->getState().colorMode);
206 EXPECT_EQ(ui::Dataspace::DISPLAY_P3, mDisplay->getState().dataspace);
207 EXPECT_EQ(ui::RenderIntent::TONE_MAP_COLORIMETRIC, mDisplay->getState().renderIntent);
208 EXPECT_EQ(ui::Dataspace::UNKNOWN, mDisplay->getState().targetDataspace);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700209}
210
211TEST_F(DisplayTest, setColorModeDoesNothingForVirtualDisplay) {
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800212 using ColorProfile = Output::ColorProfile;
213
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700214 std::shared_ptr<impl::Display> virtualDisplay{
215 impl::createDisplay(mCompositionEngine, DisplayCreationArgs{true, DEFAULT_DISPLAY_ID})};
Lloyd Pique32cbe282018-10-19 13:09:22 -0700216
Lloyd Piquef5275482019-01-29 18:42:42 -0800217 mock::DisplayColorProfile* colorProfile = new StrictMock<mock::DisplayColorProfile>();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700218 virtualDisplay->setDisplayColorProfileForTest(
Lloyd Piquef5275482019-01-29 18:42:42 -0800219 std::unique_ptr<DisplayColorProfile>(colorProfile));
220
221 EXPECT_CALL(*colorProfile,
222 getTargetDataspace(ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3,
223 ui::Dataspace::UNKNOWN))
224 .WillOnce(Return(ui::Dataspace::UNKNOWN));
225
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700226 virtualDisplay->setColorProfile(
Lloyd Pique6a3b4462019-03-07 20:58:12 -0800227 ColorProfile{ui::ColorMode::DISPLAY_P3, ui::Dataspace::DISPLAY_P3,
228 ui::RenderIntent::TONE_MAP_COLORIMETRIC, ui::Dataspace::UNKNOWN});
Lloyd Pique32cbe282018-10-19 13:09:22 -0700229
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700230 EXPECT_EQ(ui::ColorMode::NATIVE, virtualDisplay->getState().colorMode);
231 EXPECT_EQ(ui::Dataspace::UNKNOWN, virtualDisplay->getState().dataspace);
232 EXPECT_EQ(ui::RenderIntent::COLORIMETRIC, virtualDisplay->getState().renderIntent);
233 EXPECT_EQ(ui::Dataspace::UNKNOWN, virtualDisplay->getState().targetDataspace);
Lloyd Pique32cbe282018-10-19 13:09:22 -0700234}
235
Lloyd Pique66d68602019-02-13 14:23:31 -0800236/*
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700237 * Display::createDisplayColorProfile()
238 */
239
240TEST_F(DisplayTest, createDisplayColorProfileSetsDisplayColorProfile) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700241 EXPECT_TRUE(mDisplay->getDisplayColorProfile() == nullptr);
242 mDisplay->createDisplayColorProfile(
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700243 DisplayColorProfileCreationArgs{false, HdrCapabilities(), 0,
244 DisplayColorProfileCreationArgs::HwcColorModes()});
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700245 EXPECT_TRUE(mDisplay->getDisplayColorProfile() != nullptr);
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700246}
247
Lloyd Pique66d68602019-02-13 14:23:31 -0800248/*
Lloyd Pique31cb2942018-10-19 17:23:03 -0700249 * Display::createRenderSurface()
250 */
251
252TEST_F(DisplayTest, createRenderSurfaceSetsRenderSurface) {
chaviw8beb4142019-04-11 13:09:05 -0700253 EXPECT_CALL(*mNativeWindow, disconnect(NATIVE_WINDOW_API_EGL)).WillRepeatedly(Return(NO_ERROR));
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700254 EXPECT_TRUE(mDisplay->getRenderSurface() == nullptr);
255 mDisplay->createRenderSurface(RenderSurfaceCreationArgs{640, 480, mNativeWindow, nullptr});
256 EXPECT_TRUE(mDisplay->getRenderSurface() != nullptr);
Lloyd Pique31cb2942018-10-19 17:23:03 -0700257}
258
Lloyd Pique66d68602019-02-13 14:23:31 -0800259/*
Lloyd Piquedf336d92019-03-07 21:38:42 -0800260 * Display::createOutputLayer()
261 */
262
263TEST_F(DisplayTest, createOutputLayerSetsHwcLayer) {
264 sp<mock::LayerFE> layerFE = new StrictMock<mock::LayerFE>();
265 auto layer = std::make_shared<StrictMock<mock::Layer>>();
266 StrictMock<HWC2::mock::Layer> hwcLayer;
267
268 EXPECT_CALL(mHwComposer, createLayer(DEFAULT_DISPLAY_ID)).WillOnce(Return(&hwcLayer));
269
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700270 auto outputLayer = mDisplay->createOutputLayer(layer, layerFE);
Lloyd Piquedf336d92019-03-07 21:38:42 -0800271
272 EXPECT_EQ(&hwcLayer, outputLayer->getHwcLayer());
273
274 EXPECT_CALL(mHwComposer, destroyLayer(DEFAULT_DISPLAY_ID, &hwcLayer));
275 outputLayer.reset();
276}
277
278/*
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800279 * Display::setReleasedLayers()
280 */
281
282TEST_F(DisplayTest, setReleasedLayersDoesNothingIfNotHwcDisplay) {
283 std::shared_ptr<impl::Display> nonHwcDisplay{
284 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
285
286 sp<mock::LayerFE> layerXLayerFE = new StrictMock<mock::LayerFE>();
287 mock::Layer layerXLayer;
288
289 {
290 Output::ReleasedLayers releasedLayers;
291 releasedLayers.emplace_back(layerXLayerFE);
292 nonHwcDisplay->setReleasedLayers(std::move(releasedLayers));
293 }
294
295 CompositionRefreshArgs refreshArgs;
296 refreshArgs.layersWithQueuedFrames.push_back(&layerXLayer);
297
298 nonHwcDisplay->setReleasedLayers(refreshArgs);
299
300 const auto& releasedLayers = nonHwcDisplay->getReleasedLayersForTest();
301 ASSERT_EQ(1, releasedLayers.size());
302}
303
304TEST_F(DisplayTest, setReleasedLayersDoesNothingIfNoLayersWithQueuedFrames) {
305 sp<mock::LayerFE> layerXLayerFE = new StrictMock<mock::LayerFE>();
306
307 {
308 Output::ReleasedLayers releasedLayers;
309 releasedLayers.emplace_back(layerXLayerFE);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700310 mDisplay->setReleasedLayers(std::move(releasedLayers));
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800311 }
312
313 CompositionRefreshArgs refreshArgs;
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700314 mDisplay->setReleasedLayers(refreshArgs);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800315
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700316 const auto& releasedLayers = mDisplay->getReleasedLayersForTest();
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800317 ASSERT_EQ(1, releasedLayers.size());
318}
319
320TEST_F(DisplayTest, setReleasedLayers) {
321 sp<mock::LayerFE> layer1LayerFE = new StrictMock<mock::LayerFE>();
322 sp<mock::LayerFE> layer2LayerFE = new StrictMock<mock::LayerFE>();
323 sp<mock::LayerFE> layer3LayerFE = new StrictMock<mock::LayerFE>();
324 sp<mock::LayerFE> layerXLayerFE = new StrictMock<mock::LayerFE>();
325 mock::Layer layer1Layer;
326 mock::Layer layer2Layer;
327 mock::Layer layer3Layer;
328 mock::Layer layerXLayer;
329
330 EXPECT_CALL(*mLayer1, getLayer()).WillRepeatedly(ReturnRef(layer1Layer));
331 EXPECT_CALL(*mLayer1, getLayerFE()).WillRepeatedly(ReturnRef(*layer1LayerFE.get()));
332 EXPECT_CALL(*mLayer2, getLayer()).WillRepeatedly(ReturnRef(layer2Layer));
333 EXPECT_CALL(*mLayer2, getLayerFE()).WillRepeatedly(ReturnRef(*layer2LayerFE.get()));
334 EXPECT_CALL(*mLayer3, getLayer()).WillRepeatedly(ReturnRef(layer3Layer));
335 EXPECT_CALL(*mLayer3, getLayerFE()).WillRepeatedly(ReturnRef(*layer3LayerFE.get()));
336
337 CompositionRefreshArgs refreshArgs;
338 refreshArgs.layersWithQueuedFrames.push_back(&layer1Layer);
339 refreshArgs.layersWithQueuedFrames.push_back(&layer2Layer);
340 refreshArgs.layersWithQueuedFrames.push_back(&layerXLayer);
341 refreshArgs.layersWithQueuedFrames.push_back(nullptr);
342
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700343 mDisplay->setReleasedLayers(refreshArgs);
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800344
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700345 const auto& releasedLayers = mDisplay->getReleasedLayersForTest();
Lloyd Piquec29e4c62019-03-07 21:48:19 -0800346 ASSERT_EQ(2, releasedLayers.size());
347 ASSERT_EQ(layer1LayerFE.get(), releasedLayers[0].promote().get());
348 ASSERT_EQ(layer2LayerFE.get(), releasedLayers[1].promote().get());
349}
350
351/*
Lloyd Pique66d68602019-02-13 14:23:31 -0800352 * Display::chooseCompositionStrategy()
353 */
354
355struct DisplayChooseCompositionStrategyTest : public testing::Test {
356 struct DisplayPartialMock : public impl::Display {
357 DisplayPartialMock(const compositionengine::CompositionEngine& compositionEngine,
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700358 const compositionengine::DisplayCreationArgs& args)
359 : impl::Display(args), mCompositionEngine(compositionEngine) {}
Lloyd Pique66d68602019-02-13 14:23:31 -0800360
361 // Sets up the helper functions called by chooseCompositionStrategy to
362 // use a mock implementations.
363 MOCK_CONST_METHOD0(anyLayersRequireClientComposition, bool());
364 MOCK_CONST_METHOD0(allLayersRequireClientComposition, bool());
365 MOCK_METHOD1(applyChangedTypesToLayers, void(const impl::Display::ChangedTypes&));
366 MOCK_METHOD1(applyDisplayRequests, void(const impl::Display::DisplayRequests&));
367 MOCK_METHOD1(applyLayerRequestsToLayers, void(const impl::Display::LayerRequests&));
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700368
369 // compositionengine::Output overrides
370 const OutputCompositionState& getState() const override { return mState; }
371 OutputCompositionState& editState() override { return mState; }
372
373 // compositionengine::impl::Output overrides
374 const CompositionEngine& getCompositionEngine() const override {
375 return mCompositionEngine;
376 };
377
378 // These need implementations though are not expected to be called.
379 MOCK_CONST_METHOD1(dumpState, void(std::string&));
380
381 const compositionengine::CompositionEngine& mCompositionEngine;
382 impl::OutputCompositionState mState;
Lloyd Pique66d68602019-02-13 14:23:31 -0800383 };
384
385 DisplayChooseCompositionStrategyTest() {
386 EXPECT_CALL(mCompositionEngine, getHwComposer()).WillRepeatedly(ReturnRef(mHwComposer));
387 }
388
389 StrictMock<android::mock::HWComposer> mHwComposer;
390 StrictMock<mock::CompositionEngine> mCompositionEngine;
391 StrictMock<DisplayPartialMock>
392 mDisplay{mCompositionEngine,
393 DisplayCreationArgsBuilder().setDisplayId(DEFAULT_DISPLAY_ID).build()};
394};
395
396TEST_F(DisplayChooseCompositionStrategyTest, takesEarlyOutIfNotAHwcDisplay) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700397 std::shared_ptr<impl::Display> nonHwcDisplay{
398 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
399 EXPECT_FALSE(nonHwcDisplay->getId());
Lloyd Pique66d68602019-02-13 14:23:31 -0800400
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700401 nonHwcDisplay->chooseCompositionStrategy();
Lloyd Pique66d68602019-02-13 14:23:31 -0800402
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700403 auto& state = nonHwcDisplay->getState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800404 EXPECT_TRUE(state.usesClientComposition);
405 EXPECT_FALSE(state.usesDeviceComposition);
406}
407
408TEST_F(DisplayChooseCompositionStrategyTest, takesEarlyOutOnHwcError) {
409 EXPECT_CALL(mDisplay, anyLayersRequireClientComposition()).WillOnce(Return(false));
410 EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, false, _))
411 .WillOnce(Return(INVALID_OPERATION));
412
413 mDisplay.chooseCompositionStrategy();
414
415 auto& state = mDisplay.getState();
416 EXPECT_TRUE(state.usesClientComposition);
417 EXPECT_FALSE(state.usesDeviceComposition);
418}
419
420TEST_F(DisplayChooseCompositionStrategyTest, normalOperation) {
421 // Since two calls are made to anyLayersRequireClientComposition with different return values,
422 // use a Sequence to control the matching so the values are returned in a known order.
423 Sequence s;
424 EXPECT_CALL(mDisplay, anyLayersRequireClientComposition()).InSequence(s).WillOnce(Return(true));
425 EXPECT_CALL(mDisplay, anyLayersRequireClientComposition())
426 .InSequence(s)
427 .WillOnce(Return(false));
428
429 EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, true, _))
430 .WillOnce(Return(NO_ERROR));
431 EXPECT_CALL(mDisplay, allLayersRequireClientComposition()).WillOnce(Return(false));
432
433 mDisplay.chooseCompositionStrategy();
434
435 auto& state = mDisplay.getState();
436 EXPECT_FALSE(state.usesClientComposition);
437 EXPECT_TRUE(state.usesDeviceComposition);
438}
439
440TEST_F(DisplayChooseCompositionStrategyTest, normalOperationWithChanges) {
441 android::HWComposer::DeviceRequestedChanges changes{
442 {{nullptr, HWC2::Composition::Client}},
443 HWC2::DisplayRequest::FlipClientTarget,
444 {{nullptr, HWC2::LayerRequest::ClearClientTarget}},
445 };
446
447 // Since two calls are made to anyLayersRequireClientComposition with different return values,
448 // use a Sequence to control the matching so the values are returned in a known order.
449 Sequence s;
450 EXPECT_CALL(mDisplay, anyLayersRequireClientComposition()).InSequence(s).WillOnce(Return(true));
451 EXPECT_CALL(mDisplay, anyLayersRequireClientComposition())
452 .InSequence(s)
453 .WillOnce(Return(false));
454
455 EXPECT_CALL(mHwComposer, getDeviceCompositionChanges(DEFAULT_DISPLAY_ID, true, _))
456 .WillOnce(DoAll(SetArgPointee<2>(changes), Return(NO_ERROR)));
457 EXPECT_CALL(mDisplay, applyChangedTypesToLayers(changes.changedTypes)).Times(1);
458 EXPECT_CALL(mDisplay, applyDisplayRequests(changes.displayRequests)).Times(1);
459 EXPECT_CALL(mDisplay, applyLayerRequestsToLayers(changes.layerRequests)).Times(1);
460 EXPECT_CALL(mDisplay, allLayersRequireClientComposition()).WillOnce(Return(false));
461
462 mDisplay.chooseCompositionStrategy();
463
464 auto& state = mDisplay.getState();
465 EXPECT_FALSE(state.usesClientComposition);
466 EXPECT_TRUE(state.usesDeviceComposition);
467}
468
469/*
Lloyd Pique688abd42019-02-15 15:42:24 -0800470 * Display::getSkipColorTransform()
471 */
472
473TEST_F(DisplayTest, getSkipColorTransformDoesNothingIfNonHwcDisplay) {
474 auto nonHwcDisplay{
475 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
476 EXPECT_FALSE(nonHwcDisplay->getSkipColorTransform());
477}
478
479TEST_F(DisplayTest, getSkipColorTransformChecksHwcCapability) {
480 EXPECT_CALL(mHwComposer,
481 hasDisplayCapability(std::make_optional(DEFAULT_DISPLAY_ID),
482 HWC2::DisplayCapability::SkipClientColorTransform))
483 .WillOnce(Return(true));
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700484 EXPECT_TRUE(mDisplay->getSkipColorTransform());
Lloyd Pique688abd42019-02-15 15:42:24 -0800485}
486
487/*
Lloyd Pique66d68602019-02-13 14:23:31 -0800488 * Display::anyLayersRequireClientComposition()
489 */
490
491TEST_F(DisplayTest, anyLayersRequireClientCompositionReturnsFalse) {
492 EXPECT_CALL(*mLayer1, requiresClientComposition()).WillOnce(Return(false));
493 EXPECT_CALL(*mLayer2, requiresClientComposition()).WillOnce(Return(false));
494 EXPECT_CALL(*mLayer3, requiresClientComposition()).WillOnce(Return(false));
495
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700496 EXPECT_FALSE(mDisplay->anyLayersRequireClientComposition());
Lloyd Pique66d68602019-02-13 14:23:31 -0800497}
498
499TEST_F(DisplayTest, anyLayersRequireClientCompositionReturnsTrue) {
500 EXPECT_CALL(*mLayer1, requiresClientComposition()).WillOnce(Return(false));
501 EXPECT_CALL(*mLayer2, requiresClientComposition()).WillOnce(Return(true));
502
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700503 EXPECT_TRUE(mDisplay->anyLayersRequireClientComposition());
Lloyd Pique66d68602019-02-13 14:23:31 -0800504}
505
506/*
507 * Display::allLayersRequireClientComposition()
508 */
509
510TEST_F(DisplayTest, allLayersRequireClientCompositionReturnsTrue) {
511 EXPECT_CALL(*mLayer1, requiresClientComposition()).WillOnce(Return(true));
512 EXPECT_CALL(*mLayer2, requiresClientComposition()).WillOnce(Return(true));
513 EXPECT_CALL(*mLayer3, requiresClientComposition()).WillOnce(Return(true));
514
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700515 EXPECT_TRUE(mDisplay->allLayersRequireClientComposition());
Lloyd Pique66d68602019-02-13 14:23:31 -0800516}
517
518TEST_F(DisplayTest, allLayersRequireClientCompositionReturnsFalse) {
519 EXPECT_CALL(*mLayer1, requiresClientComposition()).WillOnce(Return(true));
520 EXPECT_CALL(*mLayer2, requiresClientComposition()).WillOnce(Return(false));
521
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700522 EXPECT_FALSE(mDisplay->allLayersRequireClientComposition());
Lloyd Pique66d68602019-02-13 14:23:31 -0800523}
524
525/*
526 * Display::applyChangedTypesToLayers()
527 */
528
529TEST_F(DisplayTest, applyChangedTypesToLayersTakesEarlyOutIfNoChangedLayers) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700530 mDisplay->applyChangedTypesToLayers(impl::Display::ChangedTypes());
Lloyd Pique66d68602019-02-13 14:23:31 -0800531}
532
533TEST_F(DisplayTest, applyChangedTypesToLayersAppliesChanges) {
534 EXPECT_CALL(*mLayer1,
535 applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition::CLIENT))
536 .Times(1);
537 EXPECT_CALL(*mLayer2,
538 applyDeviceCompositionTypeChange(Hwc2::IComposerClient::Composition::DEVICE))
539 .Times(1);
540
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700541 mDisplay->applyChangedTypesToLayers(impl::Display::ChangedTypes{
Lloyd Pique66d68602019-02-13 14:23:31 -0800542 {&mHWC2Layer1, HWC2::Composition::Client},
543 {&mHWC2Layer2, HWC2::Composition::Device},
544 {&mHWC2LayerUnknown, HWC2::Composition::SolidColor},
545 });
546}
547
548/*
549 * Display::applyDisplayRequests()
550 */
551
552TEST_F(DisplayTest, applyDisplayRequestsToLayersHandlesNoRequests) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700553 mDisplay->applyDisplayRequests(static_cast<HWC2::DisplayRequest>(0));
Lloyd Pique66d68602019-02-13 14:23:31 -0800554
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700555 auto& state = mDisplay->getState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800556 EXPECT_FALSE(state.flipClientTarget);
557}
558
559TEST_F(DisplayTest, applyDisplayRequestsToLayersHandlesFlipClientTarget) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700560 mDisplay->applyDisplayRequests(HWC2::DisplayRequest::FlipClientTarget);
Lloyd Pique66d68602019-02-13 14:23:31 -0800561
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700562 auto& state = mDisplay->getState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800563 EXPECT_TRUE(state.flipClientTarget);
564}
565
566TEST_F(DisplayTest, applyDisplayRequestsToLayersHandlesWriteClientTargetToOutput) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700567 mDisplay->applyDisplayRequests(HWC2::DisplayRequest::WriteClientTargetToOutput);
Lloyd Pique66d68602019-02-13 14:23:31 -0800568
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700569 auto& state = mDisplay->getState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800570 EXPECT_FALSE(state.flipClientTarget);
571}
572
573TEST_F(DisplayTest, applyDisplayRequestsToLayersHandlesAllRequestFlagsSet) {
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700574 mDisplay->applyDisplayRequests(static_cast<HWC2::DisplayRequest>(~0));
Lloyd Pique66d68602019-02-13 14:23:31 -0800575
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700576 auto& state = mDisplay->getState();
Lloyd Pique66d68602019-02-13 14:23:31 -0800577 EXPECT_TRUE(state.flipClientTarget);
578}
579
580/*
581 * Display::applyLayerRequestsToLayers()
582 */
583
584TEST_F(DisplayTest, applyLayerRequestsToLayersPreparesAllLayers) {
585 EXPECT_CALL(*mLayer1, prepareForDeviceLayerRequests()).Times(1);
586 EXPECT_CALL(*mLayer2, prepareForDeviceLayerRequests()).Times(1);
587 EXPECT_CALL(*mLayer3, prepareForDeviceLayerRequests()).Times(1);
588
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700589 mDisplay->applyLayerRequestsToLayers(impl::Display::LayerRequests());
Lloyd Pique66d68602019-02-13 14:23:31 -0800590}
591
592TEST_F(DisplayTest, applyLayerRequestsToLayers2) {
593 EXPECT_CALL(*mLayer1, prepareForDeviceLayerRequests()).Times(1);
594 EXPECT_CALL(*mLayer2, prepareForDeviceLayerRequests()).Times(1);
595 EXPECT_CALL(*mLayer3, prepareForDeviceLayerRequests()).Times(1);
596
597 EXPECT_CALL(*mLayer1,
598 applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest::CLEAR_CLIENT_TARGET))
599 .Times(1);
600
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700601 mDisplay->applyLayerRequestsToLayers(impl::Display::LayerRequests{
Lloyd Pique66d68602019-02-13 14:23:31 -0800602 {&mHWC2Layer1, HWC2::LayerRequest::ClearClientTarget},
603 {&mHWC2LayerUnknown, HWC2::LayerRequest::ClearClientTarget},
604 });
605}
606
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800607/*
608 * Display::presentAndGetFrameFences()
609 */
610
611TEST_F(DisplayTest, presentAndGetFrameFencesReturnsNoFencesOnNonHwcDisplay) {
612 auto nonHwcDisplay{
613 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
614
615 auto result = nonHwcDisplay->presentAndGetFrameFences();
616
617 ASSERT_TRUE(result.presentFence.get());
618 EXPECT_FALSE(result.presentFence->isValid());
619 EXPECT_EQ(0u, result.layerFences.size());
620}
621
622TEST_F(DisplayTest, presentAndGetFrameFencesReturnsPresentAndLayerFences) {
623 sp<Fence> presentFence = new Fence();
624 sp<Fence> layer1Fence = new Fence();
625 sp<Fence> layer2Fence = new Fence();
626
627 EXPECT_CALL(mHwComposer, presentAndGetReleaseFences(DEFAULT_DISPLAY_ID)).Times(1);
628 EXPECT_CALL(mHwComposer, getPresentFence(DEFAULT_DISPLAY_ID)).WillOnce(Return(presentFence));
629 EXPECT_CALL(mHwComposer, getLayerReleaseFence(DEFAULT_DISPLAY_ID, &mHWC2Layer1))
630 .WillOnce(Return(layer1Fence));
631 EXPECT_CALL(mHwComposer, getLayerReleaseFence(DEFAULT_DISPLAY_ID, &mHWC2Layer2))
632 .WillOnce(Return(layer2Fence));
633 EXPECT_CALL(mHwComposer, clearReleaseFences(DEFAULT_DISPLAY_ID)).Times(1);
634
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700635 auto result = mDisplay->presentAndGetFrameFences();
Lloyd Pique35fca9d2019-02-13 14:24:11 -0800636
637 EXPECT_EQ(presentFence, result.presentFence);
638
639 EXPECT_EQ(2u, result.layerFences.size());
640 ASSERT_EQ(1, result.layerFences.count(&mHWC2Layer1));
641 EXPECT_EQ(layer1Fence, result.layerFences[&mHWC2Layer1]);
642 ASSERT_EQ(1, result.layerFences.count(&mHWC2Layer2));
643 EXPECT_EQ(layer2Fence, result.layerFences[&mHWC2Layer2]);
644}
645
Lloyd Pique688abd42019-02-15 15:42:24 -0800646/*
647 * Display::setExpensiveRenderingExpected()
648 */
649
650TEST_F(DisplayTest, setExpensiveRenderingExpectedForwardsToPowerAdvisor) {
651 EXPECT_CALL(mPowerAdvisor, setExpensiveRenderingExpected(DEFAULT_DISPLAY_ID, true)).Times(1);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700652 mDisplay->setExpensiveRenderingExpected(true);
Lloyd Pique688abd42019-02-15 15:42:24 -0800653
654 EXPECT_CALL(mPowerAdvisor, setExpensiveRenderingExpected(DEFAULT_DISPLAY_ID, false)).Times(1);
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700655 mDisplay->setExpensiveRenderingExpected(false);
Lloyd Pique688abd42019-02-15 15:42:24 -0800656}
657
Lloyd Piqued3d69882019-02-28 16:03:46 -0800658/*
659 * Display::finishFrame()
660 */
661
662TEST_F(DisplayTest, finishFrameDoesNotSkipCompositionIfNotDirtyOnHwcDisplay) {
663 mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>();
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700664 mDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface));
Lloyd Piqued3d69882019-02-28 16:03:46 -0800665
666 // We expect no calls to queueBuffer if composition was skipped.
667 EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1);
668
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700669 mDisplay->editState().isEnabled = true;
670 mDisplay->editState().usesClientComposition = false;
671 mDisplay->editState().viewport = Rect(0, 0, 1, 1);
672 mDisplay->editState().dirtyRegion = Region::INVALID_REGION;
Lloyd Piqued3d69882019-02-28 16:03:46 -0800673
674 CompositionRefreshArgs refreshArgs;
675 refreshArgs.repaintEverything = false;
676
Lloyd Piquea38ea7e2019-04-16 18:10:26 -0700677 mDisplay->finishFrame(refreshArgs);
Lloyd Piqued3d69882019-02-28 16:03:46 -0800678}
679
680TEST_F(DisplayTest, finishFrameSkipsCompositionIfNotDirty) {
681 std::shared_ptr<impl::Display> nonHwcDisplay{
682 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
683
684 mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>();
685 nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface));
686
687 // We expect no calls to queueBuffer if composition was skipped.
688 EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(0);
689
690 nonHwcDisplay->editState().isEnabled = true;
691 nonHwcDisplay->editState().usesClientComposition = false;
692 nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
693 nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION;
694
695 CompositionRefreshArgs refreshArgs;
696 refreshArgs.repaintEverything = false;
697
698 nonHwcDisplay->finishFrame(refreshArgs);
699}
700
701TEST_F(DisplayTest, finishFramePerformsCompositionIfDirty) {
702 std::shared_ptr<impl::Display> nonHwcDisplay{
703 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
704
705 mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>();
706 nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface));
707
708 // We expect a single call to queueBuffer when composition is not skipped.
709 EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1);
710
711 nonHwcDisplay->editState().isEnabled = true;
712 nonHwcDisplay->editState().usesClientComposition = false;
713 nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
714 nonHwcDisplay->editState().dirtyRegion = Region(Rect(0, 0, 1, 1));
715
716 CompositionRefreshArgs refreshArgs;
717 refreshArgs.repaintEverything = false;
718
719 nonHwcDisplay->finishFrame(refreshArgs);
720}
721
722TEST_F(DisplayTest, finishFramePerformsCompositionIfRepaintEverything) {
723 std::shared_ptr<impl::Display> nonHwcDisplay{
724 impl::createDisplay(mCompositionEngine, DisplayCreationArgsBuilder().build())};
725
726 mock::RenderSurface* renderSurface = new StrictMock<mock::RenderSurface>();
727 nonHwcDisplay->setRenderSurfaceForTest(std::unique_ptr<RenderSurface>(renderSurface));
728
729 // We expect a single call to queueBuffer when composition is not skipped.
730 EXPECT_CALL(*renderSurface, queueBuffer(_)).Times(1);
731
732 nonHwcDisplay->editState().isEnabled = true;
733 nonHwcDisplay->editState().usesClientComposition = false;
734 nonHwcDisplay->editState().viewport = Rect(0, 0, 1, 1);
735 nonHwcDisplay->editState().dirtyRegion = Region::INVALID_REGION;
736
737 CompositionRefreshArgs refreshArgs;
738 refreshArgs.repaintEverything = true;
739
740 nonHwcDisplay->finishFrame(refreshArgs);
741}
742
Lloyd Pique45a165a2018-10-19 11:54:47 -0700743} // namespace
744} // namespace android::compositionengine