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