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