Skip to content

Commit

Permalink
Add getSurfaceProps helper method to SurfaceManager (facebook#48487)
Browse files Browse the repository at this point in the history
Summary:

[Changelog] [Internal] - Add getSurfaceProps helper method to SurfaceManager

When reload a reactHost we need to know which surface properties have been applied when starting the surface. This adds a utility function for that.

Reviewed By: rshest

Differential Revision: D67822459
  • Loading branch information
christophpurrer authored and facebook-github-bot committed Jan 6, 2025
1 parent a3dfc49 commit 1fc5611
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ void SurfaceManager::stopAllSurfaces() const noexcept {
}
}

std::optional<SurfaceManager::SurfaceProps> SurfaceManager::getSurfaceProps(
SurfaceId surfaceId) const noexcept {
std::optional<SurfaceManager::SurfaceProps> surfaceProps;

visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
surfaceProps = SurfaceManager::SurfaceProps{
surfaceId,
surfaceHandler.getModuleName(),
surfaceHandler.getProps(),
surfaceHandler.getLayoutConstraints(),
surfaceHandler.getLayoutContext()};
});

return surfaceProps;
}

Size SurfaceManager::measureSurface(
SurfaceId surfaceId,
const LayoutConstraints& layoutConstraints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include <mutex>
#include <optional>
#include <shared_mutex>
#include <unordered_map>

Expand All @@ -29,6 +30,15 @@ class SurfaceManager final {
explicit SurfaceManager(const Scheduler& scheduler) noexcept;
~SurfaceManager() noexcept;

/* SurfaceProps contain information about running surfaces */
struct SurfaceProps {
SurfaceId surfaceId;
std::string moduleName;
folly::dynamic props;
LayoutConstraints layoutConstraints;
LayoutContext layoutContext;
};

#pragma mark - Surface Management

void startSurface(
Expand All @@ -47,6 +57,9 @@ class SurfaceManager final {

void stopAllSurfaces() const noexcept;

std::optional<SurfaceManager::SurfaceProps> getSurfaceProps(
SurfaceId surfaceId) const noexcept;

Size measureSurface(
SurfaceId surfaceId,
const LayoutConstraints& layoutConstraints,
Expand Down

0 comments on commit 1fc5611

Please sign in to comment.