mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager (#48484)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48484 [Changelog] [Internal] - Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager This exposes convience getter methods to data already stored in SurfaceManager Reviewed By: rshest Differential Revision: D67814092 fbshipit-source-id: af5e9df3b380d5efc0c11627a0d9a56796526639
This commit is contained in:
committed by
Facebook GitHub Bot
parent
25c673e357
commit
44525aaf8b
@@ -45,10 +45,17 @@ void SurfaceManager::startSurface(
|
||||
}
|
||||
|
||||
void SurfaceManager::stopSurface(SurfaceId surfaceId) noexcept {
|
||||
bool surfaceWasRunning = false;
|
||||
visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
|
||||
surfaceHandler.stop();
|
||||
scheduler_.unregisterSurface(surfaceHandler);
|
||||
surfaceWasRunning = true;
|
||||
});
|
||||
if (!surfaceWasRunning) {
|
||||
LOG(WARNING)
|
||||
<< "SurfaceManager::stopSurface tried to stop a surface which was not running, surfaceId = "
|
||||
<< surfaceId;
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock lock(mutex_);
|
||||
@@ -59,6 +66,19 @@ void SurfaceManager::stopSurface(SurfaceId surfaceId) noexcept {
|
||||
}
|
||||
|
||||
void SurfaceManager::stopAllSurfaces() noexcept {
|
||||
auto surfaceIds = getRunningSurfaces();
|
||||
for (const auto& surfaceId : surfaceIds) {
|
||||
stopSurface(surfaceId);
|
||||
}
|
||||
}
|
||||
|
||||
bool SurfaceManager::isSurfaceRunning(SurfaceId surfaceId) const noexcept {
|
||||
std::shared_lock lock(mutex_);
|
||||
return registry_.contains(surfaceId);
|
||||
}
|
||||
|
||||
std::unordered_set<SurfaceId> SurfaceManager::getRunningSurfaces()
|
||||
const noexcept {
|
||||
std::unordered_set<SurfaceId> surfaceIds;
|
||||
{
|
||||
std::shared_lock lock(mutex_);
|
||||
@@ -66,9 +86,7 @@ void SurfaceManager::stopAllSurfaces() noexcept {
|
||||
surfaceIds.insert(surfaceId);
|
||||
}
|
||||
}
|
||||
for (const auto& surfaceId : surfaceIds) {
|
||||
stopSurface(surfaceId);
|
||||
}
|
||||
return surfaceIds;
|
||||
}
|
||||
|
||||
Size SurfaceManager::measureSurface(
|
||||
|
||||
@@ -42,6 +42,10 @@ class SurfaceManager final {
|
||||
|
||||
void stopAllSurfaces() noexcept;
|
||||
|
||||
bool isSurfaceRunning(SurfaceId surfaceId) const noexcept;
|
||||
|
||||
std::unordered_set<SurfaceId> getRunningSurfaces() const noexcept;
|
||||
|
||||
Size measureSurface(
|
||||
SurfaceId surfaceId,
|
||||
const LayoutConstraints& layoutConstraints,
|
||||
|
||||
Reference in New Issue
Block a user