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