blob: 349dd3f2f1ce47f6999a3f705cbb6bf99d45e0cc [file] [log] [blame]
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001/*
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
17#undef LOG_TAG
18#define LOG_TAG "CompositionTest"
19
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080020#include <compositionengine/Display.h>
Lloyd Pique542307f2018-10-19 13:24:08 -070021#include <compositionengine/mock/DisplaySurface.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070022#include <gmock/gmock.h>
23#include <gtest/gtest.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070024#include <gui/IProducerListener.h>
Evan Roskya1f1e152019-01-24 16:17:46 -080025#include <gui/LayerMetadata.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070026#include <log/log.h>
Lloyd Pique3823e7b2018-10-18 16:58:10 -070027#include <renderengine/mock/Framebuffer.h>
28#include <renderengine/mock/Image.h>
29#include <renderengine/mock/RenderEngine.h>
Lloyd Piqued6b579f2018-04-06 15:29:10 -070030#include <system/window.h>
31#include <utils/String8.h>
32
33#include "BufferQueueLayer.h"
34#include "ColorLayer.h"
35#include "Layer.h"
36
Ana Krulecafb45842019-02-13 13:33:03 -080037#include "TestableScheduler.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070038#include "TestableSurfaceFlinger.h"
39#include "mock/DisplayHardware/MockComposer.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070040#include "mock/MockDispSync.h"
41#include "mock/MockEventControlThread.h"
42#include "mock/MockEventThread.h"
43#include "mock/MockMessageQueue.h"
Alec Mouriba013fa2018-10-16 12:43:11 -070044#include "mock/system/window/MockNativeWindow.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070045
46namespace android {
47namespace {
48
49using testing::_;
David Sodman15094112018-10-11 09:39:37 -070050using testing::AtLeast;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000051using testing::Between;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070052using testing::ByMove;
53using testing::DoAll;
Alec Mourie7d1d4a2019-02-05 01:13:46 +000054using testing::Field;
Alec Mouri0a9c7b82018-11-16 13:05:25 -080055using testing::Invoke;
Lloyd Piqued6b579f2018-04-06 15:29:10 -070056using testing::IsNull;
57using testing::Mock;
58using testing::NotNull;
59using testing::Ref;
60using testing::Return;
61using testing::ReturnRef;
62using testing::SetArgPointee;
63
64using android::Hwc2::Error;
65using android::Hwc2::IComposer;
66using android::Hwc2::IComposerClient;
67using android::Hwc2::Transform;
68
69using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector;
70using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector;
71
72constexpr hwc2_display_t HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DISPLAY_ID;
73constexpr hwc2_layer_t HWC_LAYER = 5000;
74constexpr Transform DEFAULT_TRANSFORM = static_cast<Transform>(0);
75
Dominik Laskowski34157762018-10-31 13:07:19 -070076constexpr DisplayId DEFAULT_DISPLAY_ID = DisplayId{42};
Lloyd Piqued6b579f2018-04-06 15:29:10 -070077constexpr int DEFAULT_DISPLAY_WIDTH = 1920;
78constexpr int DEFAULT_DISPLAY_HEIGHT = 1024;
79
80constexpr int DEFAULT_CONFIG_ID = 0;
81constexpr int DEFAULT_TEXTURE_ID = 6000;
82constexpr int DEFAULT_LAYER_STACK = 7000;
83
84constexpr int DEFAULT_DISPLAY_MAX_LUMINANCE = 500;
85
86constexpr int DEFAULT_SIDEBAND_STREAM = 51;
87
88class CompositionTest : public testing::Test {
89public:
90 CompositionTest() {
91 const ::testing::TestInfo* const test_info =
92 ::testing::UnitTest::GetInstance()->current_test_info();
93 ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
94
Lloyd Piqued6b579f2018-04-06 15:29:10 -070095 mFlinger.mutableEventQueue().reset(mMessageQueue);
Ana Krulecafb45842019-02-13 13:33:03 -080096 setupScheduler();
Lloyd Piqued6b579f2018-04-06 15:29:10 -070097
Lloyd Piqued6b579f2018-04-06 15:29:10 -070098 EXPECT_CALL(*mPrimaryDispSync, computeNextRefresh(0)).WillRepeatedly(Return(0));
99 EXPECT_CALL(*mPrimaryDispSync, getPeriod())
100 .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE));
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800101 EXPECT_CALL(*mPrimaryDispSync, expectedPresentTime()).WillRepeatedly(Return(0));
Alec Mourif6fd29e2018-11-17 04:56:41 +0000102 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
103 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
104 EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
105 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700106
107 mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
108 setupComposer(0);
109 }
110
111 ~CompositionTest() {
112 const ::testing::TestInfo* const test_info =
113 ::testing::UnitTest::GetInstance()->current_test_info();
114 ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name());
115 }
116
117 void setupComposer(int virtualDisplayCount) {
118 mComposer = new Hwc2::mock::Composer();
119 EXPECT_CALL(*mComposer, getCapabilities())
120 .WillOnce(Return(std::vector<IComposer::Capability>()));
121 EXPECT_CALL(*mComposer, getMaxVirtualDisplayCount()).WillOnce(Return(virtualDisplayCount));
122 mFlinger.setupComposer(std::unique_ptr<Hwc2::Composer>(mComposer));
123
124 Mock::VerifyAndClear(mComposer);
125 }
126
Ana Krulecafb45842019-02-13 13:33:03 -0800127 void setupScheduler() {
Steven Thomase9eb1832019-08-28 16:08:35 -0700128 std::vector<scheduler::RefreshRateConfigs::InputConfig> configs{{/*hwcId=*/0, 16666667}};
129 mFlinger.mutableRefreshRateConfigs() =
130 std::make_unique<scheduler::RefreshRateConfigs>(/*refreshRateSwitching=*/false,
131 configs,
132 /*currentConfig=*/0);
133 mFlinger.mutableRefreshRateStats() =
134 std::make_unique<scheduler::RefreshRateStats>(*mFlinger.mutableRefreshRateConfigs(),
135 *mFlinger.mutableTimeStats(),
136 /*currentConfig=*/0,
137 /*powerMode=*/HWC_POWER_MODE_OFF);
138 mScheduler = new TestableScheduler(*mFlinger.mutableRefreshRateConfigs());
Ana Krulecafb45842019-02-13 13:33:03 -0800139 mScheduler->mutableEventControlThread().reset(mEventControlThread);
140 mScheduler->mutablePrimaryDispSync().reset(mPrimaryDispSync);
141 EXPECT_CALL(*mEventThread.get(), registerDisplayEventConnection(_));
142 sp<Scheduler::ConnectionHandle> connectionHandle =
143 mScheduler->addConnection(std::move(mEventThread));
144 mFlinger.mutableSfConnectionHandle() = std::move(connectionHandle);
145
146 mFlinger.mutableScheduler().reset(mScheduler);
147 }
148
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700149 void setupForceGeometryDirty() {
150 // TODO: This requires the visible region and other related
151 // state to be set, and is problematic for BufferLayers since they are
152 // not visible without a buffer (and setting up a buffer looks like a
153 // pain)
154 // mFlinger.mutableVisibleRegionsDirty() = true;
155
156 mFlinger.mutableGeometryInvalid() = true;
157 }
158
159 template <typename Case>
160 void displayRefreshCompositionDirtyGeometry();
161
162 template <typename Case>
163 void displayRefreshCompositionDirtyFrame();
164
165 template <typename Case>
166 void captureScreenComposition();
167
168 std::unordered_set<HWC2::Capability> mDefaultCapabilities = {HWC2::Capability::SidebandStream};
169
Ana Krulecafb45842019-02-13 13:33:03 -0800170 TestableScheduler* mScheduler;
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700171 TestableSurfaceFlinger mFlinger;
172 sp<DisplayDevice> mDisplay;
173 sp<DisplayDevice> mExternalDisplay;
Lloyd Pique542307f2018-10-19 13:24:08 -0700174 sp<compositionengine::mock::DisplaySurface> mDisplaySurface =
175 new compositionengine::mock::DisplaySurface();
Alec Mouriba013fa2018-10-16 12:43:11 -0700176 mock::NativeWindow* mNativeWindow = new mock::NativeWindow();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700177
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800178 sp<GraphicBuffer> mBuffer = new GraphicBuffer();
179 ANativeWindowBuffer* mNativeWindowBuffer = mBuffer->getNativeBuffer();
180
Ana Krulecafb45842019-02-13 13:33:03 -0800181 std::unique_ptr<mock::EventThread> mEventThread = std::make_unique<mock::EventThread>();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700182 mock::EventControlThread* mEventControlThread = new mock::EventControlThread();
183
184 Hwc2::mock::Composer* mComposer = nullptr;
185 renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine();
186 mock::MessageQueue* mMessageQueue = new mock::MessageQueue();
187 mock::DispSync* mPrimaryDispSync = new mock::DispSync();
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700188
189 sp<Fence> mClientTargetAcquireFence = Fence::NO_FENCE;
190
191 sp<GraphicBuffer> mCaptureScreenBuffer;
192};
193
194template <typename LayerCase>
195void CompositionTest::displayRefreshCompositionDirtyGeometry() {
196 setupForceGeometryDirty();
197 LayerCase::setupForDirtyGeometry(this);
198
199 // --------------------------------------------------------------------
200 // Invocation
201
202 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
203 mFlinger.onMessageReceived(MessageQueue::REFRESH);
204
205 LayerCase::cleanup(this);
206}
207
208template <typename LayerCase>
209void CompositionTest::displayRefreshCompositionDirtyFrame() {
210 LayerCase::setupForDirtyFrame(this);
211
212 // --------------------------------------------------------------------
213 // Invocation
214
215 mFlinger.onMessageReceived(MessageQueue::INVALIDATE);
216 mFlinger.onMessageReceived(MessageQueue::REFRESH);
217
218 LayerCase::cleanup(this);
219}
220
221template <typename LayerCase>
222void CompositionTest::captureScreenComposition() {
223 LayerCase::setupForScreenCapture(this);
224
225 const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700226 constexpr bool useIdentityTransform = true;
227 constexpr bool forSystem = true;
228
229 DisplayRenderArea renderArea(mDisplay, sourceCrop, DEFAULT_DISPLAY_WIDTH,
Peiyong Lin0e003c92018-09-17 11:09:51 -0700230 DEFAULT_DISPLAY_HEIGHT, ui::Dataspace::V0_SRGB,
231 ui::Transform::ROT_0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700232
233 auto traverseLayers = [this](const LayerVector::Visitor& visitor) {
chaviw0e3479f2018-09-10 16:49:30 -0700234 return mFlinger.traverseLayersInDisplay(mDisplay, visitor);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700235 };
236
237 // TODO: Eliminate expensive/real allocation if possible.
238 const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
239 GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
240 mCaptureScreenBuffer = new GraphicBuffer(renderArea.getReqWidth(), renderArea.getReqHeight(),
241 HAL_PIXEL_FORMAT_RGBA_8888, 1, usage, "screenshot");
242
243 int fd = -1;
244 status_t result =
245 mFlinger.captureScreenImplLocked(renderArea, traverseLayers, mCaptureScreenBuffer.get(),
246 useIdentityTransform, forSystem, &fd);
247 if (fd >= 0) {
248 close(fd);
249 }
250
251 EXPECT_EQ(NO_ERROR, result);
252
253 LayerCase::cleanup(this);
254}
255
256/* ------------------------------------------------------------------------
257 * Variants for each display configuration which can be tested
258 */
259
260template <typename Derived>
261struct BaseDisplayVariant {
262 static constexpr bool IS_SECURE = true;
263 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_NORMAL;
264
265 static void setupPreconditions(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700266 EXPECT_CALL(*test->mComposer,
267 setPowerMode(HWC_DISPLAY,
268 static_cast<Hwc2::IComposerClient::PowerMode>(
269 Derived::INIT_POWER_MODE)))
270 .WillOnce(Return(Error::NONE));
Alec Mouriba013fa2018-10-16 12:43:11 -0700271
Dominik Laskowski075d3172018-05-24 15:50:06 -0700272 FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, HWC2::DisplayType::Physical,
273 true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700274 .setCapabilities(&test->mDefaultCapabilities)
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700275 .setPowerMode(Derived::INIT_POWER_MODE)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700276 .inject(&test->mFlinger, test->mComposer);
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800277 Mock::VerifyAndClear(test->mComposer);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700278
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800279 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
280 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
281 EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
282 .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));
283 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_BUFFERS_FORMAT)).Times(1);
284 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_API_CONNECT)).Times(1);
285 EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_USAGE64)).Times(1);
Dominik Laskowski075d3172018-05-24 15:50:06 -0700286 test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, DEFAULT_DISPLAY_ID,
287 false /* isVirtual */, true /* isPrimary */)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700288 .setDisplaySurface(test->mDisplaySurface)
Alec Mouriba013fa2018-10-16 12:43:11 -0700289 .setNativeWindow(test->mNativeWindow)
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700290 .setSecure(Derived::IS_SECURE)
291 .setPowerMode(Derived::INIT_POWER_MODE)
292 .inject();
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800293 Mock::VerifyAndClear(test->mNativeWindow);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700294 test->mDisplay->setLayerStack(DEFAULT_LAYER_STACK);
295 }
296
297 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700298 static void setupPreconditionCallExpectations(CompositionTest* test) {
299 EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
300 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
301 Return(Error::NONE)));
302 }
303
304 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700305 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
306 EXPECT_CALL(*test->mComposer,
307 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
308 .Times(1);
309 EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _)).Times(1);
310 EXPECT_CALL(*test->mComposer, getDisplayRequests(HWC_DISPLAY, _, _, _)).Times(1);
311 EXPECT_CALL(*test->mComposer, acceptDisplayChanges(HWC_DISPLAY)).Times(1);
312 EXPECT_CALL(*test->mComposer, presentDisplay(HWC_DISPLAY, _)).Times(1);
313 EXPECT_CALL(*test->mComposer, getReleaseFences(HWC_DISPLAY, _, _)).Times(1);
314
315 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000316 // TODO: remove once we verify that we can just grab the fence from the
317 // FramebufferSurface.
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800318 EXPECT_CALL(*test->mRenderEngine, flush()).WillRepeatedly(Invoke([]() {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000319 return base::unique_fd();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800320 }));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700321
322 EXPECT_CALL(*test->mDisplaySurface, onFrameCommitted()).Times(1);
323 EXPECT_CALL(*test->mDisplaySurface, advanceFrame()).Times(1);
324
325 Case::CompositionType::setupHwcSetCallExpectations(test);
326 Case::CompositionType::setupHwcGetCallExpectations(test);
327 }
328
329 template <typename Case>
330 static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000331 EXPECT_CALL(*test->mRenderEngine, drawLayers)
332 .WillRepeatedly(
333 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700334 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
335 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000336 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
337 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
338 displaySettings.physicalDisplay);
339 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
340 displaySettings.clip);
341 return NO_ERROR;
342 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700343 }
344
345 static void setupNonEmptyFrameCompositionCallExpectations(CompositionTest* test) {
346 EXPECT_CALL(*test->mDisplaySurface, beginFrame(true)).Times(1);
347 }
348
349 static void setupEmptyFrameCompositionCallExpectations(CompositionTest* test) {
350 EXPECT_CALL(*test->mDisplaySurface, beginFrame(false)).Times(1);
351 }
352
353 static void setupHwcCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700354 EXPECT_CALL(*test->mDisplaySurface,
355 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_HWC))
356 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700357 }
358
359 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique542307f2018-10-19 13:24:08 -0700360 EXPECT_CALL(*test->mDisplaySurface,
361 prepareFrame(compositionengine::DisplaySurface::COMPOSITION_GLES))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700362 .Times(1);
363 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
364 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
365
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800366 EXPECT_CALL(*test->mNativeWindow, queueBuffer(_, _)).WillOnce(Return(0));
367 EXPECT_CALL(*test->mNativeWindow, dequeueBuffer(_, _))
368 .WillOnce(DoAll(SetArgPointee<0>(test->mNativeWindowBuffer), SetArgPointee<1>(-1),
369 Return(0)));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000370 EXPECT_CALL(*test->mRenderEngine, drawLayers)
371 .WillRepeatedly(
372 [](const renderengine::DisplaySettings& displaySettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700373 const std::vector<renderengine::LayerSettings>&, ANativeWindowBuffer*,
374 const bool, base::unique_fd&&, base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000375 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
376 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
377 displaySettings.physicalDisplay);
378 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
379 displaySettings.clip);
380 EXPECT_EQ(ui::Dataspace::UNKNOWN, displaySettings.outputDataspace);
381 return NO_ERROR;
382 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700383 }
384
385 template <typename Case>
386 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
387 Case::Layer::setupRECompositionCallExpectations(test);
388 }
389
390 template <typename Case>
391 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
392 Case::Layer::setupREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700393 }
394};
395
396struct DefaultDisplaySetupVariant : public BaseDisplayVariant<DefaultDisplaySetupVariant> {};
397
398struct InsecureDisplaySetupVariant : public BaseDisplayVariant<InsecureDisplaySetupVariant> {
399 static constexpr bool IS_SECURE = false;
400
401 template <typename Case>
402 static void setupRELayerCompositionCallExpectations(CompositionTest* test) {
403 Case::Layer::setupInsecureRECompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700404 }
405
406 template <typename Case>
407 static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) {
408 Case::Layer::setupInsecureREScreenshotCompositionCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700409 }
410};
411
412struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> {
413 static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;
414
415 template <typename Case>
Peiyong Lin1336e6e2019-05-28 09:23:50 -0700416 static void setupPreconditionCallExpectations(CompositionTest*) {}
417
418 template <typename Case>
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700419 static void setupCommonCompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800420 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
421
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700422 // TODO: This seems like an unnecessary call if display is powered off.
423 EXPECT_CALL(*test->mComposer,
424 setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
425 .Times(1);
426
427 // TODO: This seems like an unnecessary call if display is powered off.
428 Case::CompositionType::setupHwcSetCallExpectations(test);
429 }
430
431 static void setupHwcCompositionCallExpectations(CompositionTest*) {}
432
433 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Pique86fa3db2019-02-04 18:46:01 -0800434 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
435
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700436 // TODO: This seems like an unnecessary call if display is powered off.
437 EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence())
438 .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence));
439 }
440
441 template <typename Case>
442 static void setupRELayerCompositionCallExpectations(CompositionTest*) {}
443};
444
445/* ------------------------------------------------------------------------
446 * Variants for each layer configuration which can be tested
447 */
448
449template <typename LayerProperties>
450struct BaseLayerProperties {
451 static constexpr uint32_t WIDTH = 100;
452 static constexpr uint32_t HEIGHT = 100;
453 static constexpr PixelFormat FORMAT = PIXEL_FORMAT_RGBA_8888;
454 static constexpr uint64_t USAGE =
455 GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_SW_WRITE_NEVER;
456 static constexpr android_dataspace DATASPACE = HAL_DATASPACE_UNKNOWN;
457 static constexpr uint32_t SCALING_MODE = 0;
458 static constexpr uint32_t TRANSFORM = 0;
459 static constexpr uint32_t LAYER_FLAGS = 0;
460 static constexpr float COLOR[] = {1.f, 1.f, 1.f, 1.f};
461 static constexpr IComposerClient::BlendMode BLENDMODE =
462 IComposerClient::BlendMode::PREMULTIPLIED;
463
464 static void enqueueBuffer(CompositionTest*, sp<BufferQueueLayer> layer) {
465 auto producer = layer->getProducer();
466
467 IGraphicBufferProducer::QueueBufferOutput qbo;
468 status_t result = producer->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &qbo);
469 if (result != NO_ERROR) {
470 ALOGE("Failed to connect() (%d)", result);
471 return;
472 }
473
474 int slot;
475 sp<Fence> fence;
476 result = producer->dequeueBuffer(&slot, &fence, LayerProperties::WIDTH,
477 LayerProperties::HEIGHT, LayerProperties::FORMAT,
478 LayerProperties::USAGE, nullptr, nullptr);
479 if (result != IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
480 ALOGE("Failed to dequeueBuffer() (%d)", result);
481 return;
482 }
483
484 sp<GraphicBuffer> buffer;
485 result = producer->requestBuffer(slot, &buffer);
486 if (result != NO_ERROR) {
487 ALOGE("Failed to requestBuffer() (%d)", result);
488 return;
489 }
490
491 IGraphicBufferProducer::QueueBufferInput qbi(systemTime(), false /* isAutoTimestamp */,
492 LayerProperties::DATASPACE,
493 Rect(LayerProperties::WIDTH,
494 LayerProperties::HEIGHT),
495 LayerProperties::SCALING_MODE,
496 LayerProperties::TRANSFORM, Fence::NO_FENCE);
497 result = producer->queueBuffer(slot, qbi, &qbo);
498 if (result != NO_ERROR) {
499 ALOGE("Failed to queueBuffer (%d)", result);
500 return;
501 }
502 }
503
504 static void setupLatchedBuffer(CompositionTest* test, sp<BufferQueueLayer> layer) {
505 // TODO: Eliminate the complexity of actually creating a buffer
506 EXPECT_CALL(*test->mRenderEngine, getMaxTextureSize()).WillOnce(Return(16384));
507 EXPECT_CALL(*test->mRenderEngine, getMaxViewportDims()).WillOnce(Return(16384));
508 status_t err =
509 layer->setDefaultBufferProperties(LayerProperties::WIDTH, LayerProperties::HEIGHT,
510 LayerProperties::FORMAT);
511 ASSERT_EQ(NO_ERROR, err);
512 Mock::VerifyAndClear(test->mRenderEngine);
513
514 EXPECT_CALL(*test->mMessageQueue, invalidate()).Times(1);
515 enqueueBuffer(test, layer);
516 Mock::VerifyAndClear(test->mMessageQueue);
517
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700518 EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700519 bool ignoredRecomputeVisibleRegions;
Alec Mouri56e538f2019-01-14 15:22:01 -0800520 layer->latchBuffer(ignoredRecomputeVisibleRegions, 0);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700521 Mock::VerifyAndClear(test->mRenderEngine);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700522 }
523
524 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
525 setupLatchedBuffer(test, layer);
526 }
527
528 static void setupBufferLayerPostFrameCallExpectations(CompositionTest* test) {
529 // BufferLayer::onPostComposition(), when there is no present fence
530 EXPECT_CALL(*test->mComposer, getActiveConfig(HWC_DISPLAY, _))
531 .WillOnce(DoAll(SetArgPointee<1>(DEFAULT_CONFIG_ID), Return(Error::NONE)));
532 }
533
534 static void setupHwcSetGeometryCallExpectations(CompositionTest* test) {
535 // TODO: Coverage of other values
536 EXPECT_CALL(*test->mComposer,
537 setLayerBlendMode(HWC_DISPLAY, HWC_LAYER, LayerProperties::BLENDMODE))
538 .Times(1);
539 // TODO: Coverage of other values for origin
540 EXPECT_CALL(*test->mComposer,
541 setLayerDisplayFrame(HWC_DISPLAY, HWC_LAYER,
542 IComposerClient::Rect({0, 0, LayerProperties::WIDTH,
543 LayerProperties::HEIGHT})))
544 .Times(1);
545 EXPECT_CALL(*test->mComposer,
546 setLayerPlaneAlpha(HWC_DISPLAY, HWC_LAYER, LayerProperties::COLOR[3]))
547 .Times(1);
548 // TODO: Coverage of other values
549 EXPECT_CALL(*test->mComposer, setLayerZOrder(HWC_DISPLAY, HWC_LAYER, 0u)).Times(1);
550 // TODO: Coverage of other values
551 EXPECT_CALL(*test->mComposer, setLayerInfo(HWC_DISPLAY, HWC_LAYER, 0u, 0u)).Times(1);
552
553 // These expectations retire on saturation as the code path these
554 // expectations are for appears to make an extra call to them.
555 // TODO: Investigate this extra call
556 EXPECT_CALL(*test->mComposer, setLayerTransform(HWC_DISPLAY, HWC_LAYER, DEFAULT_TRANSFORM))
David Sodman15094112018-10-11 09:39:37 -0700557 .Times(AtLeast(1))
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700558 .RetiresOnSaturation();
559 }
560
561 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
562 EXPECT_CALL(*test->mComposer,
563 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
564 IComposerClient::FRect({0.f, 0.f, LayerProperties::WIDTH,
565 LayerProperties::HEIGHT})))
566 .Times(1);
567 }
568
569 static void setupHwcSetSourceCropColorCallExpectations(CompositionTest* test) {
570 EXPECT_CALL(*test->mComposer,
571 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
572 IComposerClient::FRect({0.f, 0.f, 0.f, 0.f})))
573 .Times(1);
574 }
575
576 static void setupHwcSetPerFrameCallExpectations(CompositionTest* test) {
577 EXPECT_CALL(*test->mComposer,
578 setLayerVisibleRegion(HWC_DISPLAY, HWC_LAYER,
579 std::vector<IComposerClient::Rect>({IComposerClient::Rect(
580 {0, 0, LayerProperties::WIDTH,
581 LayerProperties::HEIGHT})})))
582 .Times(1);
583 }
584
585 static void setupHwcSetPerFrameColorCallExpectations(CompositionTest* test) {
586 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
587
588 // TODO: use COLOR
589 EXPECT_CALL(*test->mComposer,
590 setLayerColor(HWC_DISPLAY, HWC_LAYER,
591 IComposerClient::Color({0xff, 0xff, 0xff, 0xff})))
592 .Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700593 }
594
595 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
596 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
597 EXPECT_CALL(*test->mComposer, setLayerBuffer(HWC_DISPLAY, HWC_LAYER, _, _, _)).Times(1);
598
599 setupBufferLayerPostFrameCallExpectations(test);
600 }
601
602 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000603 EXPECT_CALL(*test->mRenderEngine, drawLayers)
604 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
605 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700606 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800607 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000608 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
609 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
610 displaySettings.physicalDisplay);
611 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
612 displaySettings.clip);
613 // screen capture adds an additional color layer as an alpha
614 // prefill, so gtet the back layer.
615 renderengine::LayerSettings layer = layerSettings.back();
616 EXPECT_THAT(layer.source.buffer.buffer, Not(IsNull()));
617 EXPECT_THAT(layer.source.buffer.fence, Not(IsNull()));
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000618 EXPECT_EQ(DEFAULT_TEXTURE_ID, layer.source.buffer.textureName);
619 EXPECT_EQ(false, layer.source.buffer.isY410BT2020);
620 EXPECT_EQ(true, layer.source.buffer.usePremultipliedAlpha);
621 EXPECT_EQ(false, layer.source.buffer.isOpaque);
622 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
623 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
624 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
625 return NO_ERROR;
626 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700627 }
628
629 static void setupREBufferCompositionCallExpectations(CompositionTest* test) {
630 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700631 }
632
633 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
634 setupREBufferCompositionCallExpectations(test);
635 }
636
637 static void setupREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
638 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
639 }
640
641 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
642 LayerProperties::setupREBufferCompositionCommonCallExpectations(test);
643 }
644
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700645 static void setupREColorCompositionCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000646 EXPECT_CALL(*test->mRenderEngine, drawLayers)
647 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
648 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700649 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800650 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000651 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
652 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
653 displaySettings.physicalDisplay);
654 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
655 displaySettings.clip);
656 // screen capture adds an additional color layer as an alpha
657 // prefill, so get the back layer.
658 renderengine::LayerSettings layer = layerSettings.back();
659 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
660 EXPECT_EQ(half3(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
661 LayerProperties::COLOR[2]),
662 layer.source.solidColor);
663 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
664 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
665 EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha);
666 return NO_ERROR;
667 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700668 }
669
670 static void setupREColorScreenshotCompositionCallExpectations(CompositionTest* test) {
671 setupREColorCompositionCallExpectations(test);
672 }
673};
674
675struct DefaultLayerProperties : public BaseLayerProperties<DefaultLayerProperties> {};
676
677struct ColorLayerProperties : public BaseLayerProperties<ColorLayerProperties> {};
678
679struct SidebandLayerProperties : public BaseLayerProperties<SidebandLayerProperties> {
680 using Base = BaseLayerProperties<SidebandLayerProperties>;
681 static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE;
682
683 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
684 sp<NativeHandle> stream =
685 NativeHandle::create(reinterpret_cast<native_handle_t*>(DEFAULT_SIDEBAND_STREAM),
686 false);
687 test->mFlinger.setLayerSidebandStream(layer, stream);
688 }
689
690 static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) {
691 EXPECT_CALL(*test->mComposer,
692 setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER,
693 IComposerClient::FRect({0.f, 0.f, -1.f, -1.f})))
694 .Times(1);
695 }
696
697 static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) {
698 EXPECT_CALL(*test->mComposer,
699 setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER,
700 reinterpret_cast<native_handle_t*>(
701 DEFAULT_SIDEBAND_STREAM)))
702 .WillOnce(Return(Error::NONE));
703
704 EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1);
705 }
706
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000707 static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {}
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700708};
709
710struct SecureLayerProperties : public BaseLayerProperties<SecureLayerProperties> {
711 using Base = BaseLayerProperties<SecureLayerProperties>;
712
713 static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure;
714
715 static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000716 EXPECT_CALL(*test->mRenderEngine, drawLayers)
717 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
718 const std::vector<renderengine::LayerSettings>& layerSettings,
Alec Mourife0d72b2019-03-21 14:05:56 -0700719 ANativeWindowBuffer*, const bool, base::unique_fd&&,
Alec Mouri6338c9d2019-02-07 16:57:51 -0800720 base::unique_fd*) -> status_t {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000721 EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
722 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
723 displaySettings.physicalDisplay);
724 EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
725 displaySettings.clip);
726 // screen capture adds an additional color layer as an alpha
727 // prefill, so get the back layer.
728 renderengine::LayerSettings layer = layerSettings.back();
729 EXPECT_THAT(layer.source.buffer.buffer, IsNull());
730 EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor);
731 EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius);
732 EXPECT_EQ(ui::Dataspace::UNKNOWN, layer.sourceDataspace);
733 EXPECT_EQ(1.0f, layer.alpha);
734 return NO_ERROR;
735 });
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700736 }
737
738 static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) {
739 setupInsecureREBufferCompositionCommonCallExpectations(test);
740 Base::setupBufferLayerPostFrameCallExpectations(test);
741 }
742
743 static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) {
744 setupInsecureREBufferCompositionCommonCallExpectations(test);
745 }
746};
747
748struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> {
749 using Base = BaseLayerProperties<CursorLayerProperties>;
750
751 static void setupLayerState(CompositionTest* test, sp<BufferQueueLayer> layer) {
752 Base::setupLayerState(test, layer);
753 test->mFlinger.setLayerPotentialCursor(layer, true);
754 }
755};
756
757struct NoLayerVariant {
758 using FlingerLayerType = sp<BufferQueueLayer>;
759
760 static FlingerLayerType createLayer(CompositionTest*) { return FlingerLayerType(); }
761 static void injectLayer(CompositionTest*, FlingerLayerType) {}
762 static void cleanupInjectedLayers(CompositionTest*) {}
763
764 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
765 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
766};
767
768template <typename LayerProperties>
769struct BaseLayerVariant {
770 template <typename L, typename F>
771 static sp<L> createLayerWithFactory(CompositionTest* test, F factory) {
772 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(0);
773
774 sp<L> layer = factory();
775
776 Mock::VerifyAndClear(test->mComposer);
777 Mock::VerifyAndClear(test->mRenderEngine);
778 Mock::VerifyAndClear(test->mMessageQueue);
779
780 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
781 layerDrawingState.layerStack = DEFAULT_LAYER_STACK;
782 layerDrawingState.active.w = 100;
783 layerDrawingState.active.h = 100;
784 layerDrawingState.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
785 LayerProperties::COLOR[2], LayerProperties::COLOR[3]);
Vishnu Nair4351ad52019-02-11 14:13:02 -0800786 layer->computeBounds(FloatRect(0, 0, 100, 100), ui::Transform());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700787 layer->setVisibleRegion(Region(Rect(0, 0, 100, 100)));
788
789 return layer;
790 }
791
792 static void injectLayer(CompositionTest* test, sp<Layer> layer) {
793 EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _))
794 .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE)));
795
Lloyd Pique07e33212018-12-18 16:33:37 -0800796 std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
797 outputLayers.emplace_back(test->mDisplay->getCompositionDisplay()
798 ->getOrCreateOutputLayer(DEFAULT_DISPLAY_ID,
799 layer->getCompositionLayer(),
800 layer));
801
802 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700803
804 Mock::VerifyAndClear(test->mComposer);
805
806 Vector<sp<Layer>> layers;
807 layers.add(layer);
808 test->mDisplay->setVisibleLayersSortedByZ(layers);
809 test->mFlinger.mutableDrawingState().layersSortedByZ.add(layer);
810 }
811
812 static void cleanupInjectedLayers(CompositionTest* test) {
813 EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER))
814 .WillOnce(Return(Error::NONE));
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800815
816 test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(
817 std::vector<std::unique_ptr<compositionengine::OutputLayer>>());
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700818 test->mFlinger.mutableDrawingState().layersSortedByZ.clear();
819 }
820};
821
822template <typename LayerProperties>
823struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> {
824 using Base = BaseLayerVariant<LayerProperties>;
825 using FlingerLayerType = sp<ColorLayer>;
826
827 static FlingerLayerType createLayer(CompositionTest* test) {
828 FlingerLayerType layer = Base::template createLayerWithFactory<ColorLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700829 return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
830 String8("test-layer"), LayerProperties::WIDTH,
831 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800832 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700833 });
Vishnu Nair60356342018-11-13 13:00:45 -0800834
835 auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
836 layerDrawingState.crop_legacy = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700837 return layer;
838 }
839
840 static void setupRECompositionCallExpectations(CompositionTest* test) {
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700841 LayerProperties::setupREColorCompositionCallExpectations(test);
842 }
843
844 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
845 LayerProperties::setupREColorScreenshotCompositionCallExpectations(test);
846 }
847
848 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
849 LayerProperties::setupHwcSetGeometryCallExpectations(test);
850 LayerProperties::setupHwcSetSourceCropColorCallExpectations(test);
851 }
852
853 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
854 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
855 LayerProperties::setupHwcSetPerFrameColorCallExpectations(test);
856 }
857};
858
859template <typename LayerProperties>
860struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> {
861 using Base = BaseLayerVariant<LayerProperties>;
862 using FlingerLayerType = sp<BufferQueueLayer>;
863
864 static FlingerLayerType createLayer(CompositionTest* test) {
865 test->mFlinger.mutableTexturePool().push_back(DEFAULT_TEXTURE_ID);
866
867 FlingerLayerType layer =
868 Base::template createLayerWithFactory<BufferQueueLayer>(test, [test]() {
Lloyd Pique42ab75e2018-09-12 20:46:03 -0700869 return new BufferQueueLayer(
870 LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(),
871 String8("test-layer"), LayerProperties::WIDTH,
872 LayerProperties::HEIGHT,
Evan Roskya1f1e152019-01-24 16:17:46 -0800873 LayerProperties::LAYER_FLAGS, LayerMetadata()));
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700874 });
875
876 LayerProperties::setupLayerState(test, layer);
877
878 return layer;
879 }
880
881 static void cleanupInjectedLayers(CompositionTest* test) {
Dan Stoza67765d82019-05-07 14:58:27 -0700882 EXPECT_CALL(*test->mMessageQueue, postMessage(_, 0)).Times(1);
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700883 Base::cleanupInjectedLayers(test);
884 }
885
886 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
887 LayerProperties::setupHwcSetGeometryCallExpectations(test);
888 LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test);
889 }
890
891 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
892 LayerProperties::setupHwcSetPerFrameCallExpectations(test);
893 LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test);
894 }
895
896 static void setupRECompositionCallExpectations(CompositionTest* test) {
897 LayerProperties::setupREBufferCompositionCallExpectations(test);
898 }
899
900 static void setupInsecureRECompositionCallExpectations(CompositionTest* test) {
901 LayerProperties::setupInsecureREBufferCompositionCallExpectations(test);
902 }
903
904 static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) {
905 LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test);
906 }
907
908 static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) {
909 LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test);
910 }
911};
912
913/* ------------------------------------------------------------------------
914 * Variants to control how the composition type is changed
915 */
916
917struct NoCompositionTypeVariant {
918 static void setupHwcSetCallExpectations(CompositionTest*) {}
919
920 static void setupHwcGetCallExpectations(CompositionTest* test) {
921 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
922 }
923};
924
925template <IComposerClient::Composition CompositionType>
926struct KeepCompositionTypeVariant {
927 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(CompositionType);
928
929 static void setupHwcSetCallExpectations(CompositionTest* test) {
930 EXPECT_CALL(*test->mComposer,
931 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType))
932 .Times(1);
933 }
934
935 static void setupHwcGetCallExpectations(CompositionTest* test) {
936 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1);
937 }
938};
939
940template <IComposerClient::Composition InitialCompositionType,
941 IComposerClient::Composition FinalCompositionType>
942struct ChangeCompositionTypeVariant {
943 static constexpr HWC2::Composition TYPE = static_cast<HWC2::Composition>(FinalCompositionType);
944
945 static void setupHwcSetCallExpectations(CompositionTest* test) {
946 EXPECT_CALL(*test->mComposer,
947 setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType))
948 .Times(1);
949 }
950
951 static void setupHwcGetCallExpectations(CompositionTest* test) {
952 EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _))
953 .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{
954 static_cast<Hwc2::Layer>(HWC_LAYER)}),
955 SetArgPointee<2>(std::vector<IComposerClient::Composition>{
956 FinalCompositionType}),
957 Return(Error::NONE)));
958 }
959};
960
961/* ------------------------------------------------------------------------
962 * Variants to select how the composition is expected to be handled
963 */
964
965struct CompositionResultBaseVariant {
966 static void setupLayerState(CompositionTest*, sp<Layer>) {}
967
968 template <typename Case>
969 static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) {
970 Case::Layer::setupCallExpectationsForDirtyGeometry(test);
971 }
972
973 template <typename Case>
974 static void setupCallExpectationsForDirtyFrame(CompositionTest* test) {
975 Case::Layer::setupCallExpectationsForDirtyFrame(test);
976 }
977};
978
979struct NoCompositionResultVariant : public CompositionResultBaseVariant {
980 template <typename Case>
981 static void setupCallExpectations(CompositionTest* test) {
982 Case::Display::setupEmptyFrameCompositionCallExpectations(test);
983 Case::Display::setupHwcCompositionCallExpectations(test);
984 }
985};
986
987struct HwcCompositionResultVariant : public CompositionResultBaseVariant {
988 template <typename Case>
989 static void setupCallExpectations(CompositionTest* test) {
990 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
991 Case::Display::setupHwcCompositionCallExpectations(test);
992 }
993};
994
995struct RECompositionResultVariant : public CompositionResultBaseVariant {
996 template <typename Case>
997 static void setupCallExpectations(CompositionTest* test) {
998 Case::Display::setupNonEmptyFrameCompositionCallExpectations(test);
999 Case::Display::setupRECompositionCallExpectations(test);
1000 Case::Display::template setupRELayerCompositionCallExpectations<Case>(test);
1001 }
1002};
1003
1004struct ForcedClientCompositionResultVariant : public RECompositionResultVariant {
Lloyd Pique37c2c9b2018-12-04 17:25:10 -08001005 static void setupLayerState(CompositionTest* test, sp<Layer> layer) {
1006 layer->forceClientComposition(test->mDisplay);
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001007 }
1008
1009 template <typename Case>
1010 static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {}
1011
1012 template <typename Case>
1013 static void setupCallExpectationsForDirtyFrame(CompositionTest*) {}
1014};
1015
1016struct EmptyScreenshotResultVariant {
1017 static void setupLayerState(CompositionTest*, sp<Layer>) {}
1018
1019 template <typename Case>
1020 static void setupCallExpectations(CompositionTest*) {}
1021};
1022
1023struct REScreenshotResultVariant : public EmptyScreenshotResultVariant {
1024 using Base = EmptyScreenshotResultVariant;
1025
1026 template <typename Case>
1027 static void setupCallExpectations(CompositionTest* test) {
1028 Base::template setupCallExpectations<Case>(test);
1029 Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test);
1030 }
1031};
1032
1033/* ------------------------------------------------------------------------
1034 * Composition test case, containing all the variants being tested
1035 */
1036
1037template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase,
1038 typename CompositionResultCase>
1039struct CompositionCase {
1040 using ThisCase =
1041 CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>;
1042 using Display = DisplayCase;
1043 using Layer = LayerCase;
1044 using CompositionType = CompositionTypeCase;
1045 using CompositionResult = CompositionResultCase;
1046
1047 static void setupCommon(CompositionTest* test) {
Peiyong Lin1336e6e2019-05-28 09:23:50 -07001048 Display::template setupPreconditionCallExpectations<ThisCase>(test);
Lloyd Piqued6b579f2018-04-06 15:29:10 -07001049 Display::setupPreconditions(test);
1050
1051 auto layer = Layer::createLayer(test);
1052 Layer::injectLayer(test, layer);
1053 CompositionResult::setupLayerState(test, layer);
1054 }
1055
1056 static void setupForDirtyGeometry(CompositionTest* test) {
1057 setupCommon(test);
1058
1059 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1060 CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test);
1061 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1062 CompositionResult::template setupCallExpectations<ThisCase>(test);
1063 }
1064
1065 static void setupForDirtyFrame(CompositionTest* test) {
1066 setupCommon(test);
1067
1068 Display::template setupCommonCompositionCallExpectations<ThisCase>(test);
1069 CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test);
1070 CompositionResult::template setupCallExpectations<ThisCase>(test);
1071 }
1072
1073 static void setupForScreenCapture(CompositionTest* test) {
1074 setupCommon(test);
1075
1076 Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test);
1077 CompositionResult::template setupCallExpectations<ThisCase>(test);
1078 }
1079
1080 static void cleanup(CompositionTest* test) {
1081 Layer::cleanupInjectedLayers(test);
1082
1083 for (auto& hwcDisplay : test->mFlinger.mFakeHwcDisplays) {
1084 hwcDisplay->mutableLayers().clear();
1085 }
1086
1087 test->mDisplay->setVisibleLayersSortedByZ(Vector<sp<android::Layer>>());
1088 }
1089};
1090
1091/* ------------------------------------------------------------------------
1092 * Composition cases to test
1093 */
1094
1095TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) {
1096 displayRefreshCompositionDirtyGeometry<
1097 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1098 NoCompositionResultVariant>>();
1099}
1100
1101TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) {
1102 displayRefreshCompositionDirtyFrame<
1103 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1104 NoCompositionResultVariant>>();
1105}
1106
1107TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) {
1108 captureScreenComposition<
1109 CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant,
1110 EmptyScreenshotResultVariant>>();
1111}
1112
1113/* ------------------------------------------------------------------------
1114 * Simple buffer layers
1115 */
1116
1117TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) {
1118 displayRefreshCompositionDirtyGeometry<
1119 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1120 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1121 HwcCompositionResultVariant>>();
1122}
1123
1124TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) {
1125 displayRefreshCompositionDirtyFrame<
1126 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1127 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1128 HwcCompositionResultVariant>>();
1129}
1130
1131TEST_F(CompositionTest, REComposedNormalBufferLayer) {
1132 displayRefreshCompositionDirtyFrame<
1133 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1134 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1135 IComposerClient::Composition::CLIENT>,
1136 RECompositionResultVariant>>();
1137}
1138
1139TEST_F(CompositionTest, captureScreenNormalBufferLayer) {
1140 captureScreenComposition<
1141 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1142 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1143}
1144
1145/* ------------------------------------------------------------------------
1146 * Single-color layers
1147 */
1148
1149TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyGeometry) {
1150 displayRefreshCompositionDirtyGeometry<
1151 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1152 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1153 HwcCompositionResultVariant>>();
1154}
1155
1156TEST_F(CompositionTest, HWCComposedColorLayerWithDirtyFrame) {
1157 displayRefreshCompositionDirtyFrame<
1158 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1159 KeepCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR>,
1160 HwcCompositionResultVariant>>();
1161}
1162
1163TEST_F(CompositionTest, REComposedColorLayer) {
1164 displayRefreshCompositionDirtyFrame<
1165 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1166 ChangeCompositionTypeVariant<IComposerClient::Composition::SOLID_COLOR,
1167 IComposerClient::Composition::CLIENT>,
1168 RECompositionResultVariant>>();
1169}
1170
1171TEST_F(CompositionTest, captureScreenColorLayer) {
1172 captureScreenComposition<
1173 CompositionCase<DefaultDisplaySetupVariant, ColorLayerVariant<ColorLayerProperties>,
1174 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1175}
1176
1177/* ------------------------------------------------------------------------
1178 * Layers with sideband buffers
1179 */
1180
1181TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) {
1182 displayRefreshCompositionDirtyGeometry<
1183 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1184 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1185 HwcCompositionResultVariant>>();
1186}
1187
1188TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) {
1189 displayRefreshCompositionDirtyFrame<
1190 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1191 KeepCompositionTypeVariant<IComposerClient::Composition::SIDEBAND>,
1192 HwcCompositionResultVariant>>();
1193}
1194
1195TEST_F(CompositionTest, REComposedSidebandBufferLayer) {
1196 displayRefreshCompositionDirtyFrame<
1197 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1198 ChangeCompositionTypeVariant<IComposerClient::Composition::SIDEBAND,
1199 IComposerClient::Composition::CLIENT>,
1200 RECompositionResultVariant>>();
1201}
1202
1203TEST_F(CompositionTest, captureScreenSidebandBufferLayer) {
1204 captureScreenComposition<
1205 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>,
1206 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1207}
1208
1209/* ------------------------------------------------------------------------
1210 * Layers with ISurfaceComposerClient::eSecure, on a secure display
1211 */
1212
1213TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) {
1214 displayRefreshCompositionDirtyGeometry<
1215 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1216 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1217 HwcCompositionResultVariant>>();
1218}
1219
1220TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) {
1221 displayRefreshCompositionDirtyFrame<
1222 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1223 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1224 HwcCompositionResultVariant>>();
1225}
1226
1227TEST_F(CompositionTest, REComposedSecureBufferLayer) {
1228 displayRefreshCompositionDirtyFrame<
1229 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1230 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1231 IComposerClient::Composition::CLIENT>,
1232 RECompositionResultVariant>>();
1233}
1234
1235TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) {
1236 captureScreenComposition<
1237 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1238 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1239}
1240
1241/* ------------------------------------------------------------------------
1242 * Layers with ISurfaceComposerClient::eSecure, on a non-secure display
1243 */
1244
1245TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) {
1246 displayRefreshCompositionDirtyGeometry<
1247 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1248 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1249 ForcedClientCompositionResultVariant>>();
1250}
1251
1252TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) {
1253 displayRefreshCompositionDirtyFrame<
1254 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1255 KeepCompositionTypeVariant<IComposerClient::Composition::CLIENT>,
1256 ForcedClientCompositionResultVariant>>();
1257}
1258
1259TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) {
1260 captureScreenComposition<
1261 CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>,
1262 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1263}
1264
1265/* ------------------------------------------------------------------------
1266 * Cursor layers
1267 */
1268
1269TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) {
1270 displayRefreshCompositionDirtyGeometry<
1271 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1272 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1273 HwcCompositionResultVariant>>();
1274}
1275
1276TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) {
1277 displayRefreshCompositionDirtyFrame<
1278 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1279 KeepCompositionTypeVariant<IComposerClient::Composition::CURSOR>,
1280 HwcCompositionResultVariant>>();
1281}
1282
1283TEST_F(CompositionTest, REComposedCursorLayer) {
1284 displayRefreshCompositionDirtyFrame<
1285 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1286 ChangeCompositionTypeVariant<IComposerClient::Composition::CURSOR,
1287 IComposerClient::Composition::CLIENT>,
1288 RECompositionResultVariant>>();
1289}
1290
1291TEST_F(CompositionTest, captureScreenCursorLayer) {
1292 captureScreenComposition<
1293 CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>,
1294 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1295}
1296
1297/* ------------------------------------------------------------------------
1298 * Simple buffer layer on a display which is powered off.
1299 */
1300
1301TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) {
1302 displayRefreshCompositionDirtyGeometry<CompositionCase<
1303 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1304 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1305 HwcCompositionResultVariant>>();
1306}
1307
1308TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) {
1309 displayRefreshCompositionDirtyFrame<CompositionCase<
1310 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1311 KeepCompositionTypeVariant<IComposerClient::Composition::DEVICE>,
1312 HwcCompositionResultVariant>>();
1313}
1314
1315TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) {
1316 displayRefreshCompositionDirtyFrame<CompositionCase<
1317 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1318 ChangeCompositionTypeVariant<IComposerClient::Composition::DEVICE,
1319 IComposerClient::Composition::CLIENT>,
1320 RECompositionResultVariant>>();
1321}
1322
1323TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) {
1324 captureScreenComposition<CompositionCase<
1325 PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>,
1326 NoCompositionTypeVariant, REScreenshotResultVariant>>();
1327}
1328
1329} // namespace
1330} // namespace android