| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 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 | #pragma once | 
|  | 18 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 19 | #include <algorithm> | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 20 | #include <chrono> | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 21 | #include <variant> | 
|  | 22 |  | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 23 | #include <compositionengine/Display.h> | 
| Lloyd Pique | 9755fb7 | 2019-03-26 14:44:40 -0700 | [diff] [blame] | 24 | #include <compositionengine/LayerFECompositionState.h> | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 25 | #include <compositionengine/OutputLayer.h> | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 26 | #include <compositionengine/impl/CompositionEngine.h> | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 27 | #include <compositionengine/impl/Display.h> | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 28 | #include <compositionengine/impl/OutputLayerCompositionState.h> | 
| Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 29 | #include <compositionengine/mock/DisplaySurface.h> | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 30 | #include <ftl/fake_guard.h> | 
| chaviw | 0ef7caa | 2021-01-05 11:04:50 -0800 | [diff] [blame] | 31 | #include <gui/ScreenCaptureResults.h> | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 32 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 33 | #include "BufferStateLayer.h" | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 34 | #include "DisplayDevice.h" | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 35 | #include "EffectLayer.h" | 
| Ady Abraham | c581d3c | 2020-08-06 17:34:27 -0700 | [diff] [blame] | 36 | #include "FakeVsyncConfiguration.h" | 
| Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 37 | #include "FrameTracer/FrameTracer.h" | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 38 | #include "Layer.h" | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 39 | #include "NativeWindowSurface.h" | 
| Dominik Laskowski | 9dab343 | 2019-03-27 13:21:10 -0700 | [diff] [blame] | 40 | #include "Scheduler/MessageQueue.h" | 
| Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 41 | #include "Scheduler/RefreshRateConfigs.h" | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 42 | #include "StartPropertySetThread.h" | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 43 | #include "SurfaceFlinger.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 44 | #include "SurfaceFlingerDefaultFactory.h" | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 45 | #include "SurfaceInterceptor.h" | 
| Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 46 | #include "TestableScheduler.h" | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 47 | #include "mock/DisplayHardware/MockComposer.h" | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 48 | #include "mock/DisplayHardware/MockDisplayMode.h" | 
| Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 49 | #include "mock/MockFrameTimeline.h" | 
| Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 50 | #include "mock/MockFrameTracer.h" | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 51 | #include "mock/MockSchedulerCallback.h" | 
| Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 52 |  | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 53 | namespace android { | 
|  | 54 |  | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 55 | class EventThread; | 
|  | 56 |  | 
| Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 57 | namespace renderengine { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 58 |  | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 59 | class RenderEngine; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 60 |  | 
|  | 61 | } // namespace renderengine | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 62 |  | 
|  | 63 | namespace Hwc2 { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 64 |  | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 65 | class Composer; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 66 |  | 
|  | 67 | } // namespace Hwc2 | 
|  | 68 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 69 | namespace hal = android::hardware::graphics::composer::hal; | 
|  | 70 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 71 | namespace surfaceflinger::test { | 
|  | 72 |  | 
|  | 73 | class Factory final : public surfaceflinger::Factory { | 
|  | 74 | public: | 
|  | 75 | ~Factory() = default; | 
|  | 76 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 77 | std::unique_ptr<HWComposer> createHWComposer(const std::string&) override { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 78 | return nullptr; | 
|  | 79 | } | 
|  | 80 |  | 
| Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 81 | std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration( | 
| Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 82 | Fps /*currentRefreshRate*/) override { | 
| Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 83 | return std::make_unique<scheduler::FakePhaseOffsets>(); | 
|  | 84 | } | 
|  | 85 |  | 
| Pablo Gamito | c351d6f | 2020-09-17 15:34:26 +0000 | [diff] [blame] | 86 | sp<SurfaceInterceptor> createSurfaceInterceptor() override { | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 87 | return sp<android::impl::SurfaceInterceptor>::make(); | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 88 | } | 
|  | 89 |  | 
|  | 90 | sp<StartPropertySetThread> createStartPropertySetThread(bool timestampPropertyValue) override { | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 91 | return sp<StartPropertySetThread>::make(timestampPropertyValue); | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 92 | } | 
|  | 93 |  | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 94 | sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) override { | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 95 | return sp<DisplayDevice>::make(creationArgs); | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 96 | } | 
|  | 97 |  | 
|  | 98 | sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, PixelFormat format, | 
|  | 99 | uint32_t layerCount, uint64_t usage, | 
|  | 100 | std::string requestorName) override { | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 101 | return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName); | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 102 | } | 
|  | 103 |  | 
|  | 104 | void createBufferQueue(sp<IGraphicBufferProducer>* outProducer, | 
|  | 105 | sp<IGraphicBufferConsumer>* outConsumer, | 
|  | 106 | bool consumerIsSurfaceFlinger) override { | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 107 | if (!mCreateBufferQueue) { | 
|  | 108 | BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); | 
|  | 109 | return; | 
|  | 110 | } | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 111 | mCreateBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); | 
|  | 112 | } | 
|  | 113 |  | 
|  | 114 | std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface( | 
|  | 115 | const sp<IGraphicBufferProducer>& producer) override { | 
|  | 116 | if (!mCreateNativeWindowSurface) return nullptr; | 
|  | 117 | return mCreateNativeWindowSurface(producer); | 
|  | 118 | } | 
|  | 119 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 120 | std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() override { | 
|  | 121 | return compositionengine::impl::createCompositionEngine(); | 
|  | 122 | } | 
|  | 123 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 124 | sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs&) override { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 125 | return nullptr; | 
|  | 126 | } | 
|  | 127 |  | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 128 | sp<EffectLayer> createEffectLayer(const LayerCreationArgs&) override { return nullptr; } | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 129 |  | 
| Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 130 | std::unique_ptr<FrameTracer> createFrameTracer() override { | 
|  | 131 | return std::make_unique<mock::FrameTracer>(); | 
|  | 132 | } | 
|  | 133 |  | 
| Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 134 | std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline( | 
| Adithya Srinivasan | 9b2ca3e | 2020-11-10 10:14:17 -0800 | [diff] [blame] | 135 | std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid = 0) override { | 
|  | 136 | return std::make_unique<mock::FrameTimeline>(timeStats, surfaceFlingerPid); | 
| Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 137 | } | 
|  | 138 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 139 | using CreateBufferQueueFunction = | 
|  | 140 | std::function<void(sp<IGraphicBufferProducer>* /* outProducer */, | 
|  | 141 | sp<IGraphicBufferConsumer>* /* outConsumer */, | 
|  | 142 | bool /* consumerIsSurfaceFlinger */)>; | 
|  | 143 | CreateBufferQueueFunction mCreateBufferQueue; | 
|  | 144 |  | 
|  | 145 | using CreateNativeWindowSurfaceFunction = | 
|  | 146 | std::function<std::unique_ptr<surfaceflinger::NativeWindowSurface>( | 
|  | 147 | const sp<IGraphicBufferProducer>&)>; | 
|  | 148 | CreateNativeWindowSurfaceFunction mCreateNativeWindowSurface; | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 149 |  | 
|  | 150 | using CreateCompositionEngineFunction = | 
|  | 151 | std::function<std::unique_ptr<compositionengine::CompositionEngine>()>; | 
|  | 152 | CreateCompositionEngineFunction mCreateCompositionEngine; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 153 | }; | 
|  | 154 |  | 
|  | 155 | } // namespace surfaceflinger::test | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 156 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 157 | class TestableSurfaceFlinger { | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 158 | public: | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 159 | using HotplugEvent = SurfaceFlinger::HotplugEvent; | 
|  | 160 |  | 
| Vishnu Nair | 4df8eb6 | 2022-02-17 15:32:02 -0800 | [diff] [blame] | 161 | TestableSurfaceFlinger(sp<SurfaceFlinger> flinger = nullptr) : mFlinger(flinger) { | 
|  | 162 | if (!mFlinger) { | 
|  | 163 | mFlinger = sp<SurfaceFlinger>::make(mFactory, SurfaceFlinger::SkipInitialization); | 
|  | 164 | } | 
| Ady Abraham | e9ebce0 | 2022-02-03 12:05:06 -0800 | [diff] [blame] | 165 | mFlinger->mAnimationTransactionTimeout = ms2ns(10); | 
|  | 166 | } | 
|  | 167 |  | 
| Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 168 | SurfaceFlinger* flinger() { return mFlinger.get(); } | 
| Dominik Laskowski | 068173d | 2021-08-11 17:22:59 -0700 | [diff] [blame] | 169 | scheduler::TestableScheduler* scheduler() { return mScheduler; } | 
| Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 170 |  | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 171 | // Extend this as needed for accessing SurfaceFlinger private (and public) | 
|  | 172 | // functions. | 
|  | 173 |  | 
| Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 174 | void setupRenderEngine(std::unique_ptr<renderengine::RenderEngine> renderEngine) { | 
| Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 175 | mFlinger->mCompositionEngine->setRenderEngine(std::move(renderEngine)); | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 176 | } | 
|  | 177 |  | 
|  | 178 | void setupComposer(std::unique_ptr<Hwc2::Composer> composer) { | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 179 | mFlinger->mCompositionEngine->setHwComposer( | 
|  | 180 | std::make_unique<impl::HWComposer>(std::move(composer))); | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 181 | } | 
|  | 182 |  | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 183 | void setupPowerAdvisor(std::unique_ptr<Hwc2::PowerAdvisor> powerAdvisor) { | 
|  | 184 | mFlinger->mPowerAdvisor = std::move(powerAdvisor); | 
|  | 185 | } | 
|  | 186 |  | 
| Alec Mouri | e4034bb | 2019-11-19 12:45:54 -0800 | [diff] [blame] | 187 | void setupTimeStats(const std::shared_ptr<TimeStats>& timeStats) { | 
|  | 188 | mFlinger->mCompositionEngine->setTimeStats(timeStats); | 
|  | 189 | } | 
|  | 190 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 191 | enum class SchedulerCallbackImpl { kNoOp, kMock }; | 
|  | 192 |  | 
|  | 193 | static constexpr struct OneDisplayMode { | 
|  | 194 | } kOneDisplayMode; | 
|  | 195 |  | 
|  | 196 | static constexpr struct TwoDisplayModes { | 
|  | 197 | } kTwoDisplayModes; | 
|  | 198 |  | 
|  | 199 | using RefreshRateConfigsPtr = std::shared_ptr<scheduler::RefreshRateConfigs>; | 
|  | 200 |  | 
|  | 201 | using DisplayModesVariant = | 
|  | 202 | std::variant<OneDisplayMode, TwoDisplayModes, RefreshRateConfigsPtr>; | 
|  | 203 |  | 
| Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 204 | void setupScheduler(std::unique_ptr<scheduler::VsyncController> vsyncController, | 
|  | 205 | std::unique_ptr<scheduler::VSyncTracker> vsyncTracker, | 
| Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 206 | std::unique_ptr<EventThread> appEventThread, | 
| Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 207 | std::unique_ptr<EventThread> sfEventThread, | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 208 | SchedulerCallbackImpl callbackImpl = SchedulerCallbackImpl::kNoOp, | 
| Vishnu Nair | 4df8eb6 | 2022-02-17 15:32:02 -0800 | [diff] [blame] | 209 | DisplayModesVariant modesVariant = kOneDisplayMode, | 
|  | 210 | bool useNiceMock = false) { | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 211 | RefreshRateConfigsPtr configs; | 
|  | 212 | if (std::holds_alternative<RefreshRateConfigsPtr>(modesVariant)) { | 
|  | 213 | configs = std::move(std::get<RefreshRateConfigsPtr>(modesVariant)); | 
|  | 214 | } else { | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 215 | constexpr DisplayModeId kModeId60{0}; | 
|  | 216 | DisplayModes modes = makeModes(mock::createDisplayMode(kModeId60, 60_Hz)); | 
| Ady Abraham | abc2760 | 2020-04-08 17:20:29 -0700 | [diff] [blame] | 217 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 218 | if (std::holds_alternative<TwoDisplayModes>(modesVariant)) { | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 219 | constexpr DisplayModeId kModeId90{1}; | 
|  | 220 | modes.try_emplace(kModeId90, mock::createDisplayMode(kModeId90, 90_Hz)); | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 221 | } | 
|  | 222 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 223 | configs = std::make_shared<scheduler::RefreshRateConfigs>(modes, kModeId60); | 
| Dominik Laskowski | 983f2b5 | 2020-06-25 16:54:06 -0700 | [diff] [blame] | 224 | } | 
|  | 225 |  | 
| Dominik Laskowski | f8734e0 | 2022-08-26 09:06:59 -0700 | [diff] [blame] | 226 | const auto fps = FTL_FAKE_GUARD(kMainThreadContext, configs->getActiveMode().getFps()); | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 227 | mFlinger->mVsyncConfiguration = mFactory.createVsyncConfiguration(fps); | 
| Ady Abraham | 23ea9da | 2021-07-14 16:32:56 -0700 | [diff] [blame] | 228 | mFlinger->mVsyncModulator = sp<scheduler::VsyncModulator>::make( | 
|  | 229 | mFlinger->mVsyncConfiguration->getCurrentConfigs()); | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 230 |  | 
| Marin Shalamanov | 68a9409 | 2020-11-24 17:48:00 +0100 | [diff] [blame] | 231 | mFlinger->mRefreshRateStats = | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 232 | std::make_unique<scheduler::RefreshRateStats>(*mFlinger->mTimeStats, fps, | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 233 | hal::PowerMode::OFF); | 
|  | 234 |  | 
|  | 235 | using Callback = scheduler::ISchedulerCallback; | 
|  | 236 | Callback& callback = callbackImpl == SchedulerCallbackImpl::kNoOp | 
|  | 237 | ? static_cast<Callback&>(mNoOpSchedulerCallback) | 
|  | 238 | : static_cast<Callback&>(mSchedulerCallback); | 
| Steven Thomas | 2bbaabe | 2019-08-28 16:08:35 -0700 | [diff] [blame] | 239 |  | 
| Vishnu Nair | 4df8eb6 | 2022-02-17 15:32:02 -0800 | [diff] [blame] | 240 | if (useNiceMock) { | 
|  | 241 | mScheduler = | 
|  | 242 | new testing::NiceMock<scheduler::TestableScheduler>(std::move(vsyncController), | 
|  | 243 | std::move(vsyncTracker), | 
|  | 244 | std::move(configs), | 
|  | 245 | callback); | 
|  | 246 | } else { | 
|  | 247 | mScheduler = new scheduler::TestableScheduler(std::move(vsyncController), | 
|  | 248 | std::move(vsyncTracker), | 
|  | 249 | std::move(configs), callback); | 
|  | 250 | } | 
| Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 251 |  | 
| Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 252 | mFlinger->mAppConnectionHandle = mScheduler->createConnection(std::move(appEventThread)); | 
|  | 253 | mFlinger->mSfConnectionHandle = mScheduler->createConnection(std::move(sfEventThread)); | 
| Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 254 | resetScheduler(mScheduler); | 
| Dominik Laskowski | 7c9dbf9 | 2019-08-01 17:57:31 -0700 | [diff] [blame] | 255 | } | 
|  | 256 |  | 
| Dominik Laskowski | 068173d | 2021-08-11 17:22:59 -0700 | [diff] [blame] | 257 | void resetScheduler(scheduler::Scheduler* scheduler) { mFlinger->mScheduler.reset(scheduler); } | 
| Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 258 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 259 | scheduler::TestableScheduler& mutableScheduler() { return *mScheduler; } | 
|  | 260 | scheduler::mock::SchedulerCallback& mockSchedulerCallback() { return mSchedulerCallback; } | 
| Ady Abraham | 44e9f3b | 2021-02-16 15:22:58 -0800 | [diff] [blame] | 261 |  | 
| Ady Abraham | 2739e83 | 2022-02-14 17:42:00 -0800 | [diff] [blame] | 262 | auto& mutableVsyncModulator() { return mFlinger->mVsyncModulator; } | 
|  | 263 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 264 | using CreateBufferQueueFunction = surfaceflinger::test::Factory::CreateBufferQueueFunction; | 
| Lloyd Pique | 5b36f3f | 2018-01-17 11:57:07 -0800 | [diff] [blame] | 265 | void setCreateBufferQueueFunction(CreateBufferQueueFunction f) { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 266 | mFactory.mCreateBufferQueue = f; | 
| Lloyd Pique | 5b36f3f | 2018-01-17 11:57:07 -0800 | [diff] [blame] | 267 | } | 
|  | 268 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 269 | using CreateNativeWindowSurfaceFunction = | 
|  | 270 | surfaceflinger::test::Factory::CreateNativeWindowSurfaceFunction; | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 271 | void setCreateNativeWindowSurface(CreateNativeWindowSurfaceFunction f) { | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 272 | mFactory.mCreateNativeWindowSurface = f; | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 273 | } | 
|  | 274 |  | 
| Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 275 | void setInternalDisplayPrimaries(const ui::DisplayPrimaries& primaries) { | 
|  | 276 | memcpy(&mFlinger->mInternalDisplayPrimaries, &primaries, sizeof(ui::DisplayPrimaries)); | 
|  | 277 | } | 
|  | 278 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 279 | static auto& mutableLayerDrawingState(const sp<Layer>& layer) { return layer->mDrawingState; } | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 280 |  | 
| Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 281 | auto& mutableStateLock() { return mFlinger->mStateLock; } | 
|  | 282 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 283 | static auto findOutputLayerForDisplay(const sp<Layer>& layer, | 
|  | 284 | const sp<const DisplayDevice>& display) { | 
|  | 285 | return layer->findOutputLayerForDisplay(display.get()); | 
|  | 286 | } | 
|  | 287 |  | 
|  | 288 | static void setLayerSidebandStream(const sp<Layer>& layer, | 
|  | 289 | const sp<NativeHandle>& sidebandStream) { | 
| Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 290 | layer->mDrawingState.sidebandStream = sidebandStream; | 
| Lloyd Pique | 0b785d8 | 2018-12-04 17:25:27 -0800 | [diff] [blame] | 291 | layer->mSidebandStream = sidebandStream; | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 292 | layer->editCompositionState()->sidebandStream = sidebandStream; | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 293 | } | 
|  | 294 |  | 
| Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 295 | void setLayerCompositionType(const sp<Layer>& layer, | 
|  | 296 | aidl::android::hardware::graphics::composer3::Composition type) { | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 297 | auto outputLayer = findOutputLayerForDisplay(layer, mFlinger->getDefaultDisplayDevice()); | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 298 | LOG_ALWAYS_FATAL_IF(!outputLayer); | 
|  | 299 | auto& state = outputLayer->editState(); | 
|  | 300 | LOG_ALWAYS_FATAL_IF(!outputLayer->getState().hwc); | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 301 | (*state.hwc).hwcCompositionType = type; | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 302 | } | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 303 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 304 | static void setLayerPotentialCursor(const sp<Layer>& layer, bool potentialCursor) { | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 305 | layer->mPotentialCursor = potentialCursor; | 
|  | 306 | } | 
|  | 307 |  | 
| Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 308 | static void setLayerDrawingParent(const sp<Layer>& layer, const sp<Layer>& drawingParent) { | 
| Rob Carr | c6d2d2b | 2021-10-25 16:51:49 +0000 | [diff] [blame] | 309 | layer->mDrawingParent = drawingParent; | 
| Garfield Tan | de619fa | 2020-10-02 17:13:53 -0700 | [diff] [blame] | 310 | } | 
|  | 311 |  | 
| Matt Buckley | 50c4406 | 2022-01-17 20:48:10 +0000 | [diff] [blame] | 312 | void setPowerHintSessionMode(bool early, bool late) { | 
|  | 313 | mFlinger->mPowerHintSessionMode = {.late = late, .early = early}; | 
|  | 314 | } | 
|  | 315 |  | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 316 | /* ------------------------------------------------------------------------ | 
|  | 317 | * Forwarding for functions being tested | 
|  | 318 | */ | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 319 |  | 
| Dominik Laskowski | f11728a | 2022-07-28 13:07:42 -0700 | [diff] [blame] | 320 | void configure() { mFlinger->configure(); } | 
|  | 321 |  | 
|  | 322 | void configureAndCommit() { | 
|  | 323 | configure(); | 
|  | 324 | commitTransactionsLocked(eDisplayTransactionNeeded); | 
|  | 325 | } | 
|  | 326 |  | 
|  | 327 | TimePoint commit(TimePoint frameTime, VsyncId vsyncId, TimePoint expectedVsyncTime) { | 
|  | 328 | mFlinger->commit(frameTime, vsyncId, expectedVsyncTime); | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 329 | return frameTime; | 
|  | 330 | } | 
|  | 331 |  | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 332 | TimePoint commit(TimePoint frameTime, VsyncId vsyncId) { | 
|  | 333 | return commit(frameTime, vsyncId, frameTime + Period(10ms)); | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 334 | } | 
|  | 335 |  | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 336 | TimePoint commit() { | 
|  | 337 | const TimePoint frameTime = scheduler::SchedulerClock::now(); | 
|  | 338 | return commit(frameTime, kVsyncId); | 
| Xiang Wang | 839fe5b | 2022-04-04 17:39:38 +0000 | [diff] [blame] | 339 | } | 
|  | 340 |  | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 341 | void commitAndComposite(TimePoint frameTime, VsyncId vsyncId, TimePoint expectedVsyncTime) { | 
|  | 342 | mFlinger->composite(commit(frameTime, vsyncId, expectedVsyncTime), vsyncId); | 
| Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 343 | } | 
|  | 344 |  | 
| Ady Abraham | 302ebed | 2022-03-07 16:03:41 -0800 | [diff] [blame] | 345 | void commitAndComposite() { mFlinger->composite(commit(), kVsyncId); } | 
| Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 346 |  | 
| Lloyd Pique | a482f99 | 2018-01-22 19:00:34 -0800 | [diff] [blame] | 347 | auto createDisplay(const String8& displayName, bool secure) { | 
|  | 348 | return mFlinger->createDisplay(displayName, secure); | 
|  | 349 | } | 
|  | 350 |  | 
| Dominik Laskowski | eecd659 | 2018-05-29 10:25:41 -0700 | [diff] [blame] | 351 | auto destroyDisplay(const sp<IBinder>& displayToken) { | 
|  | 352 | return mFlinger->destroyDisplay(displayToken); | 
|  | 353 | } | 
| Lloyd Pique | a482f99 | 2018-01-22 19:00:34 -0800 | [diff] [blame] | 354 |  | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 355 | auto getDisplay(const sp<IBinder>& displayToken) { | 
|  | 356 | Mutex::Autolock lock(mFlinger->mStateLock); | 
|  | 357 | return mFlinger->getDisplayDeviceLocked(displayToken); | 
|  | 358 | } | 
|  | 359 |  | 
| Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 360 | void enableHalVirtualDisplays(bool enable) { mFlinger->enableHalVirtualDisplays(enable); } | 
|  | 361 |  | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 362 | auto setupNewDisplayDeviceInternal( | 
|  | 363 | const wp<IBinder>& displayToken, | 
|  | 364 | std::shared_ptr<compositionengine::Display> compositionDisplay, | 
|  | 365 | const DisplayDeviceState& state, | 
|  | 366 | const sp<compositionengine::DisplaySurface>& dispSurface, | 
| Dominik Laskowski | 0a1435d | 2020-04-21 00:27:31 -0700 | [diff] [blame] | 367 | const sp<IGraphicBufferProducer>& producer) NO_THREAD_SAFETY_ANALYSIS { | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 368 | return mFlinger->setupNewDisplayDeviceInternal(displayToken, compositionDisplay, state, | 
|  | 369 | dispSurface, producer); | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 370 | } | 
|  | 371 |  | 
| Dominik Laskowski | f11728a | 2022-07-28 13:07:42 -0700 | [diff] [blame] | 372 | void commitTransactionsLocked(uint32_t transactionFlags) { | 
| Dominik Laskowski | 9e168db | 2021-05-27 16:05:12 -0700 | [diff] [blame] | 373 | Mutex::Autolock lock(mFlinger->mStateLock); | 
| Dominik Laskowski | f8734e0 | 2022-08-26 09:06:59 -0700 | [diff] [blame] | 374 | ftl::FakeGuard guard(kMainThreadContext); | 
| Dominik Laskowski | f11728a | 2022-07-28 13:07:42 -0700 | [diff] [blame] | 375 | mFlinger->commitTransactionsLocked(transactionFlags); | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 376 | } | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 377 |  | 
| Dominik Laskowski | ebc8d3a | 2021-04-16 23:18:31 -0700 | [diff] [blame] | 378 | void onComposerHalHotplug(hal::HWDisplayId hwcDisplayId, hal::Connection connection) { | 
|  | 379 | mFlinger->onComposerHalHotplug(hwcDisplayId, connection); | 
| Lloyd Pique | 6cf1103 | 2018-01-22 18:57:44 -0800 | [diff] [blame] | 380 | } | 
|  | 381 |  | 
| Vishnu Nair | ce5d0cc | 2019-02-28 14:38:41 -0800 | [diff] [blame] | 382 | auto setDisplayStateLocked(const DisplayState& s) { | 
| Dominik Laskowski | 9e168db | 2021-05-27 16:05:12 -0700 | [diff] [blame] | 383 | Mutex::Autolock lock(mFlinger->mStateLock); | 
| Vishnu Nair | ce5d0cc | 2019-02-28 14:38:41 -0800 | [diff] [blame] | 384 | return mFlinger->setDisplayStateLocked(s); | 
|  | 385 | } | 
| Lloyd Pique | 9d9cf40 | 2018-02-16 17:47:13 -0800 | [diff] [blame] | 386 |  | 
| Dominik Laskowski | 83b8821 | 2018-12-11 13:34:06 -0800 | [diff] [blame] | 387 | // Allow reading display state without locking, as if called on the SF main thread. | 
|  | 388 | auto onInitializeDisplays() NO_THREAD_SAFETY_ANALYSIS { | 
|  | 389 | return mFlinger->onInitializeDisplays(); | 
|  | 390 | } | 
| Lloyd Pique | 86016da | 2018-03-01 16:09:38 -0800 | [diff] [blame] | 391 |  | 
| Lais Andrade | 3a6e47d | 2020-04-02 11:20:16 +0100 | [diff] [blame] | 392 | auto notifyPowerBoost(int32_t boostId) { return mFlinger->notifyPowerBoost(boostId); } | 
|  | 393 |  | 
| Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 394 | auto setDisplayBrightness(const sp<IBinder>& display, | 
|  | 395 | const gui::DisplayBrightness& brightness) { | 
|  | 396 | return mFlinger->setDisplayBrightness(display, brightness); | 
|  | 397 | } | 
|  | 398 |  | 
| Dominik Laskowski | 83b8821 | 2018-12-11 13:34:06 -0800 | [diff] [blame] | 399 | // Allow reading display state without locking, as if called on the SF main thread. | 
|  | 400 | auto setPowerModeInternal(const sp<DisplayDevice>& display, | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 401 | hal::PowerMode mode) NO_THREAD_SAFETY_ANALYSIS { | 
| Dominik Laskowski | e977409 | 2018-12-11 10:04:24 -0800 | [diff] [blame] | 402 | return mFlinger->setPowerModeInternal(display, mode); | 
| Lloyd Pique | 7d4aa6c | 2018-03-01 16:36:35 -0800 | [diff] [blame] | 403 | } | 
|  | 404 |  | 
| Robert Carr | 12a3b9b | 2022-03-10 09:55:29 -0800 | [diff] [blame] | 405 | auto renderScreenImpl(const RenderArea& renderArea, | 
| chaviw | 426b5c0 | 2020-07-27 11:20:15 -0700 | [diff] [blame] | 406 | SurfaceFlinger::TraverseLayersFunction traverseLayers, | 
| Alec Mouri | a90a570 | 2021-04-16 16:36:21 +0000 | [diff] [blame] | 407 | const std::shared_ptr<renderengine::ExternalTexture>& buffer, | 
|  | 408 | bool forSystem, bool regionSampling) { | 
| chaviw | 426b5c0 | 2020-07-27 11:20:15 -0700 | [diff] [blame] | 409 | ScreenCaptureResults captureResults; | 
| Robert Carr | 12a3b9b | 2022-03-10 09:55:29 -0800 | [diff] [blame] | 410 | return mFlinger->renderScreenImpl(renderArea, traverseLayers, buffer, forSystem, | 
| chaviw | 17ac24b | 2021-01-28 18:50:05 -0800 | [diff] [blame] | 411 | regionSampling, false /* grayscale */, | 
|  | 412 | captureResults); | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 413 | } | 
|  | 414 |  | 
| chaviw | 4b9d5e1 | 2020-08-04 18:30:35 -0700 | [diff] [blame] | 415 | auto traverseLayersInLayerStack(ui::LayerStack layerStack, int32_t uid, | 
| Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 416 | const LayerVector::Visitor& visitor) { | 
| chaviw | 4b9d5e1 | 2020-08-04 18:30:35 -0700 | [diff] [blame] | 417 | return mFlinger->SurfaceFlinger::traverseLayersInLayerStack(layerStack, uid, visitor); | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 418 | } | 
|  | 419 |  | 
| Daniel Solomon | 42d0456 | 2019-01-20 21:03:19 -0800 | [diff] [blame] | 420 | auto getDisplayNativePrimaries(const sp<IBinder>& displayToken, | 
|  | 421 | ui::DisplayPrimaries &primaries) { | 
|  | 422 | return mFlinger->SurfaceFlinger::getDisplayNativePrimaries(displayToken, primaries); | 
|  | 423 | } | 
|  | 424 |  | 
| Vishnu Nair | 60d902e | 2022-07-20 02:55:37 +0000 | [diff] [blame] | 425 | auto& getTransactionQueue() { return mFlinger->mLocklessTransactionQueue; } | 
| Arthur Hung | 5814427 | 2021-01-16 03:43:53 +0000 | [diff] [blame] | 426 | auto& getPendingTransactionQueue() { return mFlinger->mPendingTransactionQueues; } | 
| ramindani | 4d48f90 | 2021-09-20 21:07:45 +0000 | [diff] [blame] | 427 | auto& getTransactionCommittedSignals() { return mFlinger->mTransactionCommittedSignals; } | 
| Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 428 |  | 
| Siarhei Vishniakou | fc434ac | 2021-01-13 10:28:00 -1000 | [diff] [blame] | 429 | auto setTransactionState( | 
|  | 430 | const FrameTimelineInfo& frameTimelineInfo, const Vector<ComposerState>& states, | 
|  | 431 | const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, | 
|  | 432 | const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime, | 
|  | 433 | bool isAutoTimestamp, const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, | 
|  | 434 | std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId) { | 
|  | 435 | return mFlinger->setTransactionState(frameTimelineInfo, states, displays, flags, applyToken, | 
|  | 436 | inputWindowCommands, desiredPresentTime, | 
| Ady Abraham | f0c5649 | 2020-12-17 18:04:15 -0800 | [diff] [blame] | 437 | isAutoTimestamp, uncacheBuffer, hasListenerCallbacks, | 
|  | 438 | listenerCallbacks, transactionId); | 
| Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 439 | } | 
|  | 440 |  | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 441 | auto flushTransactionQueues() { | 
|  | 442 | return FTL_FAKE_GUARD(kMainThreadContext, mFlinger->flushTransactionQueues(kVsyncId)); | 
|  | 443 | } | 
| Valerie Hau | d251afb | 2019-03-29 14:19:02 -0700 | [diff] [blame] | 444 |  | 
| Eduardo Rocha | ac86719 | 2020-09-14 20:12:17 +0000 | [diff] [blame] | 445 | auto onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { | 
|  | 446 | return mFlinger->onTransact(code, data, reply, flags); | 
|  | 447 | } | 
|  | 448 |  | 
| Huihong Luo | 02186fb | 2022-02-23 14:21:54 -0800 | [diff] [blame] | 449 | auto getGpuContextPriority() { return mFlinger->getGpuContextPriority(); } | 
| Ana Krulec | 31f2b3c | 2020-12-14 14:30:09 -0800 | [diff] [blame] | 450 |  | 
| Ady Abraham | 899dcdb | 2021-06-15 16:56:21 -0700 | [diff] [blame] | 451 | auto calculateMaxAcquiredBufferCount(Fps refreshRate, | 
|  | 452 | std::chrono::nanoseconds presentLatency) const { | 
|  | 453 | return SurfaceFlinger::calculateMaxAcquiredBufferCount(refreshRate, presentLatency); | 
| Ady Abraham | 564f9de | 2021-02-03 18:34:33 -0800 | [diff] [blame] | 454 | } | 
|  | 455 |  | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 456 | auto setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, ui::DisplayModeId defaultMode, | 
|  | 457 | bool allowGroupSwitching, float primaryRefreshRateMin, | 
|  | 458 | float primaryRefreshRateMax, float appRequestRefreshRateMin, | 
|  | 459 | float appRequestRefreshRateMax) { | 
|  | 460 | return mFlinger->setDesiredDisplayModeSpecs(displayToken, defaultMode, allowGroupSwitching, | 
|  | 461 | primaryRefreshRateMin, primaryRefreshRateMax, | 
|  | 462 | appRequestRefreshRateMin, | 
|  | 463 | appRequestRefreshRateMax); | 
|  | 464 | } | 
|  | 465 |  | 
|  | 466 | void onActiveDisplayChanged(const sp<DisplayDevice>& activeDisplay) { | 
|  | 467 | Mutex::Autolock lock(mFlinger->mStateLock); | 
| Dominik Laskowski | f8734e0 | 2022-08-26 09:06:59 -0700 | [diff] [blame] | 468 | ftl::FakeGuard guard(kMainThreadContext); | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 469 | mFlinger->onActiveDisplayChangedLocked(activeDisplay); | 
|  | 470 | } | 
|  | 471 |  | 
| Vishnu Nair | 4df8eb6 | 2022-02-17 15:32:02 -0800 | [diff] [blame] | 472 | auto createLayer(LayerCreationArgs& args, sp<IBinder>* outHandle, | 
|  | 473 | const sp<IBinder>& parentHandle, int32_t* outLayerId, | 
|  | 474 | const sp<Layer>& parentLayer, uint32_t* outTransformHint) { | 
|  | 475 | return mFlinger->createLayer(args, outHandle, parentHandle, outLayerId, parentLayer, | 
|  | 476 | outTransformHint); | 
|  | 477 | } | 
|  | 478 |  | 
|  | 479 | auto mirrorLayer(const LayerCreationArgs& args, const sp<IBinder>& mirrorFromHandle, | 
|  | 480 | sp<IBinder>* outHandle, int32_t* outLayerId) { | 
|  | 481 | return mFlinger->mirrorLayer(args, mirrorFromHandle, outHandle, outLayerId); | 
|  | 482 | } | 
|  | 483 |  | 
| Lloyd Pique | 86016da | 2018-03-01 16:09:38 -0800 | [diff] [blame] | 484 | /* ------------------------------------------------------------------------ | 
|  | 485 | * Read-only access to private data to assert post-conditions. | 
|  | 486 | */ | 
|  | 487 |  | 
| Lloyd Pique | 7d4aa6c | 2018-03-01 16:36:35 -0800 | [diff] [blame] | 488 | const auto& getVisibleRegionsDirty() const { return mFlinger->mVisibleRegionsDirty; } | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 489 | auto& getHwComposer() const { | 
|  | 490 | return static_cast<impl::HWComposer&>(mFlinger->getHwComposer()); | 
|  | 491 | } | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 492 | auto& getCompositionEngine() const { return mFlinger->getCompositionEngine(); } | 
| Lloyd Pique | 7d4aa6c | 2018-03-01 16:36:35 -0800 | [diff] [blame] | 493 |  | 
| Adithya Srinivasan | b238cd5 | 2021-02-04 17:54:05 +0000 | [diff] [blame] | 494 | mock::FrameTracer* getFrameTracer() const { | 
|  | 495 | return static_cast<mock::FrameTracer*>(mFlinger->mFrameTracer.get()); | 
|  | 496 | } | 
|  | 497 |  | 
| Ady Abraham | e9ebce0 | 2022-02-03 12:05:06 -0800 | [diff] [blame] | 498 | nsecs_t getAnimationTransactionTimeout() const { | 
|  | 499 | return mFlinger->mAnimationTransactionTimeout; | 
|  | 500 | } | 
|  | 501 |  | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 502 | /* ------------------------------------------------------------------------ | 
|  | 503 | * Read-write access to private data to set up preconditions and assert | 
|  | 504 | * post-conditions. | 
|  | 505 | */ | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 506 |  | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 507 | const auto& displays() const { return mFlinger->mDisplays; } | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 508 | const auto& physicalDisplays() const { return mFlinger->mPhysicalDisplays; } | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 509 | const auto& currentState() const { return mFlinger->mCurrentState; } | 
|  | 510 | const auto& drawingState() const { return mFlinger->mDrawingState; } | 
|  | 511 | const auto& transactionFlags() const { return mFlinger->mTransactionFlags; } | 
| Dominik Laskowski | bab5128 | 2022-08-12 09:28:55 -0700 | [diff] [blame] | 512 |  | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 513 | const auto& hwcPhysicalDisplayIdMap() const { return getHwComposer().mPhysicalDisplayIdMap; } | 
| Dominik Laskowski | bab5128 | 2022-08-12 09:28:55 -0700 | [diff] [blame] | 514 | const auto& hwcDisplayData() const { return getHwComposer().mDisplayData; } | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 515 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 516 | auto& mutableHasWideColorDisplay() { return SurfaceFlinger::hasWideColorDisplay; } | 
|  | 517 |  | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 518 | auto& mutableCurrentState() { return mFlinger->mCurrentState; } | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 519 | auto& mutableDisplayColorSetting() { return mFlinger->mDisplayColorSetting; } | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 520 | auto& mutableDisplays() { return mFlinger->mDisplays; } | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 521 | auto& mutablePhysicalDisplays() { return mFlinger->mPhysicalDisplays; } | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 522 | auto& mutableDrawingState() { return mFlinger->mDrawingState; } | 
| Dominik Laskowski | 8da6b0e | 2021-05-12 15:34:13 -0700 | [diff] [blame] | 523 | auto& mutableGeometryDirty() { return mFlinger->mGeometryDirty; } | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 524 | auto& mutableInterceptor() { return mFlinger->mInterceptor; } | 
| Lloyd Pique | 6cf1103 | 2018-01-22 18:57:44 -0800 | [diff] [blame] | 525 | auto& mutableMainThreadId() { return mFlinger->mMainThreadId; } | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 526 | auto& mutablePendingHotplugEvents() { return mFlinger->mPendingHotplugEvents; } | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 527 | auto& mutableTexturePool() { return mFlinger->mTexturePool; } | 
| Lloyd Pique | 0b1fe70 | 2018-01-22 18:03:16 -0800 | [diff] [blame] | 528 | auto& mutableTransactionFlags() { return mFlinger->mTransactionFlags; } | 
| Lloyd Pique | 4fe2940 | 2019-08-12 16:51:24 -0700 | [diff] [blame] | 529 | auto& mutableDebugDisableHWC() { return mFlinger->mDebugDisableHWC; } | 
| Garfield Tan | 9c9c191 | 2021-07-19 12:02:16 -0700 | [diff] [blame] | 530 | auto& mutableMaxRenderTargetSize() { return mFlinger->mMaxRenderTargetSize; } | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 531 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 532 | auto& mutableHwcDisplayData() { return getHwComposer().mDisplayData; } | 
|  | 533 | auto& mutableHwcPhysicalDisplayIdMap() { return getHwComposer().mPhysicalDisplayIdMap; } | 
| Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 534 | auto& mutablePrimaryHwcDisplayId() { return getHwComposer().mPrimaryHwcDisplayId; } | 
| Ady Abraham | adc914c | 2021-10-13 17:04:27 -0700 | [diff] [blame] | 535 | auto& mutableActiveDisplayToken() { return mFlinger->mActiveDisplayToken; } | 
| Lloyd Pique | a618d85 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 536 |  | 
| Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 537 | auto fromHandle(const sp<IBinder>& handle) { | 
| Valerie Hau | 09e6005 | 2019-12-15 14:51:15 -0800 | [diff] [blame] | 538 | return mFlinger->fromHandle(handle); | 
|  | 539 | } | 
|  | 540 |  | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 541 | ~TestableSurfaceFlinger() { | 
|  | 542 | // All these pointer and container clears help ensure that GMock does | 
|  | 543 | // not report a leaked object, since the SurfaceFlinger instance may | 
|  | 544 | // still be referenced by something despite our best efforts to destroy | 
|  | 545 | // it after each test is done. | 
|  | 546 | mutableDisplays().clear(); | 
| Ady Abraham | 2939f09 | 2019-03-04 17:44:06 -0800 | [diff] [blame] | 547 | mutableCurrentState().displays.clear(); | 
|  | 548 | mutableDrawingState().displays.clear(); | 
| Pablo Gamito | 5cfc6e5 | 2020-09-10 11:18:03 +0000 | [diff] [blame] | 549 | mutableInterceptor().clear(); | 
| Lloyd Pique | 2eb71eb | 2019-08-13 13:23:03 -0700 | [diff] [blame] | 550 | mFlinger->mScheduler.reset(); | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 551 | mFlinger->mCompositionEngine->setHwComposer(std::unique_ptr<HWComposer>()); | 
| Lloyd Pique | b97e04f | 2018-10-18 17:07:05 -0700 | [diff] [blame] | 552 | mFlinger->mCompositionEngine->setRenderEngine( | 
|  | 553 | std::unique_ptr<renderengine::RenderEngine>()); | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 554 | } | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 555 |  | 
| Lloyd Pique | a618d85 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 556 | /* ------------------------------------------------------------------------ | 
|  | 557 | * Wrapper classes for Read-write access to private data to set up | 
|  | 558 | * preconditions and assert post-conditions. | 
|  | 559 | */ | 
| Ana Krulec | 4593b69 | 2019-01-11 22:07:25 -0800 | [diff] [blame] | 560 | struct HWC2Display : public HWC2::impl::Display { | 
| Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 561 | HWC2Display( | 
|  | 562 | Hwc2::Composer& composer, | 
|  | 563 | const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>& | 
|  | 564 | capabilities, | 
|  | 565 | hal::HWDisplayId id, hal::DisplayType type) | 
| Peiyong Lin | 74ca2f4 | 2019-01-14 19:36:57 -0800 | [diff] [blame] | 566 | : HWC2::impl::Display(composer, capabilities, id, type) {} | 
| Lloyd Pique | a618d85 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 567 | ~HWC2Display() { | 
|  | 568 | // Prevents a call to disable vsyncs. | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 569 | mType = hal::DisplayType::INVALID; | 
| Lloyd Pique | a618d85 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 570 | } | 
|  | 571 |  | 
|  | 572 | auto& mutableIsConnected() { return this->mIsConnected; } | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 573 | auto& mutableLayers() { return this->mLayers; } | 
| Lloyd Pique | a618d85 | 2018-01-17 11:52:30 -0800 | [diff] [blame] | 574 | }; | 
|  | 575 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 576 | class FakeHwcDisplayInjector { | 
|  | 577 | public: | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 578 | static constexpr hal::HWDisplayId DEFAULT_HWC_DISPLAY_ID = 1000; | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 579 | static constexpr ui::Size DEFAULT_RESOLUTION{1920, 1280}; | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 580 | static constexpr int32_t DEFAULT_VSYNC_PERIOD = 16'666'667; | 
| Ady Abraham | 2139f73 | 2019-11-13 18:56:40 -0800 | [diff] [blame] | 581 | static constexpr int32_t DEFAULT_CONFIG_GROUP = 7; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 582 | static constexpr int32_t DEFAULT_DPI = 320; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 583 | static constexpr hal::HWConfigId DEFAULT_ACTIVE_CONFIG = 0; | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 584 | static constexpr hal::PowerMode DEFAULT_POWER_MODE = hal::PowerMode::ON; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 585 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 586 | FakeHwcDisplayInjector(HalDisplayId displayId, hal::DisplayType hwcDisplayType, | 
|  | 587 | bool isPrimary) | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 588 | : mDisplayId(displayId), mHwcDisplayType(hwcDisplayType), mIsPrimary(isPrimary) {} | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 589 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 590 | auto& setHwcDisplayId(hal::HWDisplayId displayId) { | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 591 | mHwcDisplayId = displayId; | 
|  | 592 | return *this; | 
|  | 593 | } | 
|  | 594 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 595 | auto& setResolution(ui::Size resolution) { | 
|  | 596 | mResolution = resolution; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 597 | return *this; | 
|  | 598 | } | 
|  | 599 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 600 | auto& setVsyncPeriod(nsecs_t vsyncPeriod) { | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 601 | mVsyncPeriod = vsyncPeriod; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 602 | return *this; | 
|  | 603 | } | 
|  | 604 |  | 
|  | 605 | auto& setDpiX(int32_t dpi) { | 
|  | 606 | mDpiX = dpi; | 
|  | 607 | return *this; | 
|  | 608 | } | 
|  | 609 |  | 
|  | 610 | auto& setDpiY(int32_t dpi) { | 
|  | 611 | mDpiY = dpi; | 
|  | 612 | return *this; | 
|  | 613 | } | 
|  | 614 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 615 | auto& setActiveConfig(hal::HWConfigId config) { | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 616 | mActiveConfig = config; | 
|  | 617 | return *this; | 
|  | 618 | } | 
|  | 619 |  | 
| Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 620 | auto& setCapabilities( | 
|  | 621 | const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>* | 
|  | 622 | capabilities) { | 
| Lloyd Pique | e22f033 | 2018-07-16 16:35:56 -0700 | [diff] [blame] | 623 | mCapabilities = capabilities; | 
|  | 624 | return *this; | 
|  | 625 | } | 
|  | 626 |  | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 627 | auto& setPowerMode(hal::PowerMode mode) { | 
| Peiyong Lin | 1336e6e | 2019-05-28 09:23:50 -0700 | [diff] [blame] | 628 | mPowerMode = mode; | 
|  | 629 | return *this; | 
|  | 630 | } | 
|  | 631 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 632 | void inject(TestableSurfaceFlinger* flinger, Hwc2::mock::Composer* composer) { | 
|  | 633 | using ::testing::_; | 
|  | 634 | using ::testing::DoAll; | 
|  | 635 | using ::testing::Return; | 
|  | 636 | using ::testing::SetArgPointee; | 
|  | 637 |  | 
| Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 638 | static const std::unordered_set< | 
|  | 639 | aidl::android::hardware::graphics::composer3::Capability> | 
|  | 640 | defaultCapabilities; | 
| Lloyd Pique | e22f033 | 2018-07-16 16:35:56 -0700 | [diff] [blame] | 641 | if (mCapabilities == nullptr) mCapabilities = &defaultCapabilities; | 
|  | 642 |  | 
|  | 643 | // Caution - Make sure that any values passed by reference here do | 
|  | 644 | // not refer to an instance owned by FakeHwcDisplayInjector. This | 
|  | 645 | // class has temporary lifetime, while the constructed HWC2::Display | 
|  | 646 | // is much longer lived. | 
| Peiyong Lin | 74ca2f4 | 2019-01-14 19:36:57 -0800 | [diff] [blame] | 647 | auto display = std::make_unique<HWC2Display>(*composer, *mCapabilities, mHwcDisplayId, | 
|  | 648 | mHwcDisplayType); | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 649 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 650 | display->mutableIsConnected() = true; | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 651 | display->setPowerMode(mPowerMode); | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 652 | flinger->mutableHwcDisplayData()[mDisplayId].hwcDisplay = std::move(display); | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 653 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 654 | EXPECT_CALL(*composer, getDisplayConfigs(mHwcDisplayId, _)) | 
|  | 655 | .WillRepeatedly( | 
|  | 656 | DoAll(SetArgPointee<1>(std::vector<hal::HWConfigId>{mActiveConfig}), | 
|  | 657 | Return(hal::Error::NONE))); | 
|  | 658 |  | 
|  | 659 | EXPECT_CALL(*composer, | 
|  | 660 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::WIDTH, _)) | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 661 | .WillRepeatedly(DoAll(SetArgPointee<3>(mResolution.getWidth()), | 
|  | 662 | Return(hal::Error::NONE))); | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 663 |  | 
|  | 664 | EXPECT_CALL(*composer, | 
|  | 665 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::HEIGHT, | 
|  | 666 | _)) | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 667 | .WillRepeatedly(DoAll(SetArgPointee<3>(mResolution.getHeight()), | 
|  | 668 | Return(hal::Error::NONE))); | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 669 |  | 
|  | 670 | EXPECT_CALL(*composer, | 
|  | 671 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, | 
|  | 672 | hal::Attribute::VSYNC_PERIOD, _)) | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 673 | .WillRepeatedly(DoAll(SetArgPointee<3>(static_cast<int32_t>(mVsyncPeriod)), | 
|  | 674 | Return(hal::Error::NONE))); | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 675 |  | 
|  | 676 | EXPECT_CALL(*composer, | 
|  | 677 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::DPI_X, _)) | 
|  | 678 | .WillRepeatedly(DoAll(SetArgPointee<3>(mDpiX), Return(hal::Error::NONE))); | 
|  | 679 |  | 
|  | 680 | EXPECT_CALL(*composer, | 
|  | 681 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::DPI_Y, _)) | 
|  | 682 | .WillRepeatedly(DoAll(SetArgPointee<3>(mDpiY), Return(hal::Error::NONE))); | 
|  | 683 |  | 
|  | 684 | EXPECT_CALL(*composer, | 
|  | 685 | getDisplayAttribute(mHwcDisplayId, mActiveConfig, | 
|  | 686 | hal::Attribute::CONFIG_GROUP, _)) | 
|  | 687 | .WillRepeatedly( | 
|  | 688 | DoAll(SetArgPointee<3>(mConfigGroup), Return(hal::Error::NONE))); | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 689 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 690 | if (mHwcDisplayType == hal::DisplayType::PHYSICAL) { | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 691 | const auto physicalId = PhysicalDisplayId::tryCast(mDisplayId); | 
|  | 692 | LOG_ALWAYS_FATAL_IF(!physicalId); | 
|  | 693 | flinger->mutableHwcPhysicalDisplayIdMap().emplace(mHwcDisplayId, *physicalId); | 
| Marin Shalamanov | 6e84017 | 2020-12-14 22:13:28 +0100 | [diff] [blame] | 694 | if (mIsPrimary) { | 
| Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 695 | flinger->mutablePrimaryHwcDisplayId() = mHwcDisplayId; | 
| Marin Shalamanov | 6e84017 | 2020-12-14 22:13:28 +0100 | [diff] [blame] | 696 | } else { | 
| Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 697 | // If there is an external HWC display, there should always be a primary ID | 
| Marin Shalamanov | 6e84017 | 2020-12-14 22:13:28 +0100 | [diff] [blame] | 698 | // as well. Set it to some arbitrary value. | 
| Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 699 | auto& primaryId = flinger->mutablePrimaryHwcDisplayId(); | 
|  | 700 | if (!primaryId) primaryId = mHwcDisplayId - 1; | 
| Marin Shalamanov | 6e84017 | 2020-12-14 22:13:28 +0100 | [diff] [blame] | 701 | } | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 702 | } | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 703 | } | 
|  | 704 |  | 
|  | 705 | private: | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 706 | const HalDisplayId mDisplayId; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 707 | const hal::DisplayType mHwcDisplayType; | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 708 | const bool mIsPrimary; | 
|  | 709 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 710 | hal::HWDisplayId mHwcDisplayId = DEFAULT_HWC_DISPLAY_ID; | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 711 | ui::Size mResolution = DEFAULT_RESOLUTION; | 
|  | 712 | nsecs_t mVsyncPeriod = DEFAULT_VSYNC_PERIOD; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 713 | int32_t mDpiX = DEFAULT_DPI; | 
|  | 714 | int32_t mDpiY = DEFAULT_DPI; | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 715 | int32_t mConfigGroup = DEFAULT_CONFIG_GROUP; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 716 | hal::HWConfigId mActiveConfig = DEFAULT_ACTIVE_CONFIG; | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 717 | hal::PowerMode mPowerMode = DEFAULT_POWER_MODE; | 
| Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 718 | const std::unordered_set<aidl::android::hardware::graphics::composer3::Capability>* | 
|  | 719 | mCapabilities = nullptr; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 720 | }; | 
|  | 721 |  | 
|  | 722 | class FakeDisplayDeviceInjector { | 
|  | 723 | public: | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 724 | FakeDisplayDeviceInjector(TestableSurfaceFlinger& flinger, | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 725 | std::shared_ptr<compositionengine::Display> display, | 
| Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 726 | std::optional<ui::DisplayConnectionType> connectionType, | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 727 | std::optional<hal::HWDisplayId> hwcDisplayId, bool isPrimary) | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 728 | : mFlinger(flinger), | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 729 | mCreationArgs(flinger.mFlinger, flinger.mFlinger->getHwComposer(), mDisplayToken, | 
|  | 730 | display), | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 731 | mConnectionType(connectionType), | 
| Marin Shalamanov | 700e639 | 2020-02-12 20:22:26 +0100 | [diff] [blame] | 732 | mHwcDisplayId(hwcDisplayId) { | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 733 | mCreationArgs.isPrimary = isPrimary; | 
| linpeter | 1c69cd3 | 2022-07-13 19:20:48 +0800 | [diff] [blame] | 734 | mCreationArgs.initialPowerMode = hal::PowerMode::ON; | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 735 | } | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 736 |  | 
|  | 737 | sp<IBinder> token() const { return mDisplayToken; } | 
|  | 738 |  | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 739 | auto physicalDisplay() const { | 
|  | 740 | return ftl::Optional(mCreationArgs.compositionDisplay->getDisplayId()) | 
|  | 741 | .and_then(&PhysicalDisplayId::tryCast) | 
|  | 742 | .and_then(display::getPhysicalDisplay(mFlinger.physicalDisplays())); | 
|  | 743 | } | 
|  | 744 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 745 | DisplayDeviceState& mutableDrawingDisplayState() { | 
|  | 746 | return mFlinger.mutableDrawingState().displays.editValueFor(mDisplayToken); | 
|  | 747 | } | 
|  | 748 |  | 
|  | 749 | DisplayDeviceState& mutableCurrentDisplayState() { | 
|  | 750 | return mFlinger.mutableCurrentState().displays.editValueFor(mDisplayToken); | 
|  | 751 | } | 
|  | 752 |  | 
| Lloyd Pique | 9d9cf40 | 2018-02-16 17:47:13 -0800 | [diff] [blame] | 753 | const auto& getDrawingDisplayState() { | 
|  | 754 | return mFlinger.mutableDrawingState().displays.valueFor(mDisplayToken); | 
|  | 755 | } | 
|  | 756 |  | 
|  | 757 | const auto& getCurrentDisplayState() { | 
|  | 758 | return mFlinger.mutableCurrentState().displays.valueFor(mDisplayToken); | 
|  | 759 | } | 
|  | 760 |  | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 761 | const sp<DisplayDevice>& mutableDisplayDevice() { | 
|  | 762 | return mFlinger.mutableDisplays().get(mDisplayToken)->get(); | 
|  | 763 | } | 
| Lloyd Pique | 9d9cf40 | 2018-02-16 17:47:13 -0800 | [diff] [blame] | 764 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 765 | // If `configs` is nullptr, the injector creates RefreshRateConfigs from the `modes`. | 
|  | 766 | // Otherwise, it uses `configs`, which the caller must create using the same `modes`. | 
|  | 767 | // | 
|  | 768 | // TODO(b/182939859): Once `modes` can be retrieved from RefreshRateConfigs, remove | 
|  | 769 | // the `configs` parameter in favor of an alternative setRefreshRateConfigs API. | 
|  | 770 | auto& setDisplayModes(DisplayModes modes, DisplayModeId activeModeId, | 
|  | 771 | std::shared_ptr<scheduler::RefreshRateConfigs> configs = nullptr) { | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 772 | mDisplayModes = std::move(modes); | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 773 | mCreationArgs.activeModeId = activeModeId; | 
|  | 774 | mCreationArgs.refreshRateConfigs = std::move(configs); | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 775 | return *this; | 
|  | 776 | } | 
|  | 777 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 778 | auto& setNativeWindow(const sp<ANativeWindow>& nativeWindow) { | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 779 | mCreationArgs.nativeWindow = nativeWindow; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 780 | return *this; | 
|  | 781 | } | 
|  | 782 |  | 
| Lloyd Pique | 542307f | 2018-10-19 13:24:08 -0700 | [diff] [blame] | 783 | auto& setDisplaySurface(const sp<compositionengine::DisplaySurface>& displaySurface) { | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 784 | mCreationArgs.displaySurface = displaySurface; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 785 | return *this; | 
|  | 786 | } | 
|  | 787 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 788 | auto& setSecure(bool secure) { | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 789 | mCreationArgs.isSecure = secure; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 790 | return *this; | 
|  | 791 | } | 
|  | 792 |  | 
| Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 793 | auto& setPowerMode(hal::PowerMode mode) { | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 794 | mCreationArgs.initialPowerMode = mode; | 
| Lloyd Pique | d6b579f | 2018-04-06 15:29:10 -0700 | [diff] [blame] | 795 | return *this; | 
|  | 796 | } | 
|  | 797 |  | 
| Valerie Hau | 9758ae0 | 2018-10-09 16:05:09 -0700 | [diff] [blame] | 798 | auto& setHwcColorModes( | 
|  | 799 | const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> | 
|  | 800 | hwcColorModes) { | 
|  | 801 | mCreationArgs.hwcColorModes = hwcColorModes; | 
|  | 802 | return *this; | 
|  | 803 | } | 
|  | 804 |  | 
|  | 805 | auto& setHasWideColorGamut(bool hasWideColorGamut) { | 
|  | 806 | mCreationArgs.hasWideColorGamut = hasWideColorGamut; | 
|  | 807 | return *this; | 
|  | 808 | } | 
|  | 809 |  | 
| Lloyd Pique | 3305047 | 2019-12-19 17:12:44 -0800 | [diff] [blame] | 810 | auto& setPhysicalOrientation(ui::Rotation orientation) { | 
|  | 811 | mCreationArgs.physicalOrientation = orientation; | 
|  | 812 | return *this; | 
|  | 813 | } | 
|  | 814 |  | 
| Ady Abraham | 690f461 | 2021-07-01 23:24:03 -0700 | [diff] [blame] | 815 | sp<DisplayDevice> inject() NO_THREAD_SAFETY_ANALYSIS { | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 816 | const auto displayId = mCreationArgs.compositionDisplay->getDisplayId(); | 
|  | 817 |  | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 818 | auto& modes = mDisplayModes; | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 819 | auto& activeModeId = mCreationArgs.activeModeId; | 
|  | 820 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 821 | if (displayId && !mCreationArgs.refreshRateConfigs) { | 
|  | 822 | if (const auto physicalId = PhysicalDisplayId::tryCast(*displayId)) { | 
|  | 823 | if (modes.empty()) { | 
|  | 824 | constexpr DisplayModeId kModeId{0}; | 
|  | 825 | DisplayModePtr mode = | 
|  | 826 | DisplayMode::Builder(FakeHwcDisplayInjector::DEFAULT_ACTIVE_CONFIG) | 
|  | 827 | .setId(kModeId) | 
|  | 828 | .setPhysicalDisplayId(*physicalId) | 
|  | 829 | .setResolution(FakeHwcDisplayInjector::DEFAULT_RESOLUTION) | 
|  | 830 | .setVsyncPeriod( | 
|  | 831 | FakeHwcDisplayInjector::DEFAULT_VSYNC_PERIOD) | 
|  | 832 | .setDpiX(FakeHwcDisplayInjector::DEFAULT_DPI) | 
|  | 833 | .setDpiY(FakeHwcDisplayInjector::DEFAULT_DPI) | 
|  | 834 | .setGroup(FakeHwcDisplayInjector::DEFAULT_CONFIG_GROUP) | 
|  | 835 | .build(); | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 836 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 837 | modes = ftl::init::map(kModeId, std::move(mode)); | 
|  | 838 | activeModeId = kModeId; | 
|  | 839 | } | 
|  | 840 |  | 
|  | 841 | mCreationArgs.refreshRateConfigs = | 
|  | 842 | std::make_shared<scheduler::RefreshRateConfigs>(modes, activeModeId); | 
|  | 843 | } | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 844 | } | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 845 |  | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 846 | sp<DisplayDevice> display = sp<DisplayDevice>::make(mCreationArgs); | 
|  | 847 | mFlinger.mutableDisplays().emplace_or_replace(mDisplayToken, display); | 
|  | 848 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 849 | DisplayDeviceState state; | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 850 | state.isSecure = mCreationArgs.isSecure; | 
|  | 851 |  | 
|  | 852 | if (mConnectionType) { | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 853 | LOG_ALWAYS_FATAL_IF(!displayId); | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 854 | const auto physicalId = PhysicalDisplayId::tryCast(*displayId); | 
|  | 855 | LOG_ALWAYS_FATAL_IF(!physicalId); | 
| Marin Shalamanov | 700e639 | 2020-02-12 20:22:26 +0100 | [diff] [blame] | 856 | LOG_ALWAYS_FATAL_IF(!mHwcDisplayId); | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 857 |  | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 858 | const auto activeMode = modes.get(activeModeId); | 
|  | 859 | LOG_ALWAYS_FATAL_IF(!activeMode); | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 860 |  | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 861 | state.physical = {.id = *physicalId, | 
| Marin Shalamanov | c7e9f82 | 2021-11-16 20:07:55 +0100 | [diff] [blame] | 862 | .hwcDisplayId = *mHwcDisplayId, | 
| Dominik Laskowski | b0054a2 | 2022-03-03 09:03:06 -0800 | [diff] [blame] | 863 | .activeMode = activeMode->get()}; | 
| Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 864 |  | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 865 | const auto it = mFlinger.mutablePhysicalDisplays() | 
|  | 866 | .emplace_or_replace(*physicalId, mDisplayToken, *physicalId, | 
|  | 867 | *mConnectionType, std::move(modes), | 
|  | 868 | std::nullopt) | 
|  | 869 | .first; | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 870 |  | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 871 | display->setActiveMode(activeModeId, it->second.snapshot()); | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 872 | } | 
| Dominik Laskowski | eb62731 | 2022-04-07 09:13:16 -0700 | [diff] [blame] | 873 |  | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 874 | mFlinger.mutableCurrentState().displays.add(mDisplayToken, state); | 
|  | 875 | mFlinger.mutableDrawingState().displays.add(mDisplayToken, state); | 
|  | 876 |  | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 877 | return display; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 878 | } | 
|  | 879 |  | 
|  | 880 | private: | 
|  | 881 | TestableSurfaceFlinger& mFlinger; | 
| Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 882 | sp<BBinder> mDisplayToken = sp<BBinder>::make(); | 
| Lloyd Pique | 2eef1d2 | 2018-09-18 21:30:04 -0700 | [diff] [blame] | 883 | DisplayDeviceCreationArgs mCreationArgs; | 
| Dominik Laskowski | b363c4c | 2022-08-02 14:03:41 -0700 | [diff] [blame] | 884 | DisplayModes mDisplayModes; | 
|  | 885 | const std::optional<ui::DisplayConnectionType> mConnectionType; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 886 | const std::optional<hal::HWDisplayId> mHwcDisplayId; | 
| Lloyd Pique | c11e0d3 | 2018-01-22 18:44:59 -0800 | [diff] [blame] | 887 | }; | 
|  | 888 |  | 
| Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 889 | private: | 
| Dominik Laskowski | 08fbd85 | 2022-07-14 08:53:42 -0700 | [diff] [blame] | 890 | static constexpr VsyncId kVsyncId{123}; | 
| Ady Abraham | 302ebed | 2022-03-07 16:03:41 -0800 | [diff] [blame] | 891 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 892 | surfaceflinger::test::Factory mFactory; | 
| Vishnu Nair | 4df8eb6 | 2022-02-17 15:32:02 -0800 | [diff] [blame] | 893 | sp<SurfaceFlinger> mFlinger; | 
| Dominik Laskowski | 83bd771 | 2022-01-07 14:30:53 -0800 | [diff] [blame] | 894 | scheduler::mock::SchedulerCallback mSchedulerCallback; | 
|  | 895 | scheduler::mock::NoOpSchedulerCallback mNoOpSchedulerCallback; | 
| Dominik Laskowski | 068173d | 2021-08-11 17:22:59 -0700 | [diff] [blame] | 896 | scheduler::TestableScheduler* mScheduler = nullptr; | 
| Lloyd Pique | f58625d | 2017-12-19 13:22:33 -0800 | [diff] [blame] | 897 | }; | 
|  | 898 |  | 
|  | 899 | } // namespace android |