MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ Surface() [1/3]

MayaFlux::Portal::Forma::Surface::Surface ( SurfaceConfig  config)
explicit

Construct a Surface from a SurfaceConfig.

Surface takes shared ownership of all three components. The caller is responsible for ensuring the Layer and Context were constructed against config.window. Wires the built-in close handling (Bridge::stop_sync plus a deferred window release) per config.should_detach_on_close(), then runs config.on_close if set. See SurfaceConfig's own doc for the composition rule between the two.

Parameters
configWindow, Layer, Context, and close-handling behavior.

Definition at line 9 of file Surface.cpp.

10 : m_window_ownership(std::make_shared<WindowOwnership>(std::move(config.window)))
11 , m_layer(std::move(config.layer))
12 , m_ctx(std::move(config.ctx))
13{
14 const bool detach = config.should_detach_on_close();
15
16 auto close_ownership = m_window_ownership;
17 auto close_layer = m_layer;
18 auto* event_source = &close_ownership->window->get_event_source();
19
20 m_ctx->on_close(0, [ownership = std::move(close_ownership), layer = std::move(close_layer), event_source, detach, on_close = std::move(config.on_close)]() {
21 if (on_close)
22 on_close();
23
24 if (detach) {
25 if (layer)
26 internal::atelier().bridge().stop_sync(*layer);
27
28 event_source->defer([ownership]() { ownership->window.reset(); });
29 }
30 });
31}
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:159
std::shared_ptr< Context > m_ctx
Definition Surface.hpp:331
std::shared_ptr< Layer > m_layer
Definition Surface.hpp:330
std::shared_ptr< WindowOwnership > m_window_ownership
Definition Surface.hpp:329

References layer(), m_ctx, m_layer, m_window_ownership, MayaFlux::Portal::Forma::SurfaceConfig::on_close, and MayaFlux::Portal::Forma::SurfaceConfig::should_detach_on_close().

+ Here is the call graph for this function: