Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 20 | #pragma clang diagnostic ignored "-Wextra" |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 21 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 22 | #undef LOG_TAG |
| 23 | #define LOG_TAG "CompositionTest" |
| 24 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 25 | #include <compositionengine/Display.h> |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 26 | #include <compositionengine/mock/DisplaySurface.h> |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 27 | #include <ftl/future.h> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 28 | #include <gmock/gmock.h> |
| 29 | #include <gtest/gtest.h> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 30 | #include <gui/IProducerListener.h> |
Evan Rosky | a1f1e15 | 2019-01-24 16:17:46 -0800 | [diff] [blame] | 31 | #include <gui/LayerMetadata.h> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 32 | #include <log/log.h> |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 33 | #include <renderengine/ExternalTexture.h> |
Vishnu Nair | dbbe385 | 2022-01-12 20:22:11 -0800 | [diff] [blame] | 34 | #include <renderengine/mock/FakeExternalTexture.h> |
Lloyd Pique | 3823e7b | 2018-10-18 16:58:10 -0700 | [diff] [blame] | 35 | #include <renderengine/mock/RenderEngine.h> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 36 | #include <system/window.h> |
| 37 | #include <utils/String8.h> |
| 38 | |
Marin Shalamanov | f6b5d18 | 2020-06-12 02:08:51 +0200 | [diff] [blame] | 39 | #include "DisplayRenderArea.h" |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 40 | #include "Layer.h" |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 41 | #include "TestableSurfaceFlinger.h" |
| 42 | #include "mock/DisplayHardware/MockComposer.h" |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 43 | #include "mock/MockEventThread.h" |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 44 | #include "mock/MockTimeStats.h" |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 45 | #include "mock/MockVsyncController.h" |
Matt Buckley | 18b9352 | 2024-08-27 05:30:18 +0000 | [diff] [blame] | 46 | #include "mock/PowerAdvisor/MockPowerAdvisor.h" |
Alec Mouri | ba013fa | 2018-10-16 12:43:11 -0700 | [diff] [blame] | 47 | #include "mock/system/window/MockNativeWindow.h" |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 48 | |
| 49 | namespace android { |
| 50 | namespace { |
| 51 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 52 | namespace hal = android::hardware::graphics::composer::hal; |
| 53 | |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 54 | using hal::Error; |
| 55 | using hal::IComposer; |
| 56 | using hal::IComposerClient; |
| 57 | using hal::PowerMode; |
| 58 | using hal::Transform; |
| 59 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 60 | using aidl::android::hardware::graphics::composer3::Capability; |
| 61 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 62 | using testing::_; |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 63 | using testing::AtLeast; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 64 | using testing::DoAll; |
| 65 | using testing::IsNull; |
| 66 | using testing::Mock; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 67 | using testing::Return; |
| 68 | using testing::ReturnRef; |
| 69 | using testing::SetArgPointee; |
| 70 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 71 | using FakeHwcDisplayInjector = TestableSurfaceFlinger::FakeHwcDisplayInjector; |
| 72 | using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector; |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 73 | using namespace ftl::flag_operators; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 74 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 75 | constexpr hal::HWDisplayId HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DISPLAY_ID; |
| 76 | constexpr hal::HWLayerId HWC_LAYER = 5000; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 77 | constexpr Transform DEFAULT_TRANSFORM = static_cast<Transform>(0); |
| 78 | |
Dominik Laskowski | f183385 | 2021-03-23 15:06:50 -0700 | [diff] [blame] | 79 | constexpr PhysicalDisplayId DEFAULT_DISPLAY_ID = PhysicalDisplayId::fromPort(42u); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 80 | constexpr int DEFAULT_DISPLAY_WIDTH = 1920; |
| 81 | constexpr int DEFAULT_DISPLAY_HEIGHT = 1024; |
| 82 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 83 | constexpr int DEFAULT_TEXTURE_ID = 6000; |
Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 84 | constexpr ui::LayerStack LAYER_STACK{7000u}; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 85 | |
| 86 | constexpr int DEFAULT_DISPLAY_MAX_LUMINANCE = 500; |
| 87 | |
| 88 | constexpr int DEFAULT_SIDEBAND_STREAM = 51; |
| 89 | |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 90 | MATCHER(IsIdentityMatrix, "") { |
| 91 | constexpr auto kIdentity = mat4(); |
| 92 | return (mat4(arg) == kIdentity); |
| 93 | } |
| 94 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 95 | class CompositionTest : public testing::Test { |
| 96 | public: |
| 97 | CompositionTest() { |
| 98 | const ::testing::TestInfo* const test_info = |
| 99 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 100 | ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 101 | |
Dominik Laskowski | aee9a62 | 2023-02-11 14:24:19 -0500 | [diff] [blame] | 102 | mFlinger.setupMockScheduler({.displayId = DEFAULT_DISPLAY_ID}); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 103 | |
Alec Mouri | f6fd29e | 2018-11-17 04:56:41 +0000 | [diff] [blame] | 104 | EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_WIDTH, _)) |
| 105 | .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0))); |
| 106 | EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _)) |
| 107 | .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0))); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 108 | |
| 109 | mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine)); |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 110 | mFlinger.setupTimeStats(std::shared_ptr<TimeStats>(mTimeStats)); |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 111 | |
| 112 | mComposer = new Hwc2::mock::Composer(); |
Matt Buckley | 18b9352 | 2024-08-27 05:30:18 +0000 | [diff] [blame] | 113 | mPowerAdvisor = new adpf::mock::PowerAdvisor(); |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 114 | mFlinger.setupComposer(std::unique_ptr<Hwc2::Composer>(mComposer)); |
Matt Buckley | 18b9352 | 2024-08-27 05:30:18 +0000 | [diff] [blame] | 115 | mFlinger.setupPowerAdvisor(std::unique_ptr<adpf::PowerAdvisor>(mPowerAdvisor)); |
Garfield Tan | 9c9c191 | 2021-07-19 12:02:16 -0700 | [diff] [blame] | 116 | mFlinger.mutableMaxRenderTargetSize() = 16384; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | ~CompositionTest() { |
| 120 | const ::testing::TestInfo* const test_info = |
| 121 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 122 | ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 123 | } |
| 124 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 125 | void setupForceGeometryDirty() { |
| 126 | // TODO: This requires the visible region and other related |
| 127 | // state to be set, and is problematic for BufferLayers since they are |
| 128 | // not visible without a buffer (and setting up a buffer looks like a |
| 129 | // pain) |
| 130 | // mFlinger.mutableVisibleRegionsDirty() = true; |
| 131 | |
Dominik Laskowski | 8da6b0e | 2021-05-12 15:34:13 -0700 | [diff] [blame] | 132 | mFlinger.mutableGeometryDirty() = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | template <typename Case> |
| 136 | void displayRefreshCompositionDirtyGeometry(); |
| 137 | |
| 138 | template <typename Case> |
| 139 | void displayRefreshCompositionDirtyFrame(); |
| 140 | |
| 141 | template <typename Case> |
| 142 | void captureScreenComposition(); |
| 143 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 144 | std::unordered_set<Capability> mDefaultCapabilities = {Capability::SIDEBAND_STREAM}; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 145 | |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 146 | bool mDisplayOff = false; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 147 | TestableSurfaceFlinger mFlinger; |
| 148 | sp<DisplayDevice> mDisplay; |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 149 | sp<compositionengine::mock::DisplaySurface> mDisplaySurface = |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 150 | sp<compositionengine::mock::DisplaySurface>::make(); |
| 151 | sp<mock::NativeWindow> mNativeWindow = sp<mock::NativeWindow>::make(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 152 | |
Brian Lindahl | f5ab5ae | 2022-12-21 14:27:15 -0700 | [diff] [blame] | 153 | sp<GraphicBuffer> mBuffer = |
| 154 | sp<GraphicBuffer>::make(1u, 1u, PIXEL_FORMAT_RGBA_8888, |
| 155 | GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN); |
Alec Mouri | 0a9c7b8 | 2018-11-16 13:05:25 -0800 | [diff] [blame] | 156 | ANativeWindowBuffer* mNativeWindowBuffer = mBuffer->getNativeBuffer(); |
| 157 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 158 | Hwc2::mock::Composer* mComposer = nullptr; |
| 159 | renderengine::mock::RenderEngine* mRenderEngine = new renderengine::mock::RenderEngine(); |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 160 | mock::TimeStats* mTimeStats = new mock::TimeStats(); |
Matt Buckley | 18b9352 | 2024-08-27 05:30:18 +0000 | [diff] [blame] | 161 | adpf::mock::PowerAdvisor* mPowerAdvisor = nullptr; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 162 | |
| 163 | sp<Fence> mClientTargetAcquireFence = Fence::NO_FENCE; |
| 164 | |
Alec Mouri | a90a570 | 2021-04-16 16:36:21 +0000 | [diff] [blame] | 165 | std::shared_ptr<renderengine::ExternalTexture> mCaptureScreenBuffer; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | template <typename LayerCase> |
| 169 | void CompositionTest::displayRefreshCompositionDirtyGeometry() { |
| 170 | setupForceGeometryDirty(); |
| 171 | LayerCase::setupForDirtyGeometry(this); |
| 172 | |
| 173 | // -------------------------------------------------------------------- |
| 174 | // Invocation |
| 175 | |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 176 | mFlinger.commitAndComposite(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 177 | |
| 178 | LayerCase::cleanup(this); |
| 179 | } |
| 180 | |
| 181 | template <typename LayerCase> |
| 182 | void CompositionTest::displayRefreshCompositionDirtyFrame() { |
| 183 | LayerCase::setupForDirtyFrame(this); |
| 184 | |
| 185 | // -------------------------------------------------------------------- |
| 186 | // Invocation |
| 187 | |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 188 | mFlinger.commitAndComposite(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 189 | |
| 190 | LayerCase::cleanup(this); |
| 191 | } |
| 192 | |
| 193 | template <typename LayerCase> |
| 194 | void CompositionTest::captureScreenComposition() { |
| 195 | LayerCase::setupForScreenCapture(this); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 196 | mFlinger.commit(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 197 | |
| 198 | const Rect sourceCrop(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT); |
Lucas Dupin | 9d763b7 | 2020-04-20 18:42:31 -0700 | [diff] [blame] | 199 | constexpr bool regionSampling = false; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 200 | |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 201 | auto renderArea = |
| 202 | DisplayRenderArea::create(mDisplay, sourceCrop, sourceCrop.getSize(), |
| 203 | ui::Dataspace::V0_SRGB, |
| 204 | RenderArea::Options::CAPTURE_SECURE_LAYERS | |
| 205 | RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 206 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 207 | auto getLayerSnapshotsFn = mFlinger.getLayerSnapshotsForScreenshotsFn(mDisplay->getLayerStack(), |
| 208 | CaptureArgs::UNSET_UID); |
Vishnu Nair | 7aa0eb7 | 2023-01-24 03:59:27 +0000 | [diff] [blame] | 209 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 210 | const uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | |
| 211 | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE; |
Vishnu Nair | dbbe385 | 2022-01-12 20:22:11 -0800 | [diff] [blame] | 212 | mCaptureScreenBuffer = |
| 213 | std::make_shared<renderengine::mock::FakeExternalTexture>(renderArea->getReqWidth(), |
| 214 | renderArea->getReqHeight(), |
| 215 | HAL_PIXEL_FORMAT_RGBA_8888, 1, |
| 216 | usage); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 217 | |
Melody Hsu | eddfe93 | 2024-06-04 18:10:41 +0000 | [diff] [blame] | 218 | auto future = mFlinger.renderScreenImpl(mDisplay, std::move(renderArea), getLayerSnapshotsFn, |
Chavi Weingarten | f5fb5b0 | 2023-11-30 17:27:52 +0000 | [diff] [blame] | 219 | mCaptureScreenBuffer, regionSampling); |
Dominik Laskowski | bb448ce | 2022-05-07 15:52:55 -0700 | [diff] [blame] | 220 | ASSERT_TRUE(future.valid()); |
| 221 | const auto fenceResult = future.get(); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 222 | |
Dominik Laskowski | bb448ce | 2022-05-07 15:52:55 -0700 | [diff] [blame] | 223 | EXPECT_EQ(NO_ERROR, fenceStatus(fenceResult)); |
| 224 | if (fenceResult.ok()) { |
| 225 | fenceResult.value()->waitForever(LOG_TAG); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 226 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 227 | |
| 228 | LayerCase::cleanup(this); |
| 229 | } |
| 230 | |
| 231 | /* ------------------------------------------------------------------------ |
| 232 | * Variants for each display configuration which can be tested |
| 233 | */ |
| 234 | |
| 235 | template <typename Derived> |
| 236 | struct BaseDisplayVariant { |
| 237 | static constexpr bool IS_SECURE = true; |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 238 | static constexpr hal::PowerMode INIT_POWER_MODE = hal::PowerMode::ON; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 239 | |
| 240 | static void setupPreconditions(CompositionTest* test) { |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 241 | EXPECT_CALL(*test->mComposer, setPowerMode(HWC_DISPLAY, Derived::INIT_POWER_MODE)) |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 242 | .WillOnce(Return(Error::NONE)); |
Alec Mouri | ba013fa | 2018-10-16 12:43:11 -0700 | [diff] [blame] | 243 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 244 | FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, hal::DisplayType::PHYSICAL, true /* isPrimary */) |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 245 | .setCapabilities(&test->mDefaultCapabilities) |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 246 | .setPowerMode(Derived::INIT_POWER_MODE) |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 247 | .inject(&test->mFlinger, test->mComposer); |
Lloyd Pique | 86fa3db | 2019-02-04 18:46:01 -0800 | [diff] [blame] | 248 | Mock::VerifyAndClear(test->mComposer); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 249 | |
Lloyd Pique | 86fa3db | 2019-02-04 18:46:01 -0800 | [diff] [blame] | 250 | EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_WIDTH, _)) |
| 251 | .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0))); |
| 252 | EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _)) |
| 253 | .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0))); |
| 254 | EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_BUFFERS_FORMAT)).Times(1); |
| 255 | EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_API_CONNECT)).Times(1); |
| 256 | EXPECT_CALL(*test->mNativeWindow, perform(NATIVE_WINDOW_SET_USAGE64)).Times(1); |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 257 | |
| 258 | const ::testing::TestInfo* const test_info = |
| 259 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 260 | |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 261 | auto ceDisplayArgs = compositionengine::DisplayCreationArgsBuilder() |
| 262 | .setId(DEFAULT_DISPLAY_ID) |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 263 | .setPixels({DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT}) |
| 264 | .setIsSecure(Derived::IS_SECURE) |
Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 265 | .setPowerAdvisor(test->mPowerAdvisor) |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 266 | .setName(std::string("Injected display for ") + |
| 267 | test_info->test_case_name() + "." + test_info->name()) |
| 268 | .build(); |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 269 | |
| 270 | auto compositionDisplay = |
| 271 | compositionengine::impl::createDisplay(test->mFlinger.getCompositionEngine(), |
| 272 | ceDisplayArgs); |
| 273 | |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 274 | constexpr auto kDisplayConnectionType = ui::DisplayConnectionType::Internal; |
| 275 | constexpr bool kIsPrimary = true; |
| 276 | |
Leon Scroggins III | ba9323a | 2023-02-22 10:40:20 -0500 | [diff] [blame] | 277 | test->mDisplay = |
| 278 | FakeDisplayDeviceInjector(test->mFlinger, compositionDisplay, |
| 279 | kDisplayConnectionType, HWC_DISPLAY, kIsPrimary) |
| 280 | .setDisplaySurface(test->mDisplaySurface) |
| 281 | .setNativeWindow(test->mNativeWindow) |
| 282 | .setSecure(Derived::IS_SECURE) |
| 283 | .setPowerMode(Derived::INIT_POWER_MODE) |
| 284 | .setRefreshRateSelector(test->mFlinger.scheduler()->refreshRateSelector()) |
Dominik Laskowski | 6e46515 | 2022-09-28 11:00:25 -0400 | [diff] [blame] | 285 | .skipSchedulerRegistration() |
Leon Scroggins III | ba9323a | 2023-02-22 10:40:20 -0500 | [diff] [blame] | 286 | .inject(); |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 287 | Mock::VerifyAndClear(test->mNativeWindow.get()); |
Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 288 | |
| 289 | constexpr bool kIsInternal = kDisplayConnectionType == ui::DisplayConnectionType::Internal; |
| 290 | test->mDisplay->setLayerFilter({LAYER_STACK, kIsInternal}); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | template <typename Case> |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 294 | static void setupPreconditionCallExpectations(CompositionTest* test) { |
| 295 | EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _)) |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 296 | .WillOnce(DoAll(SetArgPointee<1>( |
| 297 | std::vector<aidl::android::hardware::graphics::composer3:: |
| 298 | DisplayCapability>({})), |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 299 | Return(Error::NONE))); |
| 300 | } |
| 301 | |
| 302 | template <typename Case> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 303 | static void setupCommonCompositionCallExpectations(CompositionTest* test) { |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 304 | EXPECT_CALL(*test->mComposer, setColorTransform(HWC_DISPLAY, IsIdentityMatrix())).Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 305 | EXPECT_CALL(*test->mComposer, getDisplayRequests(HWC_DISPLAY, _, _, _)).Times(1); |
| 306 | EXPECT_CALL(*test->mComposer, acceptDisplayChanges(HWC_DISPLAY)).Times(1); |
| 307 | EXPECT_CALL(*test->mComposer, presentDisplay(HWC_DISPLAY, _)).Times(1); |
| 308 | EXPECT_CALL(*test->mComposer, getReleaseFences(HWC_DISPLAY, _, _)).Times(1); |
| 309 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 310 | EXPECT_CALL(*test->mDisplaySurface, onFrameCommitted()).Times(1); |
Alec Mouri | f97df4d | 2023-09-06 02:10:05 +0000 | [diff] [blame] | 311 | EXPECT_CALL(*test->mDisplaySurface, advanceFrame(_)).Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 312 | |
| 313 | Case::CompositionType::setupHwcSetCallExpectations(test); |
| 314 | Case::CompositionType::setupHwcGetCallExpectations(test); |
| 315 | } |
| 316 | |
| 317 | template <typename Case> |
| 318 | static void setupCommonScreensCaptureCallExpectations(CompositionTest* test) { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 319 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 320 | .WillRepeatedly([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 321 | const std::vector<renderengine::LayerSettings>&, |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 322 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 323 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 324 | EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance); |
| 325 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 326 | displaySettings.physicalDisplay); |
| 327 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 328 | displaySettings.clip); |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 329 | return ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 330 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | static void setupNonEmptyFrameCompositionCallExpectations(CompositionTest* test) { |
| 334 | EXPECT_CALL(*test->mDisplaySurface, beginFrame(true)).Times(1); |
| 335 | } |
| 336 | |
| 337 | static void setupEmptyFrameCompositionCallExpectations(CompositionTest* test) { |
| 338 | EXPECT_CALL(*test->mDisplaySurface, beginFrame(false)).Times(1); |
| 339 | } |
| 340 | |
| 341 | static void setupHwcCompositionCallExpectations(CompositionTest* test) { |
ramindani | 4aac32c | 2023-10-30 14:13:30 -0700 | [diff] [blame] | 342 | EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _, _, _)) |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 343 | .Times(1); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 344 | |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 345 | EXPECT_CALL(*test->mDisplaySurface, |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 346 | prepareFrame(compositionengine::DisplaySurface::CompositionType::Hwc)) |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 347 | .Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 350 | static void setupHwcClientCompositionCallExpectations(CompositionTest* test) { |
ramindani | 4aac32c | 2023-10-30 14:13:30 -0700 | [diff] [blame] | 351 | EXPECT_CALL(*test->mComposer, presentOrValidateDisplay(HWC_DISPLAY, _, _, _, _, _, _)) |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 352 | .Times(1); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | static void setupHwcForcedClientCompositionCallExpectations(CompositionTest* test) { |
ramindani | 09acbb8 | 2023-11-03 09:02:38 -0700 | [diff] [blame] | 356 | EXPECT_CALL(*test->mComposer, validateDisplay(HWC_DISPLAY, _, _, _, _)).Times(1); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 359 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 360 | EXPECT_CALL(*test->mDisplaySurface, |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 361 | prepareFrame(compositionengine::DisplaySurface::CompositionType::Gpu)) |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 362 | .Times(1); |
| 363 | EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence()) |
| 364 | .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence)); |
| 365 | |
Alec Mouri | 0a9c7b8 | 2018-11-16 13:05:25 -0800 | [diff] [blame] | 366 | 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 Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 370 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 371 | .WillRepeatedly([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 372 | const std::vector<renderengine::LayerSettings>&, |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 373 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 374 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 375 | 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); |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 381 | return ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 382 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 383 | } |
| 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 Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 393 | } |
| 394 | }; |
| 395 | |
| 396 | struct DefaultDisplaySetupVariant : public BaseDisplayVariant<DefaultDisplaySetupVariant> {}; |
| 397 | |
| 398 | struct 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 Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | template <typename Case> |
| 407 | static void setupRELayerScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 408 | Case::Layer::setupInsecureREScreenshotCompositionCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 409 | } |
| 410 | }; |
| 411 | |
| 412 | struct PoweredOffDisplaySetupVariant : public BaseDisplayVariant<PoweredOffDisplaySetupVariant> { |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 413 | static constexpr hal::PowerMode INIT_POWER_MODE = hal::PowerMode::OFF; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 414 | |
| 415 | template <typename Case> |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 416 | static void setupPreconditionCallExpectations(CompositionTest*) {} |
| 417 | |
| 418 | template <typename Case> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 419 | static void setupCommonCompositionCallExpectations(CompositionTest* test) { |
| 420 | // TODO: This seems like an unnecessary call if display is powered off. |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 421 | EXPECT_CALL(*test->mComposer, setColorTransform(HWC_DISPLAY, IsIdentityMatrix())).Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 422 | |
| 423 | // TODO: This seems like an unnecessary call if display is powered off. |
| 424 | Case::CompositionType::setupHwcSetCallExpectations(test); |
| 425 | } |
| 426 | |
| 427 | static void setupHwcCompositionCallExpectations(CompositionTest*) {} |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 428 | static void setupHwcClientCompositionCallExpectations(CompositionTest*) {} |
| 429 | static void setupHwcForcedClientCompositionCallExpectations(CompositionTest*) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 430 | |
| 431 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
| 432 | // TODO: This seems like an unnecessary call if display is powered off. |
| 433 | EXPECT_CALL(*test->mDisplaySurface, getClientTargetAcquireFence()) |
| 434 | .WillRepeatedly(ReturnRef(test->mClientTargetAcquireFence)); |
| 435 | } |
| 436 | |
| 437 | template <typename Case> |
| 438 | static void setupRELayerCompositionCallExpectations(CompositionTest*) {} |
| 439 | }; |
| 440 | |
| 441 | /* ------------------------------------------------------------------------ |
| 442 | * Variants for each layer configuration which can be tested |
| 443 | */ |
| 444 | |
| 445 | template <typename LayerProperties> |
| 446 | struct BaseLayerProperties { |
| 447 | static constexpr uint32_t WIDTH = 100; |
| 448 | static constexpr uint32_t HEIGHT = 100; |
| 449 | static constexpr PixelFormat FORMAT = PIXEL_FORMAT_RGBA_8888; |
| 450 | static constexpr uint64_t USAGE = |
| 451 | GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_SW_WRITE_NEVER; |
| 452 | static constexpr android_dataspace DATASPACE = HAL_DATASPACE_UNKNOWN; |
| 453 | static constexpr uint32_t SCALING_MODE = 0; |
| 454 | static constexpr uint32_t TRANSFORM = 0; |
| 455 | static constexpr uint32_t LAYER_FLAGS = 0; |
| 456 | static constexpr float COLOR[] = {1.f, 1.f, 1.f, 1.f}; |
| 457 | static constexpr IComposerClient::BlendMode BLENDMODE = |
| 458 | IComposerClient::BlendMode::PREMULTIPLIED; |
| 459 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 460 | static void setupLatchedBuffer(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 461 | Mock::VerifyAndClear(test->mRenderEngine); |
| 462 | |
Vishnu Nair | f8a873a | 2022-06-15 17:34:34 +0000 | [diff] [blame] | 463 | const auto buffer = std::make_shared< |
| 464 | renderengine::mock::FakeExternalTexture>(LayerProperties::WIDTH, |
| 465 | LayerProperties::HEIGHT, |
| 466 | DEFAULT_TEXTURE_ID, |
| 467 | LayerProperties::FORMAT, |
| 468 | LayerProperties::USAGE | |
| 469 | GraphicBuffer::USAGE_HW_TEXTURE); |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 470 | layer.crop = FloatRect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 471 | layer.externalTexture = buffer; |
| 472 | layer.bufferData->acquireFence = Fence::NO_FENCE; |
| 473 | layer.dataspace = ui::Dataspace::UNKNOWN; |
| 474 | layer.surfaceDamageRegion = Region(Rect(LayerProperties::HEIGHT, LayerProperties::WIDTH)); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 475 | Mock::VerifyAndClear(test->mRenderEngine); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 478 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 479 | setupLatchedBuffer(test, layer); |
| 480 | } |
| 481 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 482 | static void setupHwcSetGeometryCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 483 | if (!test->mDisplayOff) { |
| 484 | // TODO: Coverage of other values |
| 485 | EXPECT_CALL(*test->mComposer, |
| 486 | setLayerBlendMode(HWC_DISPLAY, HWC_LAYER, LayerProperties::BLENDMODE)) |
| 487 | .Times(1); |
| 488 | // TODO: Coverage of other values for origin |
| 489 | EXPECT_CALL(*test->mComposer, |
| 490 | setLayerDisplayFrame(HWC_DISPLAY, HWC_LAYER, |
| 491 | IComposerClient::Rect({0, 0, LayerProperties::WIDTH, |
| 492 | LayerProperties::HEIGHT}))) |
| 493 | .Times(1); |
| 494 | EXPECT_CALL(*test->mComposer, |
| 495 | setLayerPlaneAlpha(HWC_DISPLAY, HWC_LAYER, LayerProperties::COLOR[3])) |
| 496 | .Times(1); |
| 497 | // TODO: Coverage of other values |
| 498 | EXPECT_CALL(*test->mComposer, setLayerZOrder(HWC_DISPLAY, HWC_LAYER, 0u)).Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 499 | |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 500 | // These expectations retire on saturation as the code path these |
| 501 | // expectations are for appears to make an extra call to them. |
| 502 | // TODO: Investigate this extra call |
| 503 | EXPECT_CALL(*test->mComposer, |
| 504 | setLayerTransform(HWC_DISPLAY, HWC_LAYER, DEFAULT_TRANSFORM)) |
| 505 | .Times(AtLeast(1)) |
| 506 | .RetiresOnSaturation(); |
| 507 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 511 | if (!test->mDisplayOff) { |
| 512 | EXPECT_CALL(*test->mComposer, |
| 513 | setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER, |
| 514 | IComposerClient::FRect({0.f, 0.f, LayerProperties::WIDTH, |
| 515 | LayerProperties::HEIGHT}))) |
| 516 | .Times(1); |
| 517 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | static void setupHwcSetSourceCropColorCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 521 | if (!test->mDisplayOff) { |
| 522 | EXPECT_CALL(*test->mComposer, |
| 523 | setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER, |
| 524 | IComposerClient::FRect({0.f, 0.f, 0.f, 0.f}))) |
| 525 | .Times(1); |
| 526 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | static void setupHwcSetPerFrameCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 530 | if (!test->mDisplayOff) { |
| 531 | EXPECT_CALL(*test->mComposer, |
| 532 | setLayerVisibleRegion(HWC_DISPLAY, HWC_LAYER, |
| 533 | std::vector<IComposerClient::Rect>( |
| 534 | {IComposerClient::Rect( |
| 535 | {0, 0, LayerProperties::WIDTH, |
| 536 | LayerProperties::HEIGHT})}))) |
| 537 | .Times(1); |
| 538 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | static void setupHwcSetPerFrameColorCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 542 | if (!test->mDisplayOff) { |
| 543 | EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)) |
| 544 | .Times(1); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 545 | |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 546 | // TODO: use COLOR |
| 547 | EXPECT_CALL(*test->mComposer, |
| 548 | setLayerColor(HWC_DISPLAY, HWC_LAYER, |
Ady Abraham | 6e60b14 | 2022-01-06 18:10:35 -0800 | [diff] [blame] | 549 | aidl::android::hardware::graphics::composer3::Color( |
| 550 | {1.0f, 1.0f, 1.0f, 1.0f}))) |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 551 | .Times(1); |
| 552 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 556 | if (!test->mDisplayOff) { |
| 557 | EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)) |
| 558 | .Times(1); |
| 559 | EXPECT_CALL(*test->mComposer, setLayerBuffer(HWC_DISPLAY, HWC_LAYER, _, _, _)).Times(1); |
| 560 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | static void setupREBufferCompositionCommonCallExpectations(CompositionTest* test) { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 564 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 565 | .WillOnce([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 566 | const std::vector<renderengine::LayerSettings>& layerSettings, |
Alec Mouri | f29700f | 2023-08-17 21:53:31 +0000 | [diff] [blame] | 567 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 568 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 569 | EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance); |
| 570 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 571 | displaySettings.physicalDisplay); |
| 572 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 573 | displaySettings.clip); |
| 574 | // screen capture adds an additional color layer as an alpha |
| 575 | // prefill, so gtet the back layer. |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 576 | ftl::Future<FenceResult> resultFuture = |
| 577 | ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 578 | if (layerSettings.empty()) { |
| 579 | ADD_FAILURE() << "layerSettings was not expected to be empty in " |
| 580 | "setupREBufferCompositionCommonCallExpectations " |
| 581 | "verification lambda"; |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 582 | return resultFuture; |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 583 | } |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 584 | const renderengine::LayerSettings layer = layerSettings.back(); |
| 585 | EXPECT_THAT(layer.source.buffer.buffer, Not(IsNull())); |
| 586 | EXPECT_THAT(layer.source.buffer.fence, Not(IsNull())); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 587 | EXPECT_EQ(true, layer.source.buffer.usePremultipliedAlpha); |
| 588 | EXPECT_EQ(false, layer.source.buffer.isOpaque); |
Vishnu Nair | 50c0afe | 2022-07-11 15:04:07 -0700 | [diff] [blame] | 589 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.x); |
| 590 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.y); |
Alec Mouri | 74c7ae1 | 2023-03-26 02:57:47 +0000 | [diff] [blame] | 591 | EXPECT_EQ(ui::Dataspace::V0_SRGB, layer.sourceDataspace); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 592 | EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha); |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 593 | return resultFuture; |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 594 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | static void setupREBufferCompositionCallExpectations(CompositionTest* test) { |
| 598 | LayerProperties::setupREBufferCompositionCommonCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) { |
| 602 | setupREBufferCompositionCallExpectations(test); |
| 603 | } |
| 604 | |
| 605 | static void setupREBufferScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 606 | LayerProperties::setupREBufferCompositionCommonCallExpectations(test); |
| 607 | } |
| 608 | |
| 609 | static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 610 | LayerProperties::setupREBufferCompositionCommonCallExpectations(test); |
| 611 | } |
| 612 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 613 | static void setupREColorCompositionCallExpectations(CompositionTest* test) { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 614 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 615 | .WillOnce([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 616 | const std::vector<renderengine::LayerSettings>& layerSettings, |
Alec Mouri | f29700f | 2023-08-17 21:53:31 +0000 | [diff] [blame] | 617 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 618 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 619 | EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance); |
| 620 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 621 | displaySettings.physicalDisplay); |
| 622 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 623 | displaySettings.clip); |
| 624 | // screen capture adds an additional color layer as an alpha |
| 625 | // prefill, so get the back layer. |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 626 | ftl::Future<FenceResult> resultFuture = |
| 627 | ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 628 | if (layerSettings.empty()) { |
| 629 | ADD_FAILURE() |
| 630 | << "layerSettings was not expected to be empty in " |
| 631 | "setupREColorCompositionCallExpectations verification lambda"; |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 632 | return resultFuture; |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 633 | } |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 634 | const renderengine::LayerSettings layer = layerSettings.back(); |
| 635 | EXPECT_THAT(layer.source.buffer.buffer, IsNull()); |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 636 | EXPECT_EQ(half3(LayerProperties::COLOR[0], LayerProperties::COLOR[1], |
| 637 | LayerProperties::COLOR[2]), |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 638 | layer.source.solidColor); |
Vishnu Nair | 50c0afe | 2022-07-11 15:04:07 -0700 | [diff] [blame] | 639 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.x); |
| 640 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.y); |
Alec Mouri | 74c7ae1 | 2023-03-26 02:57:47 +0000 | [diff] [blame] | 641 | EXPECT_EQ(ui::Dataspace::V0_SRGB, layer.sourceDataspace); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 642 | EXPECT_EQ(LayerProperties::COLOR[3], layer.alpha); |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 643 | return resultFuture; |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 644 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | static void setupREColorScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 648 | setupREColorCompositionCallExpectations(test); |
| 649 | } |
| 650 | }; |
| 651 | |
| 652 | struct DefaultLayerProperties : public BaseLayerProperties<DefaultLayerProperties> {}; |
| 653 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 654 | struct EffectLayerProperties : public BaseLayerProperties<EffectLayerProperties> { |
Alec Mouri | da8a9d1 | 2020-01-30 20:00:31 -0800 | [diff] [blame] | 655 | static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE; |
| 656 | }; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 657 | |
| 658 | struct SidebandLayerProperties : public BaseLayerProperties<SidebandLayerProperties> { |
| 659 | using Base = BaseLayerProperties<SidebandLayerProperties>; |
| 660 | static constexpr IComposerClient::BlendMode BLENDMODE = IComposerClient::BlendMode::NONE; |
| 661 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 662 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 663 | sp<NativeHandle> stream = |
| 664 | NativeHandle::create(reinterpret_cast<native_handle_t*>(DEFAULT_SIDEBAND_STREAM), |
| 665 | false); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 666 | layer.sidebandStream = stream; |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 667 | layer.crop = |
| 668 | FloatRect(0, 0, SidebandLayerProperties::HEIGHT, SidebandLayerProperties::WIDTH); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) { |
| 672 | EXPECT_CALL(*test->mComposer, |
| 673 | setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER, |
| 674 | IComposerClient::FRect({0.f, 0.f, -1.f, -1.f}))) |
| 675 | .Times(1); |
| 676 | } |
| 677 | |
| 678 | static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) { |
| 679 | EXPECT_CALL(*test->mComposer, |
| 680 | setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER, |
| 681 | reinterpret_cast<native_handle_t*>( |
| 682 | DEFAULT_SIDEBAND_STREAM))) |
| 683 | .WillOnce(Return(Error::NONE)); |
| 684 | |
| 685 | EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1); |
| 686 | } |
| 687 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 688 | static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 689 | }; |
| 690 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 691 | template <typename LayerProperties> |
| 692 | struct CommonSecureLayerProperties : public BaseLayerProperties<LayerProperties> { |
| 693 | using Base = BaseLayerProperties<LayerProperties>; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 694 | |
| 695 | static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 696 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 697 | .WillOnce([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 698 | const std::vector<renderengine::LayerSettings>& layerSettings, |
Alec Mouri | f29700f | 2023-08-17 21:53:31 +0000 | [diff] [blame] | 699 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 700 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 701 | EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance); |
| 702 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 703 | displaySettings.physicalDisplay); |
| 704 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 705 | displaySettings.clip); |
| 706 | // screen capture adds an additional color layer as an alpha |
| 707 | // prefill, so get the back layer. |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 708 | ftl::Future<FenceResult> resultFuture = |
| 709 | ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 710 | if (layerSettings.empty()) { |
| 711 | ADD_FAILURE() << "layerSettings was not expected to be empty in " |
| 712 | "setupInsecureREBufferCompositionCommonCallExpectations " |
| 713 | "verification lambda"; |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 714 | return resultFuture; |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 715 | } |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 716 | const renderengine::LayerSettings layer = layerSettings.back(); |
| 717 | EXPECT_THAT(layer.source.buffer.buffer, IsNull()); |
| 718 | EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor); |
Vishnu Nair | 50c0afe | 2022-07-11 15:04:07 -0700 | [diff] [blame] | 719 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.x); |
| 720 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.y); |
Alec Mouri | 74c7ae1 | 2023-03-26 02:57:47 +0000 | [diff] [blame] | 721 | EXPECT_EQ(ui::Dataspace::V0_SRGB, layer.sourceDataspace); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 722 | EXPECT_EQ(1.0f, layer.alpha); |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 723 | return resultFuture; |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 724 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) { |
| 728 | setupInsecureREBufferCompositionCommonCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 732 | setupInsecureREBufferCompositionCommonCallExpectations(test); |
| 733 | } |
| 734 | }; |
| 735 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 736 | struct ParentSecureLayerProperties |
| 737 | : public CommonSecureLayerProperties<ParentSecureLayerProperties> {}; |
| 738 | |
| 739 | struct SecureLayerProperties : public CommonSecureLayerProperties<SecureLayerProperties> { |
| 740 | static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure; |
| 741 | }; |
| 742 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 743 | struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> { |
| 744 | using Base = BaseLayerProperties<CursorLayerProperties>; |
| 745 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 746 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 747 | Base::setupLayerState(test, layer); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 748 | layer.potentialCursor = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 749 | } |
| 750 | }; |
| 751 | |
| 752 | struct NoLayerVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 753 | static frontend::RequestedLayerState createLayer(CompositionTest*) { |
| 754 | return {LayerCreationArgs()}; |
| 755 | } |
| 756 | static void injectLayer(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 757 | static void cleanupInjectedLayers(CompositionTest*) {} |
| 758 | |
| 759 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 760 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 761 | }; |
| 762 | |
| 763 | template <typename LayerProperties> |
| 764 | struct BaseLayerVariant { |
| 765 | template <typename L, typename F> |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 766 | static frontend::RequestedLayerState createLayerWithFactory(CompositionTest* test, F factory) { |
Dominik Laskowski | 756b789 | 2021-08-04 12:53:59 -0700 | [diff] [blame] | 767 | EXPECT_CALL(*test->mFlinger.scheduler(), postMessage(_)).Times(0); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 768 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 769 | auto layer = factory(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 770 | |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 771 | // Layer should be registered with scheduler. |
Dominik Laskowski | 9c93d60 | 2021-10-07 19:38:26 -0700 | [diff] [blame] | 772 | EXPECT_EQ(1u, test->mFlinger.scheduler()->layerHistorySize()); |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 773 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 774 | Mock::VerifyAndClear(test->mComposer); |
| 775 | Mock::VerifyAndClear(test->mRenderEngine); |
Dominik Laskowski | 756b789 | 2021-08-04 12:53:59 -0700 | [diff] [blame] | 776 | Mock::VerifyAndClearExpectations(test->mFlinger.scheduler()); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 777 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 778 | initLayerDrawingStateAndComputeBounds(test, layer); |
| 779 | |
| 780 | return layer; |
| 781 | } |
| 782 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 783 | static void initLayerDrawingStateAndComputeBounds(CompositionTest* test, |
| 784 | frontend::RequestedLayerState& layer) { |
| 785 | layer.layerStack = LAYER_STACK; |
| 786 | layer.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1], |
| 787 | LayerProperties::COLOR[2], LayerProperties::COLOR[3]); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 788 | } |
| 789 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 790 | static void injectLayer(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 791 | EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _)) |
| 792 | .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE))); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 793 | auto legacyLayer = test->mFlinger.getLegacyLayer(layer.id); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 794 | auto outputLayer = test->mDisplay->getCompositionDisplay()->injectOutputLayerForTest( |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 795 | legacyLayer->getCompositionEngineLayerFE({.id = layer.id})); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 796 | outputLayer->editState().visibleRegion = Region(Rect(0, 0, 100, 100)); |
| 797 | outputLayer->editState().outputSpaceVisibleRegion = Region(Rect(0, 0, 100, 100)); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 798 | |
| 799 | Mock::VerifyAndClear(test->mComposer); |
| 800 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 801 | auto layerCopy = std::make_unique<frontend::RequestedLayerState>(layer); |
| 802 | test->mFlinger.addLayer(layerCopy); |
Vishnu Nair | 802ac4f | 2023-05-10 13:55:22 -0700 | [diff] [blame] | 803 | test->mFlinger.mutableVisibleRegionsDirty() = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | static void cleanupInjectedLayers(CompositionTest* test) { |
| 807 | EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER)) |
| 808 | .WillOnce(Return(Error::NONE)); |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 809 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 810 | test->mFlinger.destroyAllLayerHandles(); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 811 | test->mDisplay->getCompositionDisplay()->clearOutputLayers(); |
Vishnu Nair | 802ac4f | 2023-05-10 13:55:22 -0700 | [diff] [blame] | 812 | test->mFlinger.mutablePreviouslyComposedLayers().clear(); |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 813 | // Layer should be unregistered with scheduler. |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 814 | test->mFlinger.commit(); |
Dominik Laskowski | 9c93d60 | 2021-10-07 19:38:26 -0700 | [diff] [blame] | 815 | EXPECT_EQ(0u, test->mFlinger.scheduler()->layerHistorySize()); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 816 | } |
| 817 | }; |
| 818 | |
| 819 | template <typename LayerProperties> |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 820 | struct EffectLayerVariant : public BaseLayerVariant<LayerProperties> { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 821 | using Base = BaseLayerVariant<LayerProperties>; |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 822 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
| 823 | frontend::RequestedLayerState layer = Base::template createLayerWithFactory< |
| 824 | frontend::RequestedLayerState>(test, [test]() { |
| 825 | auto args = LayerCreationArgs(test->mFlinger.flinger(), sp<Client>(), "test-layer", |
| 826 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
| 827 | auto legacyLayer = sp<Layer>::make(args); |
| 828 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 829 | return frontend::RequestedLayerState(args); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 830 | }); |
Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 831 | |
Vishnu Nair | a9123c8 | 2024-10-03 03:56:44 +0000 | [diff] [blame] | 832 | layer.crop = FloatRect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 833 | return layer; |
| 834 | } |
| 835 | |
| 836 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 837 | LayerProperties::setupREColorCompositionCallExpectations(test); |
| 838 | } |
| 839 | |
| 840 | static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 841 | LayerProperties::setupREColorScreenshotCompositionCallExpectations(test); |
| 842 | } |
| 843 | |
| 844 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 845 | LayerProperties::setupHwcSetGeometryCallExpectations(test); |
| 846 | LayerProperties::setupHwcSetSourceCropColorCallExpectations(test); |
| 847 | } |
| 848 | |
| 849 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 850 | LayerProperties::setupHwcSetPerFrameCallExpectations(test); |
| 851 | LayerProperties::setupHwcSetPerFrameColorCallExpectations(test); |
| 852 | } |
| 853 | }; |
| 854 | |
| 855 | template <typename LayerProperties> |
| 856 | struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> { |
| 857 | using Base = BaseLayerVariant<LayerProperties>; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 858 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 859 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
| 860 | frontend::RequestedLayerState layer = Base::template createLayerWithFactory< |
| 861 | frontend::RequestedLayerState>(test, [test]() { |
Alec Mouri | c3a1782 | 2023-08-16 14:56:30 +0000 | [diff] [blame] | 862 | LayerCreationArgs args(test->mFlinger.flinger(), sp<Client>(), "test-layer", |
| 863 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 864 | auto legacyLayer = sp<Layer>::make(args); |
| 865 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 866 | return frontend::RequestedLayerState(args); |
Alec Mouri | c3a1782 | 2023-08-16 14:56:30 +0000 | [diff] [blame] | 867 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 868 | |
| 869 | LayerProperties::setupLayerState(test, layer); |
| 870 | |
| 871 | return layer; |
| 872 | } |
| 873 | |
| 874 | static void cleanupInjectedLayers(CompositionTest* test) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 875 | Base::cleanupInjectedLayers(test); |
| 876 | } |
| 877 | |
| 878 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 879 | LayerProperties::setupHwcSetGeometryCallExpectations(test); |
| 880 | LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test); |
| 881 | } |
| 882 | |
| 883 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 884 | LayerProperties::setupHwcSetPerFrameCallExpectations(test); |
| 885 | LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test); |
| 886 | } |
| 887 | |
| 888 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
| 889 | LayerProperties::setupREBufferCompositionCallExpectations(test); |
| 890 | } |
| 891 | |
| 892 | static void setupInsecureRECompositionCallExpectations(CompositionTest* test) { |
| 893 | LayerProperties::setupInsecureREBufferCompositionCallExpectations(test); |
| 894 | } |
| 895 | |
| 896 | static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 897 | LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test); |
| 898 | } |
| 899 | |
| 900 | static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 901 | LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test); |
| 902 | } |
| 903 | }; |
| 904 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 905 | template <typename LayerProperties> |
| 906 | struct ContainerLayerVariant : public BaseLayerVariant<LayerProperties> { |
| 907 | using Base = BaseLayerVariant<LayerProperties>; |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 908 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 909 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 910 | LayerCreationArgs args(test->mFlinger.flinger(), sp<Client>(), "test-container-layer", |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 911 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 912 | sp<Layer> legacyLayer = sp<Layer>::make(args); |
| 913 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 914 | frontend::RequestedLayerState layer(args); |
| 915 | Base::initLayerDrawingStateAndComputeBounds(test, layer); |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 916 | return layer; |
| 917 | } |
| 918 | }; |
| 919 | |
| 920 | template <typename LayerVariant, typename ParentLayerVariant> |
| 921 | struct ChildLayerVariant : public LayerVariant { |
| 922 | using Base = LayerVariant; |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 923 | using ParentBase = ParentLayerVariant; |
| 924 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 925 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 926 | // Need to create child layer first. Otherwise layer history size will be 2. |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 927 | frontend::RequestedLayerState layer = Base::createLayer(test); |
| 928 | frontend::RequestedLayerState parentLayer = ParentBase::createLayer(test); |
| 929 | layer.parentId = parentLayer.id; |
| 930 | auto layerCopy = std::make_unique<frontend::RequestedLayerState>(parentLayer); |
| 931 | test->mFlinger.addLayer(layerCopy); |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 932 | return layer; |
| 933 | } |
| 934 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 935 | static void cleanupInjectedLayers(CompositionTest* test) { Base::cleanupInjectedLayers(test); } |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 936 | }; |
| 937 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 938 | /* ------------------------------------------------------------------------ |
| 939 | * Variants to control how the composition type is changed |
| 940 | */ |
| 941 | |
| 942 | struct NoCompositionTypeVariant { |
| 943 | static void setupHwcSetCallExpectations(CompositionTest*) {} |
| 944 | |
| 945 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 946 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1); |
| 947 | } |
| 948 | }; |
| 949 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 950 | template <aidl::android::hardware::graphics::composer3::Composition CompositionType> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 951 | struct KeepCompositionTypeVariant { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 952 | static constexpr aidl::android::hardware::graphics::composer3::Composition TYPE = |
| 953 | CompositionType; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 954 | |
| 955 | static void setupHwcSetCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 956 | if (!test->mDisplayOff) { |
| 957 | EXPECT_CALL(*test->mComposer, |
| 958 | setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType)) |
| 959 | .Times(1); |
| 960 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 964 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1); |
| 965 | } |
| 966 | }; |
| 967 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 968 | template <aidl::android::hardware::graphics::composer3::Composition InitialCompositionType, |
| 969 | aidl::android::hardware::graphics::composer3::Composition FinalCompositionType> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 970 | struct ChangeCompositionTypeVariant { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 971 | static constexpr aidl::android::hardware::graphics::composer3::Composition TYPE = |
| 972 | FinalCompositionType; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 973 | |
| 974 | static void setupHwcSetCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 975 | if (!test->mDisplayOff) { |
| 976 | EXPECT_CALL(*test->mComposer, |
| 977 | setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType)) |
| 978 | .Times(1); |
| 979 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 983 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)) |
| 984 | .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{ |
| 985 | static_cast<Hwc2::Layer>(HWC_LAYER)}), |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 986 | SetArgPointee<2>( |
| 987 | std::vector<aidl::android::hardware::graphics::composer3:: |
| 988 | Composition>{FinalCompositionType}), |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 989 | Return(Error::NONE))); |
| 990 | } |
| 991 | }; |
| 992 | |
| 993 | /* ------------------------------------------------------------------------ |
| 994 | * Variants to select how the composition is expected to be handled |
| 995 | */ |
| 996 | |
| 997 | struct CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 998 | static void setupLayerState(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 999 | |
| 1000 | template <typename Case> |
| 1001 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 1002 | Case::Layer::setupCallExpectationsForDirtyGeometry(test); |
| 1003 | } |
| 1004 | |
| 1005 | template <typename Case> |
| 1006 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 1007 | Case::Layer::setupCallExpectationsForDirtyFrame(test); |
| 1008 | } |
| 1009 | }; |
| 1010 | |
| 1011 | struct NoCompositionResultVariant : public CompositionResultBaseVariant { |
| 1012 | template <typename Case> |
| 1013 | static void setupCallExpectations(CompositionTest* test) { |
| 1014 | Case::Display::setupEmptyFrameCompositionCallExpectations(test); |
| 1015 | Case::Display::setupHwcCompositionCallExpectations(test); |
| 1016 | } |
| 1017 | }; |
| 1018 | |
| 1019 | struct HwcCompositionResultVariant : public CompositionResultBaseVariant { |
| 1020 | template <typename Case> |
| 1021 | static void setupCallExpectations(CompositionTest* test) { |
| 1022 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1023 | Case::Display::setupHwcCompositionCallExpectations(test); |
| 1024 | } |
| 1025 | }; |
| 1026 | |
| 1027 | struct RECompositionResultVariant : public CompositionResultBaseVariant { |
| 1028 | template <typename Case> |
| 1029 | static void setupCallExpectations(CompositionTest* test) { |
| 1030 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1031 | Case::Display::setupHwcClientCompositionCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1032 | Case::Display::setupRECompositionCallExpectations(test); |
| 1033 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1034 | } |
| 1035 | }; |
| 1036 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1037 | struct ForcedClientCompositionResultVariant : public CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1038 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
| 1039 | const auto outputLayer = test->mFlinger.findOutputLayerForDisplay(layer.id, test->mDisplay); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 1040 | LOG_FATAL_IF(!outputLayer); |
| 1041 | outputLayer->editState().forceClientComposition = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | template <typename Case> |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1045 | static void setupCallExpectations(CompositionTest* test) { |
| 1046 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1047 | Case::Display::setupHwcForcedClientCompositionCallExpectations(test); |
| 1048 | Case::Display::setupRECompositionCallExpectations(test); |
| 1049 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1050 | } |
| 1051 | |
| 1052 | template <typename Case> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1053 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 1054 | |
| 1055 | template <typename Case> |
| 1056 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 1057 | }; |
| 1058 | |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1059 | struct ForcedClientCompositionViaDebugOptionResultVariant : public CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1060 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState&) { |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1061 | test->mFlinger.mutableDebugDisableHWC() = true; |
| 1062 | } |
| 1063 | |
| 1064 | template <typename Case> |
| 1065 | static void setupCallExpectations(CompositionTest* test) { |
| 1066 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1067 | Case::Display::setupHwcForcedClientCompositionCallExpectations(test); |
| 1068 | Case::Display::setupRECompositionCallExpectations(test); |
| 1069 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1070 | } |
| 1071 | |
| 1072 | template <typename Case> |
| 1073 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 1074 | |
| 1075 | template <typename Case> |
| 1076 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 1077 | }; |
| 1078 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1079 | struct EmptyScreenshotResultVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1080 | static void setupLayerState(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1081 | |
| 1082 | template <typename Case> |
| 1083 | static void setupCallExpectations(CompositionTest*) {} |
| 1084 | }; |
| 1085 | |
| 1086 | struct REScreenshotResultVariant : public EmptyScreenshotResultVariant { |
| 1087 | using Base = EmptyScreenshotResultVariant; |
| 1088 | |
| 1089 | template <typename Case> |
| 1090 | static void setupCallExpectations(CompositionTest* test) { |
| 1091 | Base::template setupCallExpectations<Case>(test); |
| 1092 | Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test); |
| 1093 | } |
| 1094 | }; |
| 1095 | |
| 1096 | /* ------------------------------------------------------------------------ |
| 1097 | * Composition test case, containing all the variants being tested |
| 1098 | */ |
| 1099 | |
| 1100 | template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase, |
| 1101 | typename CompositionResultCase> |
| 1102 | struct CompositionCase { |
| 1103 | using ThisCase = |
| 1104 | CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>; |
| 1105 | using Display = DisplayCase; |
| 1106 | using Layer = LayerCase; |
| 1107 | using CompositionType = CompositionTypeCase; |
| 1108 | using CompositionResult = CompositionResultCase; |
| 1109 | |
| 1110 | static void setupCommon(CompositionTest* test) { |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 1111 | Display::template setupPreconditionCallExpectations<ThisCase>(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1112 | Display::setupPreconditions(test); |
| 1113 | |
| 1114 | auto layer = Layer::createLayer(test); |
| 1115 | Layer::injectLayer(test, layer); |
| 1116 | CompositionResult::setupLayerState(test, layer); |
| 1117 | } |
| 1118 | |
| 1119 | static void setupForDirtyGeometry(CompositionTest* test) { |
| 1120 | setupCommon(test); |
| 1121 | |
| 1122 | Display::template setupCommonCompositionCallExpectations<ThisCase>(test); |
| 1123 | CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test); |
| 1124 | CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test); |
| 1125 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1126 | } |
| 1127 | |
| 1128 | static void setupForDirtyFrame(CompositionTest* test) { |
| 1129 | setupCommon(test); |
| 1130 | |
| 1131 | Display::template setupCommonCompositionCallExpectations<ThisCase>(test); |
| 1132 | CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test); |
| 1133 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1134 | } |
| 1135 | |
| 1136 | static void setupForScreenCapture(CompositionTest* test) { |
| 1137 | setupCommon(test); |
| 1138 | |
| 1139 | Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test); |
| 1140 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1141 | } |
| 1142 | |
| 1143 | static void cleanup(CompositionTest* test) { |
| 1144 | Layer::cleanupInjectedLayers(test); |
| 1145 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1146 | for (auto& displayData : test->mFlinger.mutableHwcDisplayData()) { |
| 1147 | static_cast<TestableSurfaceFlinger::HWC2Display*>(displayData.second.hwcDisplay.get()) |
| 1148 | ->mutableLayers() |
| 1149 | .clear(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1150 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1151 | } |
| 1152 | }; |
| 1153 | |
| 1154 | /* ------------------------------------------------------------------------ |
| 1155 | * Composition cases to test |
| 1156 | */ |
| 1157 | |
| 1158 | TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) { |
| 1159 | displayRefreshCompositionDirtyGeometry< |
| 1160 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1161 | NoCompositionResultVariant>>(); |
| 1162 | } |
| 1163 | |
| 1164 | TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) { |
| 1165 | displayRefreshCompositionDirtyFrame< |
| 1166 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1167 | NoCompositionResultVariant>>(); |
| 1168 | } |
| 1169 | |
| 1170 | TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) { |
| 1171 | captureScreenComposition< |
| 1172 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1173 | EmptyScreenshotResultVariant>>(); |
| 1174 | } |
| 1175 | |
| 1176 | /* ------------------------------------------------------------------------ |
| 1177 | * Simple buffer layers |
| 1178 | */ |
| 1179 | |
| 1180 | TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1181 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1182 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1183 | KeepCompositionTypeVariant< |
| 1184 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1185 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1189 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1190 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1191 | KeepCompositionTypeVariant< |
| 1192 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1193 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | TEST_F(CompositionTest, REComposedNormalBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1197 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1198 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1199 | ChangeCompositionTypeVariant< |
| 1200 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1201 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1202 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | TEST_F(CompositionTest, captureScreenNormalBufferLayer) { |
| 1206 | captureScreenComposition< |
| 1207 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1208 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1209 | } |
| 1210 | |
| 1211 | /* ------------------------------------------------------------------------ |
| 1212 | * Single-color layers |
| 1213 | */ |
| 1214 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1215 | TEST_F(CompositionTest, HWCComposedEffectLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1216 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1217 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1218 | KeepCompositionTypeVariant< |
| 1219 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR>, |
| 1220 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1221 | } |
| 1222 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1223 | TEST_F(CompositionTest, HWCComposedEffectLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1224 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1225 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1226 | KeepCompositionTypeVariant< |
| 1227 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR>, |
| 1228 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1229 | } |
| 1230 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1231 | TEST_F(CompositionTest, REComposedEffectLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1232 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1233 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1234 | ChangeCompositionTypeVariant< |
| 1235 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR, |
| 1236 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1237 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1238 | } |
| 1239 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1240 | TEST_F(CompositionTest, captureScreenEffectLayer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1241 | captureScreenComposition< |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1242 | CompositionCase<DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1243 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1244 | } |
| 1245 | |
| 1246 | /* ------------------------------------------------------------------------ |
| 1247 | * Layers with sideband buffers |
| 1248 | */ |
| 1249 | |
| 1250 | TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1251 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1252 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1253 | KeepCompositionTypeVariant< |
| 1254 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND>, |
| 1255 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
| 1258 | TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1259 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1260 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1261 | KeepCompositionTypeVariant< |
| 1262 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND>, |
| 1263 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | TEST_F(CompositionTest, REComposedSidebandBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1267 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1268 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1269 | ChangeCompositionTypeVariant< |
| 1270 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND, |
| 1271 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1272 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | TEST_F(CompositionTest, captureScreenSidebandBufferLayer) { |
| 1276 | captureScreenComposition< |
| 1277 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1278 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1279 | } |
| 1280 | |
| 1281 | /* ------------------------------------------------------------------------ |
| 1282 | * Layers with ISurfaceComposerClient::eSecure, on a secure display |
| 1283 | */ |
| 1284 | |
| 1285 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1286 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1287 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1288 | KeepCompositionTypeVariant< |
| 1289 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1290 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1291 | } |
| 1292 | |
| 1293 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1294 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1295 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1296 | KeepCompositionTypeVariant< |
| 1297 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1298 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | TEST_F(CompositionTest, REComposedSecureBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1302 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1303 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1304 | ChangeCompositionTypeVariant< |
| 1305 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1306 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1307 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) { |
| 1311 | captureScreenComposition< |
| 1312 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1313 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1314 | } |
| 1315 | |
| 1316 | /* ------------------------------------------------------------------------ |
| 1317 | * Layers with ISurfaceComposerClient::eSecure, on a non-secure display |
| 1318 | */ |
| 1319 | |
| 1320 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1321 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1322 | InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1323 | KeepCompositionTypeVariant< |
| 1324 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1325 | ForcedClientCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1326 | } |
| 1327 | |
| 1328 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1329 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1330 | InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1331 | KeepCompositionTypeVariant< |
| 1332 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1333 | ForcedClientCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1334 | } |
| 1335 | |
| 1336 | TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) { |
| 1337 | captureScreenComposition< |
| 1338 | CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1339 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1340 | } |
| 1341 | |
| 1342 | /* ------------------------------------------------------------------------ |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 1343 | * Layers with a parent layer with ISurfaceComposerClient::eSecure, on a non-secure display |
| 1344 | */ |
| 1345 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 1346 | TEST_F(CompositionTest, captureScreenBufferLayerWithSecureParentLayerOnInsecureDisplay) { |
| 1347 | captureScreenComposition< |
| 1348 | CompositionCase<InsecureDisplaySetupVariant, |
| 1349 | ChildLayerVariant<BufferLayerVariant<ParentSecureLayerProperties>, |
| 1350 | ContainerLayerVariant<SecureLayerProperties>>, |
| 1351 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1352 | } |
| 1353 | |
| 1354 | /* ------------------------------------------------------------------------ |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1355 | * Cursor layers |
| 1356 | */ |
| 1357 | |
| 1358 | TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1359 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1360 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1361 | KeepCompositionTypeVariant< |
| 1362 | aidl::android::hardware::graphics::composer3::Composition::CURSOR>, |
| 1363 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1364 | } |
| 1365 | |
| 1366 | TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1367 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1368 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1369 | KeepCompositionTypeVariant< |
| 1370 | aidl::android::hardware::graphics::composer3::Composition::CURSOR>, |
| 1371 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1372 | } |
| 1373 | |
| 1374 | TEST_F(CompositionTest, REComposedCursorLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1375 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1376 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1377 | ChangeCompositionTypeVariant< |
| 1378 | aidl::android::hardware::graphics::composer3::Composition::CURSOR, |
| 1379 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1380 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | TEST_F(CompositionTest, captureScreenCursorLayer) { |
| 1384 | captureScreenComposition< |
| 1385 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1386 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1387 | } |
| 1388 | |
| 1389 | /* ------------------------------------------------------------------------ |
| 1390 | * Simple buffer layer on a display which is powered off. |
| 1391 | */ |
| 1392 | |
| 1393 | TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1394 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1395 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1396 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1397 | KeepCompositionTypeVariant< |
| 1398 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1399 | HwcCompositionResultVariant>>(); |
| 1400 | } |
| 1401 | |
| 1402 | TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1403 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1404 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1405 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1406 | KeepCompositionTypeVariant< |
| 1407 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1408 | HwcCompositionResultVariant>>(); |
| 1409 | } |
| 1410 | |
| 1411 | TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1412 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1413 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1414 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1415 | ChangeCompositionTypeVariant< |
| 1416 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1417 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1418 | RECompositionResultVariant>>(); |
| 1419 | } |
| 1420 | |
| 1421 | TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) { |
| 1422 | captureScreenComposition<CompositionCase< |
| 1423 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1424 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1425 | } |
| 1426 | |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1427 | /* ------------------------------------------------------------------------ |
| 1428 | * Client composition forced through debug/developer settings |
| 1429 | */ |
| 1430 | |
| 1431 | TEST_F(CompositionTest, DebugOptionForcingClientCompositionOfBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1432 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1433 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1434 | KeepCompositionTypeVariant< |
| 1435 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1436 | ForcedClientCompositionViaDebugOptionResultVariant>>(); |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1437 | } |
| 1438 | |
| 1439 | TEST_F(CompositionTest, DebugOptionForcingClientCompositionOfBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1440 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1441 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1442 | KeepCompositionTypeVariant< |
| 1443 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1444 | ForcedClientCompositionViaDebugOptionResultVariant>>(); |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1445 | } |
| 1446 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1447 | } // namespace |
| 1448 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 1449 | |
| 1450 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 1451 | #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" |