diff options
Diffstat (limited to 'services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h')
-rw-r--r-- | services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h | 307 |
1 files changed, 99 insertions, 208 deletions
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h index cf67593174..38bc8a19cf 100644 --- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h +++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h @@ -23,15 +23,13 @@ #include <compositionengine/impl/Display.h> #include <compositionengine/impl/OutputLayerCompositionState.h> #include <compositionengine/mock/DisplaySurface.h> -#include <gui/ScreenCaptureResults.h> #include "BufferQueueLayer.h" #include "BufferStateLayer.h" #include "ContainerLayer.h" #include "DisplayDevice.h" #include "EffectLayer.h" -#include "FakeVsyncConfiguration.h" -#include "FrameTracer/FrameTracer.h" +#include "FakePhaseOffsets.h" #include "Layer.h" #include "NativeWindowSurface.h" #include "Scheduler/MessageQueue.h" @@ -41,9 +39,7 @@ #include "SurfaceFlingerDefaultFactory.h" #include "SurfaceInterceptor.h" #include "TestableScheduler.h" -#include "mock/DisplayHardware/MockComposer.h" -#include "mock/MockFrameTimeline.h" -#include "mock/MockFrameTracer.h" +#include "mock/DisplayHardware/MockDisplay.h" namespace android { @@ -69,6 +65,15 @@ class Factory final : public surfaceflinger::Factory { public: ~Factory() = default; + std::unique_ptr<DispSync> createDispSync(const char*, bool) override { + return nullptr; + } + + std::unique_ptr<EventControlThread> createEventControlThread( + std::function<void(bool)>) override { + return nullptr; + } + std::unique_ptr<HWComposer> createHWComposer(const std::string&) override { return nullptr; } @@ -77,18 +82,19 @@ public: return std::make_unique<android::impl::MessageQueue>(); } - std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration( - Fps /*currentRefreshRate*/) override { + std::unique_ptr<scheduler::PhaseConfiguration> createPhaseConfiguration( + const scheduler::RefreshRateConfigs& /*refreshRateConfigs*/) override { return std::make_unique<scheduler::FakePhaseOffsets>(); } - std::unique_ptr<Scheduler> createScheduler(const scheduler::RefreshRateConfigs&, + std::unique_ptr<Scheduler> createScheduler(std::function<void(bool)>, + const scheduler::RefreshRateConfigs&, ISchedulerCallback&) override { return nullptr; } - sp<SurfaceInterceptor> createSurfaceInterceptor() override { - return new android::impl::SurfaceInterceptor(); + std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger* flinger) override { + return std::make_unique<android::impl::SurfaceInterceptor>(flinger); } sp<StartPropertySetThread> createStartPropertySetThread(bool timestampPropertyValue) override { @@ -151,15 +157,6 @@ public: return nullptr; } - std::unique_ptr<FrameTracer> createFrameTracer() override { - return std::make_unique<mock::FrameTracer>(); - } - - std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline( - std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid = 0) override { - return std::make_unique<mock::FrameTimeline>(timeStats, surfaceFlingerPid); - } - using CreateBufferQueueFunction = std::function<void(sp<IGraphicBufferProducer>* /* outProducer */, sp<IGraphicBufferConsumer>* /* outConsumer */, @@ -178,7 +175,7 @@ public: } // namespace surfaceflinger::test -class TestableSurfaceFlinger final : private ISchedulerCallback { +class TestableSurfaceFlinger { public: using HotplugEvent = SurfaceFlinger::HotplugEvent; @@ -201,50 +198,41 @@ public: mFlinger->mCompositionEngine->setTimeStats(timeStats); } - // The ISchedulerCallback argument can be nullptr for a no-op implementation. - void setupScheduler(std::unique_ptr<scheduler::VsyncController> vsyncController, - std::unique_ptr<scheduler::VSyncTracker> vsyncTracker, + void setupScheduler(std::unique_ptr<DispSync> primaryDispSync, + std::unique_ptr<EventControlThread> eventControlThread, std::unique_ptr<EventThread> appEventThread, std::unique_ptr<EventThread> sfEventThread, - ISchedulerCallback* callback = nullptr, bool hasMultipleModes = false) { - DisplayModes modes{DisplayMode::Builder(0) - .setId(DisplayModeId(0)) - .setVsyncPeriod(16'666'667) - .setGroup(0) - .build()}; - - if (hasMultipleModes) { - modes.emplace_back(DisplayMode::Builder(1) - .setId(DisplayModeId(1)) - .setVsyncPeriod(11'111'111) - .setGroup(0) - .build()); - } - - const auto currMode = DisplayModeId(0); - mFlinger->mRefreshRateConfigs = - std::make_unique<scheduler::RefreshRateConfigs>(modes, currMode); - const auto currFps = - mFlinger->mRefreshRateConfigs->getRefreshRateFromModeId(currMode).getFps(); - mFlinger->mRefreshRateStats = - std::make_unique<scheduler::RefreshRateStats>(*mFlinger->mTimeStats, currFps, - /*powerMode=*/hal::PowerMode::OFF); - mFlinger->mVsyncConfiguration = mFactory.createVsyncConfiguration(currFps); - mFlinger->mVsyncModulator = sp<scheduler::VsyncModulator>::make( - mFlinger->mVsyncConfiguration->getCurrentConfigs()); - - mScheduler = new TestableScheduler(std::move(vsyncController), std::move(vsyncTracker), - *mFlinger->mRefreshRateConfigs, *(callback ?: this)); + bool useContentDetectionV2 = false) { + std::vector<std::shared_ptr<const HWC2::Display::Config>> configs{ + HWC2::Display::Config::Builder(mDisplay, 0) + .setVsyncPeriod(int32_t(16666667)) + .setConfigGroup(0) + .build()}; + + mFlinger->mRefreshRateConfigs = std::make_unique< + scheduler::RefreshRateConfigs>(configs, /*currentConfig=*/HwcConfigIndexType(0)); + mFlinger->mRefreshRateStats = std::make_unique< + scheduler::RefreshRateStats>(*mFlinger->mRefreshRateConfigs, *mFlinger->mTimeStats, + /*currentConfig=*/HwcConfigIndexType(0), + /*powerMode=*/hal::PowerMode::OFF); + mFlinger->mPhaseConfiguration = + mFactory.createPhaseConfiguration(*mFlinger->mRefreshRateConfigs); + + mScheduler = + new TestableScheduler(std::move(primaryDispSync), std::move(eventControlThread), + *mFlinger->mRefreshRateConfigs, useContentDetectionV2); mFlinger->mAppConnectionHandle = mScheduler->createConnection(std::move(appEventThread)); mFlinger->mSfConnectionHandle = mScheduler->createConnection(std::move(sfEventThread)); resetScheduler(mScheduler); + + mFlinger->mVSyncModulator.emplace(*mScheduler, mFlinger->mAppConnectionHandle, + mFlinger->mSfConnectionHandle, + mFlinger->mPhaseConfiguration->getCurrentOffsets()); } void resetScheduler(Scheduler* scheduler) { mFlinger->mScheduler.reset(scheduler); } - TestableScheduler& mutableScheduler() const { return *mScheduler; } - using CreateBufferQueueFunction = surfaceflinger::test::Factory::CreateBufferQueueFunction; void setCreateBufferQueueFunction(CreateBufferQueueFunction f) { mFactory.mCreateBufferQueue = f; @@ -260,6 +248,7 @@ public: memcpy(&mFlinger->mInternalDisplayPrimaries, &primaries, sizeof(ui::DisplayPrimaries)); } + static auto& mutableLayerCurrentState(const sp<Layer>& layer) { return layer->mCurrentState; } static auto& mutableLayerDrawingState(const sp<Layer>& layer) { return layer->mDrawingState; } auto& mutableStateLock() { return mFlinger->mStateLock; } @@ -288,10 +277,6 @@ public: layer->mPotentialCursor = potentialCursor; } - static void setLayerDrawingParent(const sp<Layer>& layer, const sp<Layer>& drawingParent) { - layer->mDrawingParent = drawingParent; - } - /* ------------------------------------------------------------------------ * Forwarding for functions being tested */ @@ -304,7 +289,7 @@ public: return mFlinger->destroyDisplay(displayToken); } - void enableHalVirtualDisplays(bool enable) { mFlinger->enableHalVirtualDisplays(enable); } + auto resetDisplayState() NO_THREAD_SAFETY_ANALYSIS { return mFlinger->resetDisplayState(); } auto setupNewDisplayDeviceInternal( const wp<IBinder>& displayToken, @@ -321,8 +306,9 @@ public: return mFlinger->handleTransactionLocked(transactionFlags); } - void onComposerHalHotplug(hal::HWDisplayId hwcDisplayId, hal::Connection connection) { - mFlinger->onComposerHalHotplug(hwcDisplayId, connection); + auto onHotplugReceived(int32_t sequenceId, hal::HWDisplayId display, + hal::Connection connection) { + return mFlinger->onHotplugReceived(sequenceId, display, connection); } auto setDisplayStateLocked(const DisplayState& s) { @@ -335,31 +321,27 @@ public: return mFlinger->onInitializeDisplays(); } - auto notifyPowerBoost(int32_t boostId) { return mFlinger->notifyPowerBoost(boostId); } - // Allow reading display state without locking, as if called on the SF main thread. auto setPowerModeInternal(const sp<DisplayDevice>& display, hal::PowerMode mode) NO_THREAD_SAFETY_ANALYSIS { return mFlinger->setPowerModeInternal(display, mode); } - auto onMessageReceived(int32_t what) { - return mFlinger->onMessageReceived(what, /*vsyncId=*/0, systemTime()); - } + auto onMessageReceived(int32_t what) { return mFlinger->onMessageReceived(what, systemTime()); } - auto renderScreenImplLocked(const RenderArea& renderArea, - SurfaceFlinger::TraverseLayersFunction traverseLayers, - const std::shared_ptr<renderengine::ExternalTexture>& buffer, - bool forSystem, bool regionSampling) { - ScreenCaptureResults captureResults; - return mFlinger->renderScreenImplLocked(renderArea, traverseLayers, buffer, forSystem, - regionSampling, false /* grayscale */, - captureResults); + auto captureScreenImplLocked(const RenderArea& renderArea, + SurfaceFlinger::TraverseLayersFunction traverseLayers, + ANativeWindowBuffer* buffer, bool useIdentityTransform, + bool forSystem, int* outSyncFd, bool regionSampling) { + bool ignored; + return mFlinger->captureScreenImplLocked(renderArea, traverseLayers, buffer, + useIdentityTransform, forSystem, outSyncFd, + regionSampling, ignored); } - auto traverseLayersInLayerStack(ui::LayerStack layerStack, int32_t uid, - const LayerVector::Visitor& visitor) { - return mFlinger->SurfaceFlinger::traverseLayersInLayerStack(layerStack, uid, visitor); + auto traverseLayersInDisplay(const sp<const DisplayDevice>& display, + const LayerVector::Visitor& visitor) { + return mFlinger->SurfaceFlinger::traverseLayersInDisplay(display, visitor); } auto getDisplayNativePrimaries(const sp<IBinder>& displayToken, @@ -367,34 +349,22 @@ public: return mFlinger->SurfaceFlinger::getDisplayNativePrimaries(displayToken, primaries); } - auto& getTransactionQueue() { return mFlinger->mTransactionQueue; } - auto& getPendingTransactionQueue() { return mFlinger->mPendingTransactionQueues; } + auto& getTransactionQueue() { return mFlinger->mTransactionQueues; } - auto setTransactionState( - const FrameTimelineInfo& frameTimelineInfo, const Vector<ComposerState>& states, - const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken, - const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime, - bool isAutoTimestamp, const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, - std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId) { - return mFlinger->setTransactionState(frameTimelineInfo, states, displays, flags, applyToken, - inputWindowCommands, desiredPresentTime, - isAutoTimestamp, uncacheBuffer, hasListenerCallbacks, - listenerCallbacks, transactionId); + auto setTransactionState(const Vector<ComposerState>& states, + const Vector<DisplayState>& displays, uint32_t flags, + const sp<IBinder>& applyToken, + const InputWindowCommands& inputWindowCommands, + int64_t desiredPresentTime, const client_cache_t& uncacheBuffer, + bool hasListenerCallbacks, + std::vector<ListenerCallbacks>& listenerCallbacks) { + return mFlinger->setTransactionState(states, displays, flags, applyToken, + inputWindowCommands, desiredPresentTime, uncacheBuffer, + hasListenerCallbacks, listenerCallbacks); } auto flushTransactionQueues() { return mFlinger->flushTransactionQueues(); }; - auto onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - return mFlinger->onTransact(code, data, reply, flags); - } - - auto getGPUContextPriority() { return mFlinger->getGPUContextPriority(); } - - auto calculateMaxAcquiredBufferCount(Fps refreshRate, - std::chrono::nanoseconds presentLatency) const { - return SurfaceFlinger::calculateMaxAcquiredBufferCount(refreshRate, presentLatency); - } - /* ------------------------------------------------------------------------ * Read-only access to private data to assert post-conditions. */ @@ -409,10 +379,6 @@ public: const auto& getCompositorTiming() const { return mFlinger->getBE().mCompositorTiming; } - mock::FrameTracer* getFrameTracer() const { - return static_cast<mock::FrameTracer*>(mFlinger->mFrameTracer.get()); - } - /* ------------------------------------------------------------------------ * Read-write access to private data to set up preconditions and assert * post-conditions. @@ -433,9 +399,11 @@ public: auto& mutablePhysicalDisplayTokens() { return mFlinger->mPhysicalDisplayTokens; } auto& mutableTexturePool() { return mFlinger->mTexturePool; } auto& mutableTransactionFlags() { return mFlinger->mTransactionFlags; } + auto& mutableUseHwcVirtualDisplays() { return mFlinger->mUseHwcVirtualDisplays; } auto& mutablePowerAdvisor() { return mFlinger->mPowerAdvisor; } auto& mutableDebugDisableHWC() { return mFlinger->mDebugDisableHWC; } + auto& mutableComposerSequenceId() { return mFlinger->getBE().mComposerSequenceId; } auto& mutableHwcDisplayData() { return getHwComposer().mDisplayData; } auto& mutableHwcPhysicalDisplayIdMap() { return getHwComposer().mPhysicalDisplayIdMap; } auto& mutableInternalHwcDisplayId() { return getHwComposer().mInternalHwcDisplayId; } @@ -455,7 +423,7 @@ public: mutableCurrentState().displays.clear(); mutableDrawingState().displays.clear(); mutableEventQueue().reset(); - mutableInterceptor().clear(); + mutableInterceptor().reset(); mFlinger->mScheduler.reset(); mFlinger->mCompositionEngine->setHwComposer(std::unique_ptr<HWComposer>()); mFlinger->mCompositionEngine->setRenderEngine( @@ -477,6 +445,7 @@ public: } auto& mutableIsConnected() { return this->mIsConnected; } + auto& mutableConfigs() { return this->mConfigs; } auto& mutableLayers() { return this->mLayers; } }; @@ -485,14 +454,13 @@ public: static constexpr hal::HWDisplayId DEFAULT_HWC_DISPLAY_ID = 1000; static constexpr int32_t DEFAULT_WIDTH = 1920; static constexpr int32_t DEFAULT_HEIGHT = 1280; - static constexpr int32_t DEFAULT_VSYNC_PERIOD = 16'666'666; + static constexpr int32_t DEFAULT_REFRESH_RATE = 16'666'666; static constexpr int32_t DEFAULT_CONFIG_GROUP = 7; static constexpr int32_t DEFAULT_DPI = 320; static constexpr hal::HWConfigId DEFAULT_ACTIVE_CONFIG = 0; static constexpr hal::PowerMode DEFAULT_POWER_MODE = hal::PowerMode::ON; - FakeHwcDisplayInjector(HalDisplayId displayId, hal::DisplayType hwcDisplayType, - bool isPrimary) + FakeHwcDisplayInjector(DisplayId displayId, hal::DisplayType hwcDisplayType, bool isPrimary) : mDisplayId(displayId), mHwcDisplayType(hwcDisplayType), mIsPrimary(isPrimary) {} auto& setHwcDisplayId(hal::HWDisplayId displayId) { @@ -510,8 +478,8 @@ public: return *this; } - auto& setVsyncPeriod(int32_t vsyncPeriod) { - mVsyncPeriod = vsyncPeriod; + auto& setRefreshRate(int32_t refreshRate) { + mRefreshRate = refreshRate; return *this; } @@ -540,12 +508,7 @@ public: return *this; } - void inject(TestableSurfaceFlinger* flinger, Hwc2::mock::Composer* composer) { - using ::testing::_; - using ::testing::DoAll; - using ::testing::Return; - using ::testing::SetArgPointee; - + void inject(TestableSurfaceFlinger* flinger, Hwc2::Composer* composer) { static const std::unordered_set<hal::Capability> defaultCapabilities; if (mCapabilities == nullptr) mCapabilities = &defaultCapabilities; @@ -556,72 +519,38 @@ public: auto display = std::make_unique<HWC2Display>(*composer, *mCapabilities, mHwcDisplayId, mHwcDisplayType); + auto config = HWC2::Display::Config::Builder(*display, mActiveConfig); + config.setWidth(mWidth); + config.setHeight(mHeight); + config.setVsyncPeriod(mRefreshRate); + config.setDpiX(mDpiX); + config.setDpiY(mDpiY); + config.setConfigGroup(mConfigGroup); + display->mutableConfigs().emplace(static_cast<int32_t>(mActiveConfig), config.build()); display->mutableIsConnected() = true; display->setPowerMode(mPowerMode); - flinger->mutableHwcDisplayData()[mDisplayId].hwcDisplay = std::move(display); - - EXPECT_CALL(*composer, getDisplayConfigs(mHwcDisplayId, _)) - .WillRepeatedly( - DoAll(SetArgPointee<1>(std::vector<hal::HWConfigId>{mActiveConfig}), - Return(hal::Error::NONE))); - - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::WIDTH, _)) - .WillRepeatedly(DoAll(SetArgPointee<3>(mWidth), Return(hal::Error::NONE))); - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::HEIGHT, - _)) - .WillRepeatedly(DoAll(SetArgPointee<3>(mHeight), Return(hal::Error::NONE))); - - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, - hal::Attribute::VSYNC_PERIOD, _)) - .WillRepeatedly( - DoAll(SetArgPointee<3>(mVsyncPeriod), Return(hal::Error::NONE))); - - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::DPI_X, _)) - .WillRepeatedly(DoAll(SetArgPointee<3>(mDpiX), Return(hal::Error::NONE))); - - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, hal::Attribute::DPI_Y, _)) - .WillRepeatedly(DoAll(SetArgPointee<3>(mDpiY), Return(hal::Error::NONE))); - - EXPECT_CALL(*composer, - getDisplayAttribute(mHwcDisplayId, mActiveConfig, - hal::Attribute::CONFIG_GROUP, _)) - .WillRepeatedly( - DoAll(SetArgPointee<3>(mConfigGroup), Return(hal::Error::NONE))); + flinger->mutableHwcDisplayData()[mDisplayId].hwcDisplay = std::move(display); if (mHwcDisplayType == hal::DisplayType::PHYSICAL) { - const auto physicalId = PhysicalDisplayId::tryCast(mDisplayId); - LOG_ALWAYS_FATAL_IF(!physicalId); - flinger->mutableHwcPhysicalDisplayIdMap().emplace(mHwcDisplayId, *physicalId); - if (mIsPrimary) { - flinger->mutableInternalHwcDisplayId() = mHwcDisplayId; - } else { - // If there is an external HWC display there should always be an internal ID - // as well. Set it to some arbitrary value. - auto& internalId = flinger->mutableInternalHwcDisplayId(); - if (!internalId) internalId = mHwcDisplayId - 1; - flinger->mutableExternalHwcDisplayId() = mHwcDisplayId; - } + flinger->mutableHwcPhysicalDisplayIdMap().emplace(mHwcDisplayId, mDisplayId); + (mIsPrimary ? flinger->mutableInternalHwcDisplayId() + : flinger->mutableExternalHwcDisplayId()) = mHwcDisplayId; } } private: - const HalDisplayId mDisplayId; + const DisplayId mDisplayId; const hal::DisplayType mHwcDisplayType; const bool mIsPrimary; hal::HWDisplayId mHwcDisplayId = DEFAULT_HWC_DISPLAY_ID; int32_t mWidth = DEFAULT_WIDTH; int32_t mHeight = DEFAULT_HEIGHT; - int32_t mVsyncPeriod = DEFAULT_VSYNC_PERIOD; + int32_t mRefreshRate = DEFAULT_REFRESH_RATE; int32_t mDpiX = DEFAULT_DPI; - int32_t mDpiY = DEFAULT_DPI; int32_t mConfigGroup = DEFAULT_CONFIG_GROUP; + int32_t mDpiY = DEFAULT_DPI; hal::HWConfigId mActiveConfig = DEFAULT_ACTIVE_CONFIG; hal::PowerMode mPowerMode = DEFAULT_POWER_MODE; const std::unordered_set<hal::Capability>* mCapabilities = nullptr; @@ -631,29 +560,13 @@ public: public: FakeDisplayDeviceInjector(TestableSurfaceFlinger& flinger, std::shared_ptr<compositionengine::Display> compositionDisplay, - std::optional<ui::DisplayConnectionType> connectionType, + std::optional<DisplayConnectionType> connectionType, std::optional<hal::HWDisplayId> hwcDisplayId, bool isPrimary) : mFlinger(flinger), - mCreationArgs(flinger.mFlinger.get(), flinger.mFlinger->getHwComposer(), - mDisplayToken, compositionDisplay), + mCreationArgs(flinger.mFlinger.get(), mDisplayToken, compositionDisplay), mHwcDisplayId(hwcDisplayId) { mCreationArgs.connectionType = connectionType; mCreationArgs.isPrimary = isPrimary; - - mActiveModeId = DisplayModeId(0); - DisplayModePtr activeMode = - DisplayMode::Builder(FakeHwcDisplayInjector::DEFAULT_ACTIVE_CONFIG) - .setId(mActiveModeId) - .setWidth(FakeHwcDisplayInjector::DEFAULT_WIDTH) - .setHeight(FakeHwcDisplayInjector::DEFAULT_HEIGHT) - .setVsyncPeriod(FakeHwcDisplayInjector::DEFAULT_VSYNC_PERIOD) - .setDpiX(FakeHwcDisplayInjector::DEFAULT_DPI) - .setDpiY(FakeHwcDisplayInjector::DEFAULT_DPI) - .setGroup(0) - .build(); - - DisplayModes modes{activeMode}; - mCreationArgs.supportedModes = modes; } sp<IBinder> token() const { return mDisplayToken; } @@ -676,16 +589,6 @@ public: auto& mutableDisplayDevice() { return mFlinger.mutableDisplays()[mDisplayToken]; } - auto& setActiveMode(DisplayModeId mode) { - mActiveModeId = mode; - return *this; - } - - auto& setSupportedModes(DisplayModes mode) { - mCreationArgs.supportedModes = mode; - return *this; - } - auto& setNativeWindow(const sp<ANativeWindow>& nativeWindow) { mCreationArgs.nativeWindow = nativeWindow; return *this; @@ -729,18 +632,13 @@ public: DisplayDeviceState state; if (const auto type = mCreationArgs.connectionType) { LOG_ALWAYS_FATAL_IF(!displayId); - const auto physicalId = PhysicalDisplayId::tryCast(*displayId); - LOG_ALWAYS_FATAL_IF(!physicalId); LOG_ALWAYS_FATAL_IF(!mHwcDisplayId); - state.physical = {.id = *physicalId, .type = *type, .hwcDisplayId = *mHwcDisplayId}; + state.physical = {*displayId, *type, *mHwcDisplayId}; } state.isSecure = mCreationArgs.isSecure; sp<DisplayDevice> device = new DisplayDevice(mCreationArgs); - if (!device->isVirtual()) { - device->setActiveMode(mActiveModeId); - } mFlinger.mutableDisplays().emplace(mDisplayToken, device); mFlinger.mutableCurrentState().displays.add(mDisplayToken, state); mFlinger.mutableDrawingState().displays.add(mDisplayToken, state); @@ -757,19 +655,12 @@ public: sp<BBinder> mDisplayToken = new BBinder(); DisplayDeviceCreationArgs mCreationArgs; const std::optional<hal::HWDisplayId> mHwcDisplayId; - DisplayModeId mActiveModeId; }; -private: - void setVsyncEnabled(bool) override {} - void changeRefreshRate(const Scheduler::RefreshRate&, Scheduler::ModeEvent) override {} - void repaintEverythingForHWC() override {} - void kernelTimerChanged(bool) override {} - void triggerOnFrameRateOverridesChanged() {} - surfaceflinger::test::Factory mFactory; sp<SurfaceFlinger> mFlinger = new SurfaceFlinger(mFactory, SurfaceFlinger::SkipInitialization); TestableScheduler* mScheduler = nullptr; + Hwc2::mock::Display mDisplay; }; } // namespace android |