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