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