blob: 33a02429d0e1d0716a26fb045e7ae86bc5547ddf [file] [log] [blame]
Lloyd Piquef58625d2017-12-19 13:22:33 -08001/*
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
19#include "DisplayDevice.h"
Lloyd Piqued6b579f2018-04-06 15:29:10 -070020#include "Layer.h"
Lloyd Piquef58625d2017-12-19 13:22:33 -080021#include "SurfaceFlinger.h"
22
23namespace android {
24
Lloyd Piquee39cad22017-12-20 17:01:29 -080025class EventThread;
26
Peiyong Lin833074a2018-08-28 11:53:54 -070027namespace renderengine {
Lloyd Piquee39cad22017-12-20 17:01:29 -080028class RenderEngine;
29}
30
31namespace Hwc2 {
32class Composer;
33}
34
Lloyd Piquef58625d2017-12-19 13:22:33 -080035class TestableSurfaceFlinger {
36public:
37 // Extend this as needed for accessing SurfaceFlinger private (and public)
38 // functions.
39
Peiyong Lin833074a2018-08-28 11:53:54 -070040 void setupRenderEngine(std::unique_ptr<renderengine::RenderEngine> renderEngine) {
Lloyd Piquee39cad22017-12-20 17:01:29 -080041 mFlinger->getBE().mRenderEngine = std::move(renderEngine);
42 }
43
44 void setupComposer(std::unique_ptr<Hwc2::Composer> composer) {
45 mFlinger->getBE().mHwc.reset(new HWComposer(std::move(composer)));
46 }
47
Lloyd Pique5b36f3f2018-01-17 11:57:07 -080048 using CreateBufferQueueFunction = SurfaceFlinger::CreateBufferQueueFunction;
Lloyd Pique5b36f3f2018-01-17 11:57:07 -080049 void setCreateBufferQueueFunction(CreateBufferQueueFunction f) {
50 mFlinger->mCreateBufferQueue = f;
51 }
52
Lloyd Pique0b1fe702018-01-22 18:03:16 -080053 using CreateNativeWindowSurfaceFunction = SurfaceFlinger::CreateNativeWindowSurfaceFunction;
54 void setCreateNativeWindowSurface(CreateNativeWindowSurfaceFunction f) {
55 mFlinger->mCreateNativeWindowSurface = f;
56 }
57
58 using HotplugEvent = SurfaceFlinger::HotplugEvent;
59
Lloyd Piqued6b579f2018-04-06 15:29:10 -070060 auto& mutableLayerCurrentState(sp<Layer> layer) { return layer->mCurrentState; }
61 auto& mutableLayerDrawingState(sp<Layer> layer) { return layer->mDrawingState; }
62
63 void setLayerSidebandStream(sp<Layer> layer, sp<NativeHandle> sidebandStream) {
64 layer->getBE().compositionInfo.hwc.sidebandStream = sidebandStream;
65 }
66
67 void setLayerCompositionType(sp<Layer> layer, HWC2::Composition type) {
68 layer->getBE().mHwcLayers[DisplayDevice::DISPLAY_PRIMARY].compositionType = type;
69 };
70
71 void setLayerPotentialCursor(sp<Layer> layer, bool potentialCursor) {
72 layer->mPotentialCursor = potentialCursor;
73 }
74
Lloyd Piquef58625d2017-12-19 13:22:33 -080075 /* ------------------------------------------------------------------------
76 * Forwarding for functions being tested
77 */
Lloyd Pique0b1fe702018-01-22 18:03:16 -080078
Lloyd Piquea482f992018-01-22 19:00:34 -080079 auto createDisplay(const String8& displayName, bool secure) {
80 return mFlinger->createDisplay(displayName, secure);
81 }
82
Dominik Laskowskieecd6592018-05-29 10:25:41 -070083 auto destroyDisplay(const sp<IBinder>& displayToken) {
84 return mFlinger->destroyDisplay(displayToken);
85 }
Lloyd Piquea482f992018-01-22 19:00:34 -080086
Lloyd Piqued6fbb8a2018-01-22 19:08:36 -080087 auto resetDisplayState() { return mFlinger->resetDisplayState(); }
88
Dominik Laskowski7e045462018-05-30 13:02:02 -070089 auto setupNewDisplayDeviceInternal(const wp<IBinder>& displayToken, int32_t displayId,
Lloyd Piquec11e0d32018-01-22 18:44:59 -080090 const DisplayDeviceState& state,
91 const sp<DisplaySurface>& dispSurface,
92 const sp<IGraphicBufferProducer>& producer) {
Dominik Laskowski7e045462018-05-30 13:02:02 -070093 return mFlinger->setupNewDisplayDeviceInternal(displayToken, displayId, state, dispSurface,
Lloyd Piquec11e0d32018-01-22 18:44:59 -080094 producer);
95 }
96
Lloyd Pique0b1fe702018-01-22 18:03:16 -080097 auto handleTransactionLocked(uint32_t transactionFlags) {
98 return mFlinger->handleTransactionLocked(transactionFlags);
99 }
Lloyd Piquef58625d2017-12-19 13:22:33 -0800100
Lloyd Pique6cf11032018-01-22 18:57:44 -0800101 auto onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
102 HWC2::Connection connection) {
103 return mFlinger->onHotplugReceived(sequenceId, display, connection);
104 }
105
Lloyd Pique9d9cf402018-02-16 17:47:13 -0800106 auto setDisplayStateLocked(const DisplayState& s) { return mFlinger->setDisplayStateLocked(s); }
107
Lloyd Pique86016da2018-03-01 16:09:38 -0800108 auto onInitializeDisplays() { return mFlinger->onInitializeDisplays(); }
109
Dominik Laskowskia2edf612018-06-01 13:15:16 -0700110 auto setPowerModeInternal(const sp<DisplayDevice>& display, int mode,
111 bool stateLockHeld = false) {
112 return mFlinger->setPowerModeInternal(display, mode, stateLockHeld);
Lloyd Pique7d4aa6c2018-03-01 16:36:35 -0800113 }
114
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700115 auto onMessageReceived(int32_t what) { return mFlinger->onMessageReceived(what); }
116
117 auto captureScreenImplLocked(const RenderArea& renderArea,
118 TraverseLayersFunction traverseLayers, ANativeWindowBuffer* buffer,
119 bool useIdentityTransform, bool forSystem, int* outSyncFd) {
120 return mFlinger->captureScreenImplLocked(renderArea, traverseLayers, buffer,
121 useIdentityTransform, forSystem, outSyncFd);
122 }
123
124 auto traverseLayersInDisplay(const sp<const DisplayDevice>& display, int32_t minLayerZ,
125 int32_t maxLayerZ, const LayerVector::Visitor& visitor) {
126 return mFlinger->SurfaceFlinger::traverseLayersInDisplay(display, minLayerZ, maxLayerZ,
127 visitor);
128 }
129
Lloyd Pique86016da2018-03-01 16:09:38 -0800130 /* ------------------------------------------------------------------------
131 * Read-only access to private data to assert post-conditions.
132 */
133
134 const auto& getAnimFrameTracker() const { return mFlinger->mAnimFrameTracker; }
Lloyd Pique7d4aa6c2018-03-01 16:36:35 -0800135 const auto& getHasPoweredOff() const { return mFlinger->mHasPoweredOff; }
136 const auto& getHWVsyncAvailable() const { return mFlinger->mHWVsyncAvailable; }
137 const auto& getVisibleRegionsDirty() const { return mFlinger->mVisibleRegionsDirty; }
138
Lloyd Pique86016da2018-03-01 16:09:38 -0800139 const auto& getCompositorTiming() const { return mFlinger->getBE().mCompositorTiming; }
140
Lloyd Piquef58625d2017-12-19 13:22:33 -0800141 /* ------------------------------------------------------------------------
142 * Read-write access to private data to set up preconditions and assert
143 * post-conditions.
144 */
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800145
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800146 auto& mutableHasWideColorDisplay() { return SurfaceFlinger::hasWideColorDisplay; }
Chia-I Wu304d9cd2018-08-27 14:38:14 -0700147 auto& mutablePrimaryDisplayOrientation() { return SurfaceFlinger::primaryDisplayOrientation; }
Peiyong Lin13effd12018-07-24 17:01:47 -0700148 auto& mutableUseColorManagement() { return SurfaceFlinger::useColorManagement; }
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800149
Lloyd Piquee39cad22017-12-20 17:01:29 -0800150 auto& mutableCurrentState() { return mFlinger->mCurrentState; }
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800151 auto& mutableDisplayColorSetting() { return mFlinger->mDisplayColorSetting; }
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700152 auto& mutableDisplays() { return mFlinger->mDisplays; }
153 auto& mutableDisplayTokens() { return mFlinger->mDisplayTokens; }
Lloyd Piquee39cad22017-12-20 17:01:29 -0800154 auto& mutableDrawingState() { return mFlinger->mDrawingState; }
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800155 auto& mutableEventControlThread() { return mFlinger->mEventControlThread; }
Lloyd Piquee39cad22017-12-20 17:01:29 -0800156 auto& mutableEventQueue() { return mFlinger->mEventQueue; }
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800157 auto& mutableEventThread() { return mFlinger->mEventThread; }
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700158 auto& mutableGeometryInvalid() { return mFlinger->mGeometryInvalid; }
Lloyd Piqued6fbb8a2018-01-22 19:08:36 -0800159 auto& mutableHWVsyncAvailable() { return mFlinger->mHWVsyncAvailable; }
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800160 auto& mutableInterceptor() { return mFlinger->mInterceptor; }
Lloyd Pique6cf11032018-01-22 18:57:44 -0800161 auto& mutableMainThreadId() { return mFlinger->mMainThreadId; }
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800162 auto& mutablePendingHotplugEvents() { return mFlinger->mPendingHotplugEvents; }
Lloyd Pique41be5d22018-06-21 13:11:48 -0700163 auto& mutablePrimaryDispSync() { return mFlinger->mPrimaryDispSync; }
Lloyd Piqued6fbb8a2018-01-22 19:08:36 -0800164 auto& mutablePrimaryHWVsyncEnabled() { return mFlinger->mPrimaryHWVsyncEnabled; }
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700165 auto& mutableTexturePool() { return mFlinger->mTexturePool; }
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800166 auto& mutableTransactionFlags() { return mFlinger->mTransactionFlags; }
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800167 auto& mutableUseHwcVirtualDisplays() { return mFlinger->mUseHwcVirtualDisplays; }
Lloyd Piquee39cad22017-12-20 17:01:29 -0800168
Lloyd Pique6cf11032018-01-22 18:57:44 -0800169 auto& mutableComposerSequenceId() { return mFlinger->getBE().mComposerSequenceId; }
Lloyd Piquea618d852018-01-17 11:52:30 -0800170 auto& mutableHwcDisplayData() { return mFlinger->getBE().mHwc->mDisplayData; }
171 auto& mutableHwcDisplaySlots() { return mFlinger->getBE().mHwc->mHwcDisplaySlots; }
172
Lloyd Piquee39cad22017-12-20 17:01:29 -0800173 ~TestableSurfaceFlinger() {
174 // All these pointer and container clears help ensure that GMock does
175 // not report a leaked object, since the SurfaceFlinger instance may
176 // still be referenced by something despite our best efforts to destroy
177 // it after each test is done.
178 mutableDisplays().clear();
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800179 mutableEventControlThread().reset();
180 mutableEventQueue().reset();
Lloyd Piquee39cad22017-12-20 17:01:29 -0800181 mutableEventThread().reset();
Lloyd Pique0b1fe702018-01-22 18:03:16 -0800182 mutableInterceptor().reset();
Lloyd Pique41be5d22018-06-21 13:11:48 -0700183 mutablePrimaryDispSync().reset();
Lloyd Piquee39cad22017-12-20 17:01:29 -0800184 mFlinger->getBE().mHwc.reset();
185 mFlinger->getBE().mRenderEngine.reset();
186 }
Lloyd Piquef58625d2017-12-19 13:22:33 -0800187
Lloyd Piquea618d852018-01-17 11:52:30 -0800188 /* ------------------------------------------------------------------------
189 * Wrapper classes for Read-write access to private data to set up
190 * preconditions and assert post-conditions.
191 */
Michael Wright5d22d4f2018-06-21 02:50:34 +0100192 class FakePowerAdvisor : public Hwc2::PowerAdvisor {
193 public:
194 FakePowerAdvisor() = default;
195 ~FakePowerAdvisor() override = default;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700196 void setExpensiveRenderingExpected(hwc2_display_t, bool) override {}
Michael Wright5d22d4f2018-06-21 02:50:34 +0100197 };
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800198
Lloyd Piquea618d852018-01-17 11:52:30 -0800199 struct HWC2Display : public HWC2::Display {
Michael Wright5d22d4f2018-06-21 02:50:34 +0100200 HWC2Display(Hwc2::Composer& composer, Hwc2::PowerAdvisor& advisor,
Lloyd Piquea618d852018-01-17 11:52:30 -0800201 const std::unordered_set<HWC2::Capability>& capabilities, hwc2_display_t id,
202 HWC2::DisplayType type)
Michael Wright5d22d4f2018-06-21 02:50:34 +0100203 : HWC2::Display(composer, advisor, capabilities, id, type) {}
Lloyd Piquea618d852018-01-17 11:52:30 -0800204 ~HWC2Display() {
205 // Prevents a call to disable vsyncs.
206 mType = HWC2::DisplayType::Invalid;
207 }
208
209 auto& mutableIsConnected() { return this->mIsConnected; }
210 auto& mutableConfigs() { return this->mConfigs; }
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700211 auto& mutableLayers() { return this->mLayers; }
Lloyd Piquea618d852018-01-17 11:52:30 -0800212 };
213
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800214 class FakeHwcDisplayInjector {
215 public:
216 static constexpr hwc2_display_t DEFAULT_HWC_DISPLAY_ID = 1000;
217 static constexpr int32_t DEFAULT_WIDTH = 1920;
218 static constexpr int32_t DEFAULT_HEIGHT = 1280;
219 static constexpr int32_t DEFAULT_REFRESH_RATE = 16'666'666;
220 static constexpr int32_t DEFAULT_DPI = 320;
221 static constexpr int32_t DEFAULT_ACTIVE_CONFIG = 0;
222
223 FakeHwcDisplayInjector(DisplayDevice::DisplayType type, HWC2::DisplayType hwcDisplayType)
224 : mType(type), mHwcDisplayType(hwcDisplayType) {}
225
226 auto& setHwcDisplayId(hwc2_display_t displayId) {
227 mHwcDisplayId = displayId;
228 return *this;
229 }
230
231 auto& setWidth(int32_t width) {
232 mWidth = width;
233 return *this;
234 }
235
236 auto& setHeight(int32_t height) {
237 mHeight = height;
238 return *this;
239 }
240
241 auto& setRefreshRate(int32_t refreshRate) {
242 mRefreshRate = refreshRate;
243 return *this;
244 }
245
246 auto& setDpiX(int32_t dpi) {
247 mDpiX = dpi;
248 return *this;
249 }
250
251 auto& setDpiY(int32_t dpi) {
252 mDpiY = dpi;
253 return *this;
254 }
255
256 auto& setActiveConfig(int32_t config) {
257 mActiveConfig = config;
258 return *this;
259 }
260
Lloyd Piquee22f0332018-07-16 16:35:56 -0700261 auto& setCapabilities(const std::unordered_set<HWC2::Capability>* capabilities) {
262 mCapabilities = capabilities;
263 return *this;
264 }
265
266 auto& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) {
267 mPowerAdvisor = powerAdvisor;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800268 return *this;
269 }
270
271 void inject(TestableSurfaceFlinger* flinger, Hwc2::Composer* composer) {
Lloyd Piquee22f0332018-07-16 16:35:56 -0700272 static FakePowerAdvisor defaultPowerAdvisor;
273 if (mPowerAdvisor == nullptr) mPowerAdvisor = &defaultPowerAdvisor;
274 static const std::unordered_set<HWC2::Capability> defaultCapabilities;
275 if (mCapabilities == nullptr) mCapabilities = &defaultCapabilities;
276
277 // Caution - Make sure that any values passed by reference here do
278 // not refer to an instance owned by FakeHwcDisplayInjector. This
279 // class has temporary lifetime, while the constructed HWC2::Display
280 // is much longer lived.
281 auto display = std::make_unique<HWC2Display>(*composer, *mPowerAdvisor, *mCapabilities,
Michael Wright5d22d4f2018-06-21 02:50:34 +0100282 mHwcDisplayId, mHwcDisplayType);
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800283
284 auto config = HWC2::Display::Config::Builder(*display, mActiveConfig);
285 config.setWidth(mWidth);
286 config.setHeight(mHeight);
287 config.setVsyncPeriod(mRefreshRate);
288 config.setDpiX(mDpiX);
289 config.setDpiY(mDpiY);
290 display->mutableConfigs().emplace(mActiveConfig, config.build());
291 display->mutableIsConnected() = true;
292
293 ASSERT_TRUE(flinger->mutableHwcDisplayData().size() > static_cast<size_t>(mType));
Dominik Laskowskif9750f22018-06-06 12:24:53 -0700294 flinger->mutableHwcDisplayData()[mType] = HWComposer::DisplayData();
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800295 flinger->mutableHwcDisplayData()[mType].hwcDisplay = display.get();
296 flinger->mutableHwcDisplaySlots().emplace(mHwcDisplayId, mType);
297
298 flinger->mFakeHwcDisplays.push_back(std::move(display));
299 }
300
301 private:
302 DisplayDevice::DisplayType mType;
303 HWC2::DisplayType mHwcDisplayType;
304 hwc2_display_t mHwcDisplayId = DEFAULT_HWC_DISPLAY_ID;
305 int32_t mWidth = DEFAULT_WIDTH;
306 int32_t mHeight = DEFAULT_HEIGHT;
307 int32_t mRefreshRate = DEFAULT_REFRESH_RATE;
308 int32_t mDpiX = DEFAULT_DPI;
309 int32_t mDpiY = DEFAULT_DPI;
310 int32_t mActiveConfig = DEFAULT_ACTIVE_CONFIG;
Lloyd Piquee22f0332018-07-16 16:35:56 -0700311 const std::unordered_set<HWC2::Capability>* mCapabilities = nullptr;
312 Hwc2::PowerAdvisor* mPowerAdvisor = nullptr;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800313 };
314
315 class FakeDisplayDeviceInjector {
316 public:
317 FakeDisplayDeviceInjector(TestableSurfaceFlinger& flinger, DisplayDevice::DisplayType type,
Dominik Laskowski7e045462018-05-30 13:02:02 -0700318 int32_t displayId)
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700319 : mFlinger(flinger),
320 mCreationArgs(flinger.mFlinger.get(), mDisplayToken, type, displayId) {}
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800321
322 sp<IBinder> token() const { return mDisplayToken; }
323
324 DisplayDeviceState& mutableDrawingDisplayState() {
325 return mFlinger.mutableDrawingState().displays.editValueFor(mDisplayToken);
326 }
327
328 DisplayDeviceState& mutableCurrentDisplayState() {
329 return mFlinger.mutableCurrentState().displays.editValueFor(mDisplayToken);
330 }
331
Lloyd Pique9d9cf402018-02-16 17:47:13 -0800332 const auto& getDrawingDisplayState() {
333 return mFlinger.mutableDrawingState().displays.valueFor(mDisplayToken);
334 }
335
336 const auto& getCurrentDisplayState() {
337 return mFlinger.mutableCurrentState().displays.valueFor(mDisplayToken);
338 }
339
Dominik Laskowski9fae1022018-05-29 13:17:40 -0700340 auto& mutableDisplayDevice() { return mFlinger.mutableDisplays()[mDisplayToken]; }
Lloyd Pique9d9cf402018-02-16 17:47:13 -0800341
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800342 auto& setNativeWindow(const sp<ANativeWindow>& nativeWindow) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700343 mCreationArgs.nativeWindow = nativeWindow;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800344 return *this;
345 }
346
347 auto& setDisplaySurface(const sp<DisplaySurface>& displaySurface) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700348 mCreationArgs.displaySurface = displaySurface;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800349 return *this;
350 }
351
Peiyong Lin833074a2018-08-28 11:53:54 -0700352 auto& setRenderSurface(std::unique_ptr<renderengine::Surface> renderSurface) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700353 mCreationArgs.renderSurface = std::move(renderSurface);
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800354 return *this;
355 }
356
357 auto& setSecure(bool secure) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700358 mCreationArgs.isSecure = secure;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800359 return *this;
360 }
361
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700362 auto& setDisplaySize(int width, int height) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700363 mCreationArgs.displayWidth = width;
364 mCreationArgs.displayHeight = height;
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700365 return *this;
366 }
367
368 auto& setPowerMode(int mode) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700369 mCreationArgs.initialPowerMode = mode;
Lloyd Piqued6b579f2018-04-06 15:29:10 -0700370 return *this;
371 }
372
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800373 sp<DisplayDevice> inject() {
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800374 DisplayDeviceState state;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700375 state.type = mCreationArgs.type;
376 state.isSecure = mCreationArgs.isSecure;
377
378 sp<DisplayDevice> device = new DisplayDevice(std::move(mCreationArgs));
379 mFlinger.mutableDisplays().emplace(mDisplayToken, device);
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800380 mFlinger.mutableCurrentState().displays.add(mDisplayToken, state);
381 mFlinger.mutableDrawingState().displays.add(mDisplayToken, state);
382
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700383 if (state.type >= DisplayDevice::DISPLAY_PRIMARY &&
384 state.type < DisplayDevice::DISPLAY_VIRTUAL) {
385 mFlinger.mutableDisplayTokens()[state.type] = mDisplayToken;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800386 }
387
388 return device;
389 }
390
391 private:
392 TestableSurfaceFlinger& mFlinger;
393 sp<BBinder> mDisplayToken = new BBinder();
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700394 DisplayDeviceCreationArgs mCreationArgs;
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800395 };
396
Lloyd Piqueac648ee2018-01-17 13:42:24 -0800397 sp<SurfaceFlinger> mFlinger = new SurfaceFlinger(SurfaceFlinger::SkipInitialization);
Lloyd Piquec11e0d32018-01-22 18:44:59 -0800398
399 // We need to keep a reference to these so they are properly destroyed.
400 std::vector<std::unique_ptr<HWC2Display>> mFakeHwcDisplays;
Lloyd Piquef58625d2017-12-19 13:22:33 -0800401};
402
403} // namespace android