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 | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 43 | #include "mock/DisplayHardware/MockPowerAdvisor.h" |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 44 | #include "mock/MockEventThread.h" |
Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 45 | #include "mock/MockTimeStats.h" |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 46 | #include "mock/MockVsyncController.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(); |
Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 113 | mPowerAdvisor = new Hwc2::mock::PowerAdvisor(); |
Dominik Laskowski | 3dce4f4 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 114 | mFlinger.setupComposer(std::unique_ptr<Hwc2::Composer>(mComposer)); |
Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 115 | mFlinger.setupPowerAdvisor(std::unique_ptr<Hwc2::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(); |
Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 161 | Hwc2::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 | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 470 | layer.crop = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH); |
| 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; |
| 667 | layer.crop = Rect(0, 0, SidebandLayerProperties::HEIGHT, SidebandLayerProperties::WIDTH); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | static void setupHwcSetSourceCropBufferCallExpectations(CompositionTest* test) { |
| 671 | EXPECT_CALL(*test->mComposer, |
| 672 | setLayerSourceCrop(HWC_DISPLAY, HWC_LAYER, |
| 673 | IComposerClient::FRect({0.f, 0.f, -1.f, -1.f}))) |
| 674 | .Times(1); |
| 675 | } |
| 676 | |
| 677 | static void setupHwcSetPerFrameBufferCallExpectations(CompositionTest* test) { |
| 678 | EXPECT_CALL(*test->mComposer, |
| 679 | setLayerSidebandStream(HWC_DISPLAY, HWC_LAYER, |
| 680 | reinterpret_cast<native_handle_t*>( |
| 681 | DEFAULT_SIDEBAND_STREAM))) |
| 682 | .WillOnce(Return(Error::NONE)); |
| 683 | |
| 684 | EXPECT_CALL(*test->mComposer, setLayerSurfaceDamage(HWC_DISPLAY, HWC_LAYER, _)).Times(1); |
| 685 | } |
| 686 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 687 | static void setupREBufferCompositionCommonCallExpectations(CompositionTest* /*test*/) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 688 | }; |
| 689 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 690 | template <typename LayerProperties> |
| 691 | struct CommonSecureLayerProperties : public BaseLayerProperties<LayerProperties> { |
| 692 | using Base = BaseLayerProperties<LayerProperties>; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 693 | |
| 694 | static void setupInsecureREBufferCompositionCommonCallExpectations(CompositionTest* test) { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 695 | EXPECT_CALL(*test->mRenderEngine, drawLayers) |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 696 | .WillOnce([&](const renderengine::DisplaySettings& displaySettings, |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 697 | const std::vector<renderengine::LayerSettings>& layerSettings, |
Alec Mouri | f29700f | 2023-08-17 21:53:31 +0000 | [diff] [blame] | 698 | const std::shared_ptr<renderengine::ExternalTexture>&, |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 699 | base::unique_fd&&) -> ftl::Future<FenceResult> { |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 700 | EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance); |
| 701 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 702 | displaySettings.physicalDisplay); |
| 703 | EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 704 | displaySettings.clip); |
| 705 | // screen capture adds an additional color layer as an alpha |
| 706 | // prefill, so get the back layer. |
Dominik Laskowski | 16164eb | 2024-01-31 11:54:52 -0500 | [diff] [blame] | 707 | ftl::Future<FenceResult> resultFuture = |
| 708 | ftl::yield<FenceResult>(Fence::NO_FENCE); |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 709 | if (layerSettings.empty()) { |
| 710 | ADD_FAILURE() << "layerSettings was not expected to be empty in " |
| 711 | "setupInsecureREBufferCompositionCommonCallExpectations " |
| 712 | "verification lambda"; |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 713 | return resultFuture; |
Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 714 | } |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 715 | const renderengine::LayerSettings layer = layerSettings.back(); |
| 716 | EXPECT_THAT(layer.source.buffer.buffer, IsNull()); |
| 717 | EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), layer.source.solidColor); |
Vishnu Nair | 50c0afe | 2022-07-11 15:04:07 -0700 | [diff] [blame] | 718 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.x); |
| 719 | EXPECT_EQ(0.0, layer.geometry.roundedCornersRadius.y); |
Alec Mouri | 74c7ae1 | 2023-03-26 02:57:47 +0000 | [diff] [blame] | 720 | EXPECT_EQ(ui::Dataspace::V0_SRGB, layer.sourceDataspace); |
Sally Qi | 59a9f50 | 2021-10-12 18:53:23 +0000 | [diff] [blame] | 721 | EXPECT_EQ(1.0f, layer.alpha); |
Sally Qi | 4cabdd0 | 2021-08-05 16:45:57 -0700 | [diff] [blame] | 722 | return resultFuture; |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 723 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | static void setupInsecureREBufferCompositionCallExpectations(CompositionTest* test) { |
| 727 | setupInsecureREBufferCompositionCommonCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | static void setupInsecureREBufferScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 731 | setupInsecureREBufferCompositionCommonCallExpectations(test); |
| 732 | } |
| 733 | }; |
| 734 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 735 | struct ParentSecureLayerProperties |
| 736 | : public CommonSecureLayerProperties<ParentSecureLayerProperties> {}; |
| 737 | |
| 738 | struct SecureLayerProperties : public CommonSecureLayerProperties<SecureLayerProperties> { |
| 739 | static constexpr uint32_t LAYER_FLAGS = ISurfaceComposerClient::eSecure; |
| 740 | }; |
| 741 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 742 | struct CursorLayerProperties : public BaseLayerProperties<CursorLayerProperties> { |
| 743 | using Base = BaseLayerProperties<CursorLayerProperties>; |
| 744 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 745 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 746 | Base::setupLayerState(test, layer); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 747 | layer.potentialCursor = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 748 | } |
| 749 | }; |
| 750 | |
| 751 | struct NoLayerVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 752 | static frontend::RequestedLayerState createLayer(CompositionTest*) { |
| 753 | return {LayerCreationArgs()}; |
| 754 | } |
| 755 | static void injectLayer(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 756 | static void cleanupInjectedLayers(CompositionTest*) {} |
| 757 | |
| 758 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 759 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 760 | }; |
| 761 | |
| 762 | template <typename LayerProperties> |
| 763 | struct BaseLayerVariant { |
| 764 | template <typename L, typename F> |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 765 | static frontend::RequestedLayerState createLayerWithFactory(CompositionTest* test, F factory) { |
Dominik Laskowski | 756b789 | 2021-08-04 12:53:59 -0700 | [diff] [blame] | 766 | EXPECT_CALL(*test->mFlinger.scheduler(), postMessage(_)).Times(0); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 767 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 768 | auto layer = factory(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 769 | |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 770 | // Layer should be registered with scheduler. |
Dominik Laskowski | 9c93d60 | 2021-10-07 19:38:26 -0700 | [diff] [blame] | 771 | EXPECT_EQ(1u, test->mFlinger.scheduler()->layerHistorySize()); |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 772 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 773 | Mock::VerifyAndClear(test->mComposer); |
| 774 | Mock::VerifyAndClear(test->mRenderEngine); |
Dominik Laskowski | 756b789 | 2021-08-04 12:53:59 -0700 | [diff] [blame] | 775 | Mock::VerifyAndClearExpectations(test->mFlinger.scheduler()); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 776 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 777 | initLayerDrawingStateAndComputeBounds(test, layer); |
| 778 | |
| 779 | return layer; |
| 780 | } |
| 781 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 782 | static void initLayerDrawingStateAndComputeBounds(CompositionTest* test, |
| 783 | frontend::RequestedLayerState& layer) { |
| 784 | layer.layerStack = LAYER_STACK; |
| 785 | layer.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1], |
| 786 | LayerProperties::COLOR[2], LayerProperties::COLOR[3]); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 789 | static void injectLayer(CompositionTest* test, frontend::RequestedLayerState& layer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 790 | EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _)) |
| 791 | .WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE))); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 792 | auto legacyLayer = test->mFlinger.getLegacyLayer(layer.id); |
Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 793 | auto outputLayer = test->mDisplay->getCompositionDisplay()->injectOutputLayerForTest( |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 794 | legacyLayer->getCompositionEngineLayerFE({.id = layer.id})); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 795 | outputLayer->editState().visibleRegion = Region(Rect(0, 0, 100, 100)); |
| 796 | outputLayer->editState().outputSpaceVisibleRegion = Region(Rect(0, 0, 100, 100)); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 797 | |
| 798 | Mock::VerifyAndClear(test->mComposer); |
| 799 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 800 | auto layerCopy = std::make_unique<frontend::RequestedLayerState>(layer); |
| 801 | test->mFlinger.addLayer(layerCopy); |
Vishnu Nair | 802ac4f | 2023-05-10 13:55:22 -0700 | [diff] [blame] | 802 | test->mFlinger.mutableVisibleRegionsDirty() = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | static void cleanupInjectedLayers(CompositionTest* test) { |
| 806 | EXPECT_CALL(*test->mComposer, destroyLayer(HWC_DISPLAY, HWC_LAYER)) |
| 807 | .WillOnce(Return(Error::NONE)); |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 808 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 809 | test->mFlinger.destroyAllLayerHandles(); |
Lloyd Pique | 01c77c1 | 2019-04-17 12:48:32 -0700 | [diff] [blame] | 810 | test->mDisplay->getCompositionDisplay()->clearOutputLayers(); |
Vishnu Nair | 802ac4f | 2023-05-10 13:55:22 -0700 | [diff] [blame] | 811 | test->mFlinger.mutablePreviouslyComposedLayers().clear(); |
Dominik Laskowski | 49cea51 | 2019-11-12 14:13:23 -0800 | [diff] [blame] | 812 | // Layer should be unregistered with scheduler. |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 813 | test->mFlinger.commit(); |
Dominik Laskowski | 9c93d60 | 2021-10-07 19:38:26 -0700 | [diff] [blame] | 814 | EXPECT_EQ(0u, test->mFlinger.scheduler()->layerHistorySize()); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 815 | } |
| 816 | }; |
| 817 | |
| 818 | template <typename LayerProperties> |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 819 | struct EffectLayerVariant : public BaseLayerVariant<LayerProperties> { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 820 | using Base = BaseLayerVariant<LayerProperties>; |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 821 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
| 822 | frontend::RequestedLayerState layer = Base::template createLayerWithFactory< |
| 823 | frontend::RequestedLayerState>(test, [test]() { |
| 824 | auto args = LayerCreationArgs(test->mFlinger.flinger(), sp<Client>(), "test-layer", |
| 825 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
| 826 | auto legacyLayer = sp<Layer>::make(args); |
| 827 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 828 | return frontend::RequestedLayerState(args); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 829 | }); |
Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 830 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 831 | layer.crop = Rect(0, 0, LayerProperties::HEIGHT, LayerProperties::WIDTH); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 832 | return layer; |
| 833 | } |
| 834 | |
| 835 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 836 | LayerProperties::setupREColorCompositionCallExpectations(test); |
| 837 | } |
| 838 | |
| 839 | static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 840 | LayerProperties::setupREColorScreenshotCompositionCallExpectations(test); |
| 841 | } |
| 842 | |
| 843 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 844 | LayerProperties::setupHwcSetGeometryCallExpectations(test); |
| 845 | LayerProperties::setupHwcSetSourceCropColorCallExpectations(test); |
| 846 | } |
| 847 | |
| 848 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 849 | LayerProperties::setupHwcSetPerFrameCallExpectations(test); |
| 850 | LayerProperties::setupHwcSetPerFrameColorCallExpectations(test); |
| 851 | } |
| 852 | }; |
| 853 | |
| 854 | template <typename LayerProperties> |
| 855 | struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> { |
| 856 | using Base = BaseLayerVariant<LayerProperties>; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 857 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 858 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
| 859 | frontend::RequestedLayerState layer = Base::template createLayerWithFactory< |
| 860 | frontend::RequestedLayerState>(test, [test]() { |
Alec Mouri | c3a1782 | 2023-08-16 14:56:30 +0000 | [diff] [blame] | 861 | LayerCreationArgs args(test->mFlinger.flinger(), sp<Client>(), "test-layer", |
| 862 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 863 | auto legacyLayer = sp<Layer>::make(args); |
| 864 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 865 | return frontend::RequestedLayerState(args); |
Alec Mouri | c3a1782 | 2023-08-16 14:56:30 +0000 | [diff] [blame] | 866 | }); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 867 | |
| 868 | LayerProperties::setupLayerState(test, layer); |
| 869 | |
| 870 | return layer; |
| 871 | } |
| 872 | |
| 873 | static void cleanupInjectedLayers(CompositionTest* test) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 874 | Base::cleanupInjectedLayers(test); |
| 875 | } |
| 876 | |
| 877 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 878 | LayerProperties::setupHwcSetGeometryCallExpectations(test); |
| 879 | LayerProperties::setupHwcSetSourceCropBufferCallExpectations(test); |
| 880 | } |
| 881 | |
| 882 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 883 | LayerProperties::setupHwcSetPerFrameCallExpectations(test); |
| 884 | LayerProperties::setupHwcSetPerFrameBufferCallExpectations(test); |
| 885 | } |
| 886 | |
| 887 | static void setupRECompositionCallExpectations(CompositionTest* test) { |
| 888 | LayerProperties::setupREBufferCompositionCallExpectations(test); |
| 889 | } |
| 890 | |
| 891 | static void setupInsecureRECompositionCallExpectations(CompositionTest* test) { |
| 892 | LayerProperties::setupInsecureREBufferCompositionCallExpectations(test); |
| 893 | } |
| 894 | |
| 895 | static void setupREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 896 | LayerProperties::setupREBufferScreenshotCompositionCallExpectations(test); |
| 897 | } |
| 898 | |
| 899 | static void setupInsecureREScreenshotCompositionCallExpectations(CompositionTest* test) { |
| 900 | LayerProperties::setupInsecureREBufferScreenshotCompositionCallExpectations(test); |
| 901 | } |
| 902 | }; |
| 903 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 904 | template <typename LayerProperties> |
| 905 | struct ContainerLayerVariant : public BaseLayerVariant<LayerProperties> { |
| 906 | using Base = BaseLayerVariant<LayerProperties>; |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 907 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 908 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 909 | LayerCreationArgs args(test->mFlinger.flinger(), sp<Client>(), "test-container-layer", |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 910 | LayerProperties::LAYER_FLAGS, LayerMetadata()); |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 911 | sp<Layer> legacyLayer = sp<Layer>::make(args); |
| 912 | test->mFlinger.injectLegacyLayer(legacyLayer); |
| 913 | frontend::RequestedLayerState layer(args); |
| 914 | Base::initLayerDrawingStateAndComputeBounds(test, layer); |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 915 | return layer; |
| 916 | } |
| 917 | }; |
| 918 | |
| 919 | template <typename LayerVariant, typename ParentLayerVariant> |
| 920 | struct ChildLayerVariant : public LayerVariant { |
| 921 | using Base = LayerVariant; |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 922 | using ParentBase = ParentLayerVariant; |
| 923 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 924 | static frontend::RequestedLayerState createLayer(CompositionTest* test) { |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 925 | // 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] | 926 | frontend::RequestedLayerState layer = Base::createLayer(test); |
| 927 | frontend::RequestedLayerState parentLayer = ParentBase::createLayer(test); |
| 928 | layer.parentId = parentLayer.id; |
| 929 | auto layerCopy = std::make_unique<frontend::RequestedLayerState>(parentLayer); |
| 930 | test->mFlinger.addLayer(layerCopy); |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 931 | return layer; |
| 932 | } |
| 933 | |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 934 | static void cleanupInjectedLayers(CompositionTest* test) { Base::cleanupInjectedLayers(test); } |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 935 | }; |
| 936 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 937 | /* ------------------------------------------------------------------------ |
| 938 | * Variants to control how the composition type is changed |
| 939 | */ |
| 940 | |
| 941 | struct NoCompositionTypeVariant { |
| 942 | static void setupHwcSetCallExpectations(CompositionTest*) {} |
| 943 | |
| 944 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 945 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1); |
| 946 | } |
| 947 | }; |
| 948 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 949 | template <aidl::android::hardware::graphics::composer3::Composition CompositionType> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 950 | struct KeepCompositionTypeVariant { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 951 | static constexpr aidl::android::hardware::graphics::composer3::Composition TYPE = |
| 952 | CompositionType; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 953 | |
| 954 | static void setupHwcSetCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 955 | if (!test->mDisplayOff) { |
| 956 | EXPECT_CALL(*test->mComposer, |
| 957 | setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, CompositionType)) |
| 958 | .Times(1); |
| 959 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 963 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)).Times(1); |
| 964 | } |
| 965 | }; |
| 966 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 967 | template <aidl::android::hardware::graphics::composer3::Composition InitialCompositionType, |
| 968 | aidl::android::hardware::graphics::composer3::Composition FinalCompositionType> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 969 | struct ChangeCompositionTypeVariant { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 970 | static constexpr aidl::android::hardware::graphics::composer3::Composition TYPE = |
| 971 | FinalCompositionType; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 972 | |
| 973 | static void setupHwcSetCallExpectations(CompositionTest* test) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 974 | if (!test->mDisplayOff) { |
| 975 | EXPECT_CALL(*test->mComposer, |
| 976 | setLayerCompositionType(HWC_DISPLAY, HWC_LAYER, InitialCompositionType)) |
| 977 | .Times(1); |
| 978 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | static void setupHwcGetCallExpectations(CompositionTest* test) { |
| 982 | EXPECT_CALL(*test->mComposer, getChangedCompositionTypes(HWC_DISPLAY, _, _)) |
| 983 | .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::Layer>{ |
| 984 | static_cast<Hwc2::Layer>(HWC_LAYER)}), |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 985 | SetArgPointee<2>( |
| 986 | std::vector<aidl::android::hardware::graphics::composer3:: |
| 987 | Composition>{FinalCompositionType}), |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 988 | Return(Error::NONE))); |
| 989 | } |
| 990 | }; |
| 991 | |
| 992 | /* ------------------------------------------------------------------------ |
| 993 | * Variants to select how the composition is expected to be handled |
| 994 | */ |
| 995 | |
| 996 | struct CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 997 | static void setupLayerState(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 998 | |
| 999 | template <typename Case> |
| 1000 | static void setupCallExpectationsForDirtyGeometry(CompositionTest* test) { |
| 1001 | Case::Layer::setupCallExpectationsForDirtyGeometry(test); |
| 1002 | } |
| 1003 | |
| 1004 | template <typename Case> |
| 1005 | static void setupCallExpectationsForDirtyFrame(CompositionTest* test) { |
| 1006 | Case::Layer::setupCallExpectationsForDirtyFrame(test); |
| 1007 | } |
| 1008 | }; |
| 1009 | |
| 1010 | struct NoCompositionResultVariant : public CompositionResultBaseVariant { |
| 1011 | template <typename Case> |
| 1012 | static void setupCallExpectations(CompositionTest* test) { |
| 1013 | Case::Display::setupEmptyFrameCompositionCallExpectations(test); |
| 1014 | Case::Display::setupHwcCompositionCallExpectations(test); |
| 1015 | } |
| 1016 | }; |
| 1017 | |
| 1018 | struct HwcCompositionResultVariant : public CompositionResultBaseVariant { |
| 1019 | template <typename Case> |
| 1020 | static void setupCallExpectations(CompositionTest* test) { |
| 1021 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1022 | Case::Display::setupHwcCompositionCallExpectations(test); |
| 1023 | } |
| 1024 | }; |
| 1025 | |
| 1026 | struct RECompositionResultVariant : public CompositionResultBaseVariant { |
| 1027 | template <typename Case> |
| 1028 | static void setupCallExpectations(CompositionTest* test) { |
| 1029 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1030 | Case::Display::setupHwcClientCompositionCallExpectations(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1031 | Case::Display::setupRECompositionCallExpectations(test); |
| 1032 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1033 | } |
| 1034 | }; |
| 1035 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1036 | struct ForcedClientCompositionResultVariant : public CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1037 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState& layer) { |
| 1038 | const auto outputLayer = test->mFlinger.findOutputLayerForDisplay(layer.id, test->mDisplay); |
Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 1039 | LOG_FATAL_IF(!outputLayer); |
| 1040 | outputLayer->editState().forceClientComposition = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | template <typename Case> |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 1044 | static void setupCallExpectations(CompositionTest* test) { |
| 1045 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1046 | Case::Display::setupHwcForcedClientCompositionCallExpectations(test); |
| 1047 | Case::Display::setupRECompositionCallExpectations(test); |
| 1048 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1049 | } |
| 1050 | |
| 1051 | template <typename Case> |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1052 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 1053 | |
| 1054 | template <typename Case> |
| 1055 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 1056 | }; |
| 1057 | |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1058 | struct ForcedClientCompositionViaDebugOptionResultVariant : public CompositionResultBaseVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1059 | static void setupLayerState(CompositionTest* test, frontend::RequestedLayerState&) { |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1060 | test->mFlinger.mutableDebugDisableHWC() = true; |
| 1061 | } |
| 1062 | |
| 1063 | template <typename Case> |
| 1064 | static void setupCallExpectations(CompositionTest* test) { |
| 1065 | Case::Display::setupNonEmptyFrameCompositionCallExpectations(test); |
| 1066 | Case::Display::setupHwcForcedClientCompositionCallExpectations(test); |
| 1067 | Case::Display::setupRECompositionCallExpectations(test); |
| 1068 | Case::Display::template setupRELayerCompositionCallExpectations<Case>(test); |
| 1069 | } |
| 1070 | |
| 1071 | template <typename Case> |
| 1072 | static void setupCallExpectationsForDirtyGeometry(CompositionTest*) {} |
| 1073 | |
| 1074 | template <typename Case> |
| 1075 | static void setupCallExpectationsForDirtyFrame(CompositionTest*) {} |
| 1076 | }; |
| 1077 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1078 | struct EmptyScreenshotResultVariant { |
Vishnu Nair | 4dae374 | 2024-07-22 20:28:56 +0000 | [diff] [blame] | 1079 | static void setupLayerState(CompositionTest*, frontend::RequestedLayerState&) {} |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1080 | |
| 1081 | template <typename Case> |
| 1082 | static void setupCallExpectations(CompositionTest*) {} |
| 1083 | }; |
| 1084 | |
| 1085 | struct REScreenshotResultVariant : public EmptyScreenshotResultVariant { |
| 1086 | using Base = EmptyScreenshotResultVariant; |
| 1087 | |
| 1088 | template <typename Case> |
| 1089 | static void setupCallExpectations(CompositionTest* test) { |
| 1090 | Base::template setupCallExpectations<Case>(test); |
| 1091 | Case::Display::template setupRELayerScreenshotCompositionCallExpectations<Case>(test); |
| 1092 | } |
| 1093 | }; |
| 1094 | |
| 1095 | /* ------------------------------------------------------------------------ |
| 1096 | * Composition test case, containing all the variants being tested |
| 1097 | */ |
| 1098 | |
| 1099 | template <typename DisplayCase, typename LayerCase, typename CompositionTypeCase, |
| 1100 | typename CompositionResultCase> |
| 1101 | struct CompositionCase { |
| 1102 | using ThisCase = |
| 1103 | CompositionCase<DisplayCase, LayerCase, CompositionTypeCase, CompositionResultCase>; |
| 1104 | using Display = DisplayCase; |
| 1105 | using Layer = LayerCase; |
| 1106 | using CompositionType = CompositionTypeCase; |
| 1107 | using CompositionResult = CompositionResultCase; |
| 1108 | |
| 1109 | static void setupCommon(CompositionTest* test) { |
Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 1110 | Display::template setupPreconditionCallExpectations<ThisCase>(test); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1111 | Display::setupPreconditions(test); |
| 1112 | |
| 1113 | auto layer = Layer::createLayer(test); |
| 1114 | Layer::injectLayer(test, layer); |
| 1115 | CompositionResult::setupLayerState(test, layer); |
| 1116 | } |
| 1117 | |
| 1118 | static void setupForDirtyGeometry(CompositionTest* test) { |
| 1119 | setupCommon(test); |
| 1120 | |
| 1121 | Display::template setupCommonCompositionCallExpectations<ThisCase>(test); |
| 1122 | CompositionResult::template setupCallExpectationsForDirtyGeometry<ThisCase>(test); |
| 1123 | CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test); |
| 1124 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1125 | } |
| 1126 | |
| 1127 | static void setupForDirtyFrame(CompositionTest* test) { |
| 1128 | setupCommon(test); |
| 1129 | |
| 1130 | Display::template setupCommonCompositionCallExpectations<ThisCase>(test); |
| 1131 | CompositionResult::template setupCallExpectationsForDirtyFrame<ThisCase>(test); |
| 1132 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1133 | } |
| 1134 | |
| 1135 | static void setupForScreenCapture(CompositionTest* test) { |
| 1136 | setupCommon(test); |
| 1137 | |
| 1138 | Display::template setupCommonScreensCaptureCallExpectations<ThisCase>(test); |
| 1139 | CompositionResult::template setupCallExpectations<ThisCase>(test); |
| 1140 | } |
| 1141 | |
| 1142 | static void cleanup(CompositionTest* test) { |
| 1143 | Layer::cleanupInjectedLayers(test); |
| 1144 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1145 | for (auto& displayData : test->mFlinger.mutableHwcDisplayData()) { |
| 1146 | static_cast<TestableSurfaceFlinger::HWC2Display*>(displayData.second.hwcDisplay.get()) |
| 1147 | ->mutableLayers() |
| 1148 | .clear(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1149 | } |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1150 | } |
| 1151 | }; |
| 1152 | |
| 1153 | /* ------------------------------------------------------------------------ |
| 1154 | * Composition cases to test |
| 1155 | */ |
| 1156 | |
| 1157 | TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyGeometry) { |
| 1158 | displayRefreshCompositionDirtyGeometry< |
| 1159 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1160 | NoCompositionResultVariant>>(); |
| 1161 | } |
| 1162 | |
| 1163 | TEST_F(CompositionTest, noLayersDoesMinimalWorkWithDirtyFrame) { |
| 1164 | displayRefreshCompositionDirtyFrame< |
| 1165 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1166 | NoCompositionResultVariant>>(); |
| 1167 | } |
| 1168 | |
| 1169 | TEST_F(CompositionTest, noLayersDoesMinimalWorkToCaptureScreen) { |
| 1170 | captureScreenComposition< |
| 1171 | CompositionCase<DefaultDisplaySetupVariant, NoLayerVariant, NoCompositionTypeVariant, |
| 1172 | EmptyScreenshotResultVariant>>(); |
| 1173 | } |
| 1174 | |
| 1175 | /* ------------------------------------------------------------------------ |
| 1176 | * Simple buffer layers |
| 1177 | */ |
| 1178 | |
| 1179 | TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1180 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1181 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1182 | KeepCompositionTypeVariant< |
| 1183 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1184 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | TEST_F(CompositionTest, HWCComposedNormalBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1188 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1189 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1190 | KeepCompositionTypeVariant< |
| 1191 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1192 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | TEST_F(CompositionTest, REComposedNormalBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1196 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1197 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1198 | ChangeCompositionTypeVariant< |
| 1199 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1200 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1201 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | TEST_F(CompositionTest, captureScreenNormalBufferLayer) { |
| 1205 | captureScreenComposition< |
| 1206 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1207 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1208 | } |
| 1209 | |
| 1210 | /* ------------------------------------------------------------------------ |
| 1211 | * Single-color layers |
| 1212 | */ |
| 1213 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1214 | TEST_F(CompositionTest, HWCComposedEffectLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1215 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1216 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1217 | KeepCompositionTypeVariant< |
| 1218 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR>, |
| 1219 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1222 | TEST_F(CompositionTest, HWCComposedEffectLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1223 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1224 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1225 | KeepCompositionTypeVariant< |
| 1226 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR>, |
| 1227 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1230 | TEST_F(CompositionTest, REComposedEffectLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1231 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1232 | DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
| 1233 | ChangeCompositionTypeVariant< |
| 1234 | aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR, |
| 1235 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1236 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1239 | TEST_F(CompositionTest, captureScreenEffectLayer) { |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1240 | captureScreenComposition< |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 1241 | CompositionCase<DefaultDisplaySetupVariant, EffectLayerVariant<EffectLayerProperties>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1242 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1243 | } |
| 1244 | |
| 1245 | /* ------------------------------------------------------------------------ |
| 1246 | * Layers with sideband buffers |
| 1247 | */ |
| 1248 | |
| 1249 | TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1250 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1251 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1252 | KeepCompositionTypeVariant< |
| 1253 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND>, |
| 1254 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | TEST_F(CompositionTest, HWCComposedSidebandBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1258 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1259 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1260 | KeepCompositionTypeVariant< |
| 1261 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND>, |
| 1262 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | TEST_F(CompositionTest, REComposedSidebandBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1266 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1267 | DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1268 | ChangeCompositionTypeVariant< |
| 1269 | aidl::android::hardware::graphics::composer3::Composition::SIDEBAND, |
| 1270 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1271 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | TEST_F(CompositionTest, captureScreenSidebandBufferLayer) { |
| 1275 | captureScreenComposition< |
| 1276 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SidebandLayerProperties>, |
| 1277 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1278 | } |
| 1279 | |
| 1280 | /* ------------------------------------------------------------------------ |
| 1281 | * Layers with ISurfaceComposerClient::eSecure, on a secure display |
| 1282 | */ |
| 1283 | |
| 1284 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1285 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1286 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1287 | KeepCompositionTypeVariant< |
| 1288 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1289 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1293 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1294 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1295 | KeepCompositionTypeVariant< |
| 1296 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
| 1297 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
| 1300 | TEST_F(CompositionTest, REComposedSecureBufferLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1301 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1302 | DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1303 | ChangeCompositionTypeVariant< |
| 1304 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1305 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1306 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | TEST_F(CompositionTest, captureScreenSecureBufferLayerOnSecureDisplay) { |
| 1310 | captureScreenComposition< |
| 1311 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1312 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1313 | } |
| 1314 | |
| 1315 | /* ------------------------------------------------------------------------ |
| 1316 | * Layers with ISurfaceComposerClient::eSecure, on a non-secure display |
| 1317 | */ |
| 1318 | |
| 1319 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1320 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1321 | InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1322 | KeepCompositionTypeVariant< |
| 1323 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1324 | ForcedClientCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | TEST_F(CompositionTest, HWCComposedSecureBufferLayerOnInsecureDisplayWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1328 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1329 | InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1330 | KeepCompositionTypeVariant< |
| 1331 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1332 | ForcedClientCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | TEST_F(CompositionTest, captureScreenSecureBufferLayerOnInsecureDisplay) { |
| 1336 | captureScreenComposition< |
| 1337 | CompositionCase<InsecureDisplaySetupVariant, BufferLayerVariant<SecureLayerProperties>, |
| 1338 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1339 | } |
| 1340 | |
| 1341 | /* ------------------------------------------------------------------------ |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 1342 | * Layers with a parent layer with ISurfaceComposerClient::eSecure, on a non-secure display |
| 1343 | */ |
| 1344 | |
Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 1345 | TEST_F(CompositionTest, captureScreenBufferLayerWithSecureParentLayerOnInsecureDisplay) { |
| 1346 | captureScreenComposition< |
| 1347 | CompositionCase<InsecureDisplaySetupVariant, |
| 1348 | ChildLayerVariant<BufferLayerVariant<ParentSecureLayerProperties>, |
| 1349 | ContainerLayerVariant<SecureLayerProperties>>, |
| 1350 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1351 | } |
| 1352 | |
| 1353 | /* ------------------------------------------------------------------------ |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1354 | * Cursor layers |
| 1355 | */ |
| 1356 | |
| 1357 | TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1358 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1359 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1360 | KeepCompositionTypeVariant< |
| 1361 | aidl::android::hardware::graphics::composer3::Composition::CURSOR>, |
| 1362 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1363 | } |
| 1364 | |
| 1365 | TEST_F(CompositionTest, HWCComposedCursorLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1366 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1367 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1368 | KeepCompositionTypeVariant< |
| 1369 | aidl::android::hardware::graphics::composer3::Composition::CURSOR>, |
| 1370 | HwcCompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | TEST_F(CompositionTest, REComposedCursorLayer) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1374 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1375 | DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1376 | ChangeCompositionTypeVariant< |
| 1377 | aidl::android::hardware::graphics::composer3::Composition::CURSOR, |
| 1378 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1379 | RECompositionResultVariant>>(); |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | TEST_F(CompositionTest, captureScreenCursorLayer) { |
| 1383 | captureScreenComposition< |
| 1384 | CompositionCase<DefaultDisplaySetupVariant, BufferLayerVariant<CursorLayerProperties>, |
| 1385 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1386 | } |
| 1387 | |
| 1388 | /* ------------------------------------------------------------------------ |
| 1389 | * Simple buffer layer on a display which is powered off. |
| 1390 | */ |
| 1391 | |
| 1392 | TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyGeometry) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1393 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1394 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1395 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1396 | KeepCompositionTypeVariant< |
| 1397 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1398 | HwcCompositionResultVariant>>(); |
| 1399 | } |
| 1400 | |
| 1401 | TEST_F(CompositionTest, displayOffHWCComposedNormalBufferLayerWithDirtyFrame) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1402 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1403 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1404 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1405 | KeepCompositionTypeVariant< |
| 1406 | aidl::android::hardware::graphics::composer3::Composition::DEVICE>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1407 | HwcCompositionResultVariant>>(); |
| 1408 | } |
| 1409 | |
| 1410 | TEST_F(CompositionTest, displayOffREComposedNormalBufferLayer) { |
Alec Mouri | f9a2a2c | 2019-11-12 12:46:02 -0800 | [diff] [blame] | 1411 | mDisplayOff = true; |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1412 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1413 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1414 | ChangeCompositionTypeVariant< |
| 1415 | aidl::android::hardware::graphics::composer3::Composition::DEVICE, |
| 1416 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1417 | RECompositionResultVariant>>(); |
| 1418 | } |
| 1419 | |
| 1420 | TEST_F(CompositionTest, captureScreenNormalBufferLayerOnPoweredOffDisplay) { |
| 1421 | captureScreenComposition<CompositionCase< |
| 1422 | PoweredOffDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1423 | NoCompositionTypeVariant, REScreenshotResultVariant>>(); |
| 1424 | } |
| 1425 | |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1426 | /* ------------------------------------------------------------------------ |
| 1427 | * Client composition forced through debug/developer settings |
| 1428 | */ |
| 1429 | |
| 1430 | TEST_F(CompositionTest, DebugOptionForcingClientCompositionOfBufferLayerWithDirtyGeometry) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1431 | displayRefreshCompositionDirtyGeometry<CompositionCase< |
| 1432 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1433 | KeepCompositionTypeVariant< |
| 1434 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1435 | ForcedClientCompositionViaDebugOptionResultVariant>>(); |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | TEST_F(CompositionTest, DebugOptionForcingClientCompositionOfBufferLayerWithDirtyFrame) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 1439 | displayRefreshCompositionDirtyFrame<CompositionCase< |
| 1440 | DefaultDisplaySetupVariant, BufferLayerVariant<DefaultLayerProperties>, |
| 1441 | KeepCompositionTypeVariant< |
| 1442 | aidl::android::hardware::graphics::composer3::Composition::CLIENT>, |
| 1443 | ForcedClientCompositionViaDebugOptionResultVariant>>(); |
Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 1444 | } |
| 1445 | |
Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 1446 | } // namespace |
| 1447 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 1448 | |
| 1449 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 1450 | #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" |