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