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