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