Loading services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: HWComposer(); ~HWComposer() override; MOCK_METHOD2(setConfiguration, void(HWC2::ComposerCallback*, int32_t)); MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback*)); MOCK_CONST_METHOD3(getDisplayIdentificationData, bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*)); MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability)); Loading services/surfaceflinger/DisplayHardware/HWC2.h +8 −12 Original line number Diff line number Diff line Loading @@ -55,20 +55,16 @@ namespace hal = android::hardware::graphics::composer::hal; // Implement this interface to receive hardware composer events. // // These callback functions will generally be called on a hwbinder thread, but // when first registering the callback the onHotplugReceived() function will // when first registering the callback the onComposerHalHotplug() function will // immediately be called on the thread calling registerCallback(). // // All calls receive a sequenceId, which will be the value that was supplied to // HWC2::Device::registerCallback(). It's used to help differentiate callbacks // from different hardware composer instances. struct ComposerCallback { virtual void onHotplugReceived(int32_t sequenceId, hal::HWDisplayId, hal::Connection) = 0; virtual void onRefreshReceived(int32_t sequenceId, hal::HWDisplayId) = 0; virtual void onVsyncReceived(int32_t sequenceId, hal::HWDisplayId, int64_t timestamp, virtual void onComposerHalHotplug(hal::HWDisplayId, hal::Connection) = 0; virtual void onComposerHalRefresh(hal::HWDisplayId) = 0; virtual void onComposerHalVsync(hal::HWDisplayId, int64_t timestamp, std::optional<hal::VsyncPeriodNanos>) = 0; virtual void onVsyncPeriodTimingChangedReceived(int32_t sequenceId, hal::HWDisplayId, virtual void onComposerHalVsyncPeriodTimingChanged(hal::HWDisplayId, const hal::VsyncPeriodChangeTimeline&) = 0; virtual void onSeamlessPossible(int32_t sequenceId, hal::HWDisplayId) = 0; virtual void onComposerHalSeamlessPossible(hal::HWDisplayId) = 0; protected: ~ComposerCallback() = default; Loading services/surfaceflinger/DisplayHardware/HWComposer.cpp +16 −23 Original line number Diff line number Diff line Loading @@ -82,25 +82,22 @@ using android::HWC2::ComposerCallback; class ComposerCallbackBridge : public hal::IComposerCallback { public: ComposerCallbackBridge(ComposerCallback* callback, int32_t sequenceId, bool vsyncSwitchingSupported) : mCallback(callback), mSequenceId(sequenceId), mVsyncSwitchingSupported(vsyncSwitchingSupported) {} Return<void> onHotplug(hal::HWDisplayId display, hal::Connection conn) override { mCallback->onHotplugReceived(mSequenceId, display, conn); ComposerCallbackBridge(ComposerCallback* callback, bool vsyncSwitchingSupported) : mCallback(callback), mVsyncSwitchingSupported(vsyncSwitchingSupported) {} Return<void> onHotplug(hal::HWDisplayId display, hal::Connection connection) override { mCallback->onComposerHalHotplug(display, connection); return Void(); } Return<void> onRefresh(hal::HWDisplayId display) override { mCallback->onRefreshReceived(mSequenceId, display); mCallback->onComposerHalRefresh(display); return Void(); } Return<void> onVsync(hal::HWDisplayId display, int64_t timestamp) override { if (!mVsyncSwitchingSupported) { mCallback->onVsyncReceived(mSequenceId, display, timestamp, std::nullopt); mCallback->onComposerHalVsync(display, timestamp, std::nullopt); } else { ALOGW("Unexpected onVsync callback on composer >= 2.4, ignoring."); } Loading @@ -110,8 +107,7 @@ public: Return<void> onVsync_2_4(hal::HWDisplayId display, int64_t timestamp, hal::VsyncPeriodNanos vsyncPeriodNanos) override { if (mVsyncSwitchingSupported) { mCallback->onVsyncReceived(mSequenceId, display, timestamp, std::make_optional(vsyncPeriodNanos)); mCallback->onComposerHalVsync(display, timestamp, vsyncPeriodNanos); } else { ALOGW("Unexpected onVsync_2_4 callback on composer <= 2.3, ignoring."); } Loading @@ -119,20 +115,18 @@ public: } Return<void> onVsyncPeriodTimingChanged( hal::HWDisplayId display, const hal::VsyncPeriodChangeTimeline& updatedTimeline) override { mCallback->onVsyncPeriodTimingChangedReceived(mSequenceId, display, updatedTimeline); hal::HWDisplayId display, const hal::VsyncPeriodChangeTimeline& timeline) override { mCallback->onComposerHalVsyncPeriodTimingChanged(display, timeline); return Void(); } Return<void> onSeamlessPossible(hal::HWDisplayId display) override { mCallback->onSeamlessPossible(mSequenceId, display); mCallback->onComposerHalSeamlessPossible(display); return Void(); } private: ComposerCallback* mCallback; const int32_t mSequenceId; ComposerCallback* const mCallback; const bool mVsyncSwitchingSupported; }; Loading @@ -155,7 +149,7 @@ HWComposer::~HWComposer() { mDisplayData.clear(); } void HWComposer::setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) { void HWComposer::setCallback(HWC2::ComposerCallback* callback) { loadCapabilities(); loadLayerMetadataSupport(); Loading @@ -164,10 +158,9 @@ void HWComposer::setConfiguration(HWC2::ComposerCallback* callback, int32_t sequ return; } mRegisteredCallback = true; sp<ComposerCallbackBridge> callbackBridge( new ComposerCallbackBridge(callback, sequenceId, mComposer->isVsyncPeriodSwitchSupported())); mComposer->registerCallback(callbackBridge); mComposer->registerCallback( sp<ComposerCallbackBridge>::make(callback, mComposer->isVsyncPeriodSwitchSupported())); } bool HWComposer::getDisplayIdentificationData(hal::HWDisplayId hwcDisplayId, uint8_t* outPort, Loading services/surfaceflinger/DisplayHardware/HWComposer.h +2 −2 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public: virtual ~HWComposer(); virtual void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) = 0; virtual void setCallback(HWC2::ComposerCallback*) = 0; virtual bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, DisplayIdentificationData* outData) const = 0; Loading Loading @@ -252,7 +252,7 @@ public: ~HWComposer() override; void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) override; void setCallback(HWC2::ComposerCallback*) override; bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, DisplayIdentificationData* outData) const override; Loading services/surfaceflinger/SurfaceFlinger.cpp +13 −30 Original line number Diff line number Diff line Loading @@ -778,7 +778,7 @@ void SurfaceFlinger::init() { .build())); mCompositionEngine->setTimeStats(mTimeStats); mCompositionEngine->setHwComposer(getFactory().createHWComposer(mHwcServiceName)); mCompositionEngine->getHwComposer().setConfiguration(this, getBE().mComposerSequenceId); mCompositionEngine->getHwComposer().setCallback(this); ClientCache::getInstance().setRenderEngine(&getRenderEngine()); if (base::GetBoolProperty("debug.sf.enable_hwc_vds"s, false)) { Loading Loading @@ -1638,16 +1638,11 @@ nsecs_t SurfaceFlinger::getVsyncPeriodFromHWC() const { return 0; } void SurfaceFlinger::onVsyncReceived(int32_t sequenceId, hal::HWDisplayId hwcDisplayId, int64_t timestamp, void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp, std::optional<hal::VsyncPeriodNanos> vsyncPeriod) { ATRACE_NAME("SF onVsync"); ATRACE_CALL(); Mutex::Autolock lock(mStateLock); // Ignore any vsyncs from a previous hardware composer. if (sequenceId != getBE().mComposerSequenceId) { return; } if (const auto displayId = getHwComposer().toPhysicalDisplayId(hwcDisplayId)) { auto token = getPhysicalDisplayTokenLocked(*displayId); Loading Loading @@ -1698,16 +1693,11 @@ void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate, setDesiredActiveMode({refreshRate.getModeId(), event}); } void SurfaceFlinger::onHotplugReceived(int32_t sequenceId, hal::HWDisplayId hwcDisplayId, void SurfaceFlinger::onComposerHalHotplug(hal::HWDisplayId hwcDisplayId, hal::Connection connection) { ALOGI("%s(%d, %" PRIu64 ", %s)", __FUNCTION__, sequenceId, hwcDisplayId, ALOGI("%s(%" PRIu64 ", %s)", __func__, hwcDisplayId, connection == hal::Connection::CONNECTED ? "connected" : "disconnected"); // Ignore events that do not have the right sequenceId. if (sequenceId != getBE().mComposerSequenceId) { return; } // Only lock if we're not on the main thread. This function is normally // called on a hwbinder thread, but for the primary display it's called on // the main thread with the state lock already held, so don't attempt to Loading @@ -1724,26 +1714,19 @@ void SurfaceFlinger::onHotplugReceived(int32_t sequenceId, hal::HWDisplayId hwcD setTransactionFlags(eDisplayTransactionNeeded); } void SurfaceFlinger::onVsyncPeriodTimingChangedReceived( int32_t sequenceId, hal::HWDisplayId /*display*/, const hal::VsyncPeriodChangeTimeline& updatedTimeline) { void SurfaceFlinger::onComposerHalVsyncPeriodTimingChanged( hal::HWDisplayId, const hal::VsyncPeriodChangeTimeline& timeline) { Mutex::Autolock lock(mStateLock); if (sequenceId != getBE().mComposerSequenceId) { return; } mScheduler->onNewVsyncPeriodChangeTimeline(updatedTimeline); mScheduler->onNewVsyncPeriodChangeTimeline(timeline); } void SurfaceFlinger::onSeamlessPossible(int32_t /*sequenceId*/, hal::HWDisplayId /*display*/) { void SurfaceFlinger::onComposerHalSeamlessPossible(hal::HWDisplayId) { // TODO(b/142753666): use constraints when calling to setActiveModeWithConstraints and // use this callback to know when to retry in case of SEAMLESS_NOT_POSSIBLE. } void SurfaceFlinger::onRefreshReceived(int sequenceId, hal::HWDisplayId /*hwcDisplayId*/) { void SurfaceFlinger::onComposerHalRefresh(hal::HWDisplayId) { Mutex::Autolock lock(mStateLock); if (sequenceId != getBE().mComposerSequenceId) { return; } repaintEverythingForHWC(); } Loading Loading @@ -5613,7 +5596,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r Mutex::Autolock lock(mStateLock); hwcId = getHwComposer().getInternalHwcDisplayId(); } onHotplugReceived(getBE().mComposerSequenceId, *hwcId, hal::Connection::CONNECTED); onComposerHalHotplug(*hwcId, hal::Connection::CONNECTED); return NO_ERROR; } // Modify the max number of display frames stored within FrameTimeline Loading Loading
services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public: HWComposer(); ~HWComposer() override; MOCK_METHOD2(setConfiguration, void(HWC2::ComposerCallback*, int32_t)); MOCK_METHOD1(setCallback, void(HWC2::ComposerCallback*)); MOCK_CONST_METHOD3(getDisplayIdentificationData, bool(hal::HWDisplayId, uint8_t*, DisplayIdentificationData*)); MOCK_CONST_METHOD1(hasCapability, bool(hal::Capability)); Loading
services/surfaceflinger/DisplayHardware/HWC2.h +8 −12 Original line number Diff line number Diff line Loading @@ -55,20 +55,16 @@ namespace hal = android::hardware::graphics::composer::hal; // Implement this interface to receive hardware composer events. // // These callback functions will generally be called on a hwbinder thread, but // when first registering the callback the onHotplugReceived() function will // when first registering the callback the onComposerHalHotplug() function will // immediately be called on the thread calling registerCallback(). // // All calls receive a sequenceId, which will be the value that was supplied to // HWC2::Device::registerCallback(). It's used to help differentiate callbacks // from different hardware composer instances. struct ComposerCallback { virtual void onHotplugReceived(int32_t sequenceId, hal::HWDisplayId, hal::Connection) = 0; virtual void onRefreshReceived(int32_t sequenceId, hal::HWDisplayId) = 0; virtual void onVsyncReceived(int32_t sequenceId, hal::HWDisplayId, int64_t timestamp, virtual void onComposerHalHotplug(hal::HWDisplayId, hal::Connection) = 0; virtual void onComposerHalRefresh(hal::HWDisplayId) = 0; virtual void onComposerHalVsync(hal::HWDisplayId, int64_t timestamp, std::optional<hal::VsyncPeriodNanos>) = 0; virtual void onVsyncPeriodTimingChangedReceived(int32_t sequenceId, hal::HWDisplayId, virtual void onComposerHalVsyncPeriodTimingChanged(hal::HWDisplayId, const hal::VsyncPeriodChangeTimeline&) = 0; virtual void onSeamlessPossible(int32_t sequenceId, hal::HWDisplayId) = 0; virtual void onComposerHalSeamlessPossible(hal::HWDisplayId) = 0; protected: ~ComposerCallback() = default; Loading
services/surfaceflinger/DisplayHardware/HWComposer.cpp +16 −23 Original line number Diff line number Diff line Loading @@ -82,25 +82,22 @@ using android::HWC2::ComposerCallback; class ComposerCallbackBridge : public hal::IComposerCallback { public: ComposerCallbackBridge(ComposerCallback* callback, int32_t sequenceId, bool vsyncSwitchingSupported) : mCallback(callback), mSequenceId(sequenceId), mVsyncSwitchingSupported(vsyncSwitchingSupported) {} Return<void> onHotplug(hal::HWDisplayId display, hal::Connection conn) override { mCallback->onHotplugReceived(mSequenceId, display, conn); ComposerCallbackBridge(ComposerCallback* callback, bool vsyncSwitchingSupported) : mCallback(callback), mVsyncSwitchingSupported(vsyncSwitchingSupported) {} Return<void> onHotplug(hal::HWDisplayId display, hal::Connection connection) override { mCallback->onComposerHalHotplug(display, connection); return Void(); } Return<void> onRefresh(hal::HWDisplayId display) override { mCallback->onRefreshReceived(mSequenceId, display); mCallback->onComposerHalRefresh(display); return Void(); } Return<void> onVsync(hal::HWDisplayId display, int64_t timestamp) override { if (!mVsyncSwitchingSupported) { mCallback->onVsyncReceived(mSequenceId, display, timestamp, std::nullopt); mCallback->onComposerHalVsync(display, timestamp, std::nullopt); } else { ALOGW("Unexpected onVsync callback on composer >= 2.4, ignoring."); } Loading @@ -110,8 +107,7 @@ public: Return<void> onVsync_2_4(hal::HWDisplayId display, int64_t timestamp, hal::VsyncPeriodNanos vsyncPeriodNanos) override { if (mVsyncSwitchingSupported) { mCallback->onVsyncReceived(mSequenceId, display, timestamp, std::make_optional(vsyncPeriodNanos)); mCallback->onComposerHalVsync(display, timestamp, vsyncPeriodNanos); } else { ALOGW("Unexpected onVsync_2_4 callback on composer <= 2.3, ignoring."); } Loading @@ -119,20 +115,18 @@ public: } Return<void> onVsyncPeriodTimingChanged( hal::HWDisplayId display, const hal::VsyncPeriodChangeTimeline& updatedTimeline) override { mCallback->onVsyncPeriodTimingChangedReceived(mSequenceId, display, updatedTimeline); hal::HWDisplayId display, const hal::VsyncPeriodChangeTimeline& timeline) override { mCallback->onComposerHalVsyncPeriodTimingChanged(display, timeline); return Void(); } Return<void> onSeamlessPossible(hal::HWDisplayId display) override { mCallback->onSeamlessPossible(mSequenceId, display); mCallback->onComposerHalSeamlessPossible(display); return Void(); } private: ComposerCallback* mCallback; const int32_t mSequenceId; ComposerCallback* const mCallback; const bool mVsyncSwitchingSupported; }; Loading @@ -155,7 +149,7 @@ HWComposer::~HWComposer() { mDisplayData.clear(); } void HWComposer::setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) { void HWComposer::setCallback(HWC2::ComposerCallback* callback) { loadCapabilities(); loadLayerMetadataSupport(); Loading @@ -164,10 +158,9 @@ void HWComposer::setConfiguration(HWC2::ComposerCallback* callback, int32_t sequ return; } mRegisteredCallback = true; sp<ComposerCallbackBridge> callbackBridge( new ComposerCallbackBridge(callback, sequenceId, mComposer->isVsyncPeriodSwitchSupported())); mComposer->registerCallback(callbackBridge); mComposer->registerCallback( sp<ComposerCallbackBridge>::make(callback, mComposer->isVsyncPeriodSwitchSupported())); } bool HWComposer::getDisplayIdentificationData(hal::HWDisplayId hwcDisplayId, uint8_t* outPort, Loading
services/surfaceflinger/DisplayHardware/HWComposer.h +2 −2 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public: virtual ~HWComposer(); virtual void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) = 0; virtual void setCallback(HWC2::ComposerCallback*) = 0; virtual bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, DisplayIdentificationData* outData) const = 0; Loading Loading @@ -252,7 +252,7 @@ public: ~HWComposer() override; void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) override; void setCallback(HWC2::ComposerCallback*) override; bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, DisplayIdentificationData* outData) const override; Loading
services/surfaceflinger/SurfaceFlinger.cpp +13 −30 Original line number Diff line number Diff line Loading @@ -778,7 +778,7 @@ void SurfaceFlinger::init() { .build())); mCompositionEngine->setTimeStats(mTimeStats); mCompositionEngine->setHwComposer(getFactory().createHWComposer(mHwcServiceName)); mCompositionEngine->getHwComposer().setConfiguration(this, getBE().mComposerSequenceId); mCompositionEngine->getHwComposer().setCallback(this); ClientCache::getInstance().setRenderEngine(&getRenderEngine()); if (base::GetBoolProperty("debug.sf.enable_hwc_vds"s, false)) { Loading Loading @@ -1638,16 +1638,11 @@ nsecs_t SurfaceFlinger::getVsyncPeriodFromHWC() const { return 0; } void SurfaceFlinger::onVsyncReceived(int32_t sequenceId, hal::HWDisplayId hwcDisplayId, int64_t timestamp, void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp, std::optional<hal::VsyncPeriodNanos> vsyncPeriod) { ATRACE_NAME("SF onVsync"); ATRACE_CALL(); Mutex::Autolock lock(mStateLock); // Ignore any vsyncs from a previous hardware composer. if (sequenceId != getBE().mComposerSequenceId) { return; } if (const auto displayId = getHwComposer().toPhysicalDisplayId(hwcDisplayId)) { auto token = getPhysicalDisplayTokenLocked(*displayId); Loading Loading @@ -1698,16 +1693,11 @@ void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate, setDesiredActiveMode({refreshRate.getModeId(), event}); } void SurfaceFlinger::onHotplugReceived(int32_t sequenceId, hal::HWDisplayId hwcDisplayId, void SurfaceFlinger::onComposerHalHotplug(hal::HWDisplayId hwcDisplayId, hal::Connection connection) { ALOGI("%s(%d, %" PRIu64 ", %s)", __FUNCTION__, sequenceId, hwcDisplayId, ALOGI("%s(%" PRIu64 ", %s)", __func__, hwcDisplayId, connection == hal::Connection::CONNECTED ? "connected" : "disconnected"); // Ignore events that do not have the right sequenceId. if (sequenceId != getBE().mComposerSequenceId) { return; } // Only lock if we're not on the main thread. This function is normally // called on a hwbinder thread, but for the primary display it's called on // the main thread with the state lock already held, so don't attempt to Loading @@ -1724,26 +1714,19 @@ void SurfaceFlinger::onHotplugReceived(int32_t sequenceId, hal::HWDisplayId hwcD setTransactionFlags(eDisplayTransactionNeeded); } void SurfaceFlinger::onVsyncPeriodTimingChangedReceived( int32_t sequenceId, hal::HWDisplayId /*display*/, const hal::VsyncPeriodChangeTimeline& updatedTimeline) { void SurfaceFlinger::onComposerHalVsyncPeriodTimingChanged( hal::HWDisplayId, const hal::VsyncPeriodChangeTimeline& timeline) { Mutex::Autolock lock(mStateLock); if (sequenceId != getBE().mComposerSequenceId) { return; } mScheduler->onNewVsyncPeriodChangeTimeline(updatedTimeline); mScheduler->onNewVsyncPeriodChangeTimeline(timeline); } void SurfaceFlinger::onSeamlessPossible(int32_t /*sequenceId*/, hal::HWDisplayId /*display*/) { void SurfaceFlinger::onComposerHalSeamlessPossible(hal::HWDisplayId) { // TODO(b/142753666): use constraints when calling to setActiveModeWithConstraints and // use this callback to know when to retry in case of SEAMLESS_NOT_POSSIBLE. } void SurfaceFlinger::onRefreshReceived(int sequenceId, hal::HWDisplayId /*hwcDisplayId*/) { void SurfaceFlinger::onComposerHalRefresh(hal::HWDisplayId) { Mutex::Autolock lock(mStateLock); if (sequenceId != getBE().mComposerSequenceId) { return; } repaintEverythingForHWC(); } Loading Loading @@ -5613,7 +5596,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r Mutex::Autolock lock(mStateLock); hwcId = getHwComposer().getInternalHwcDisplayId(); } onHotplugReceived(getBE().mComposerSequenceId, *hwcId, hal::Connection::CONNECTED); onComposerHalHotplug(*hwcId, hal::Connection::CONNECTED); return NO_ERROR; } // Modify the max number of display frames stored within FrameTimeline Loading