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

◆ sync()

template<typename T >
void MayaFlux::Portal::Forma::Mapped< T >::sync ( Layer *  layer = nullptr)
inline

Call whenever state may have changed: once per graphics tick for a continuously-changing source with no discrete trigger (Bridge::bind's GraphicsRoutine does this), or directly from the event handler that changed state->value when the trigger is already known (a click, a scroll, a key) - no polling needed for the latter, same as Collapsible's own on_press calling sync() straight from the handler.

If state->version has advanced since last_version, invokes geometry_fn with the current value into a local byte buffer, then passes the result to VKBuffer::set_data so the existing upload path handles GPU transfer.

Parameters
layerOptional. Layer::add() stored a separate copy of element when this Mapped was registered, so a geometry_fn that updates element.bounds_hint/contains (a fader's handle, a radial indicator) only changes this Mapped's own copy unless that copy is pushed back. Passing the Layer this element was registered on does that push after geometry_fn runs, keeping hit-testing correct past the first frame instead of just the rendered buffer.

Definition at line 149 of file Mapped.hpp.

150 {
151 if (!state || !geometry_fn || !element.buffer)
152 return;
153 if (state->version == last_version && !force_redraw_on_sync)
154 return;
155
158 last_version = state->version;
159
160 if (layer) {
162 layer->set_bounds(element.id, *element.bounds_hint);
163 if (element.contains)
164 layer->set_contains(element.id, element.contains);
165 }
166 }
void submit(const std::vector< uint8_t > &bytes) const
Replace this target's geometry.
Definition Target.cpp:51
std::function< bool(glm::vec2)> contains
Authoritative containment test in NDC space.
Definition Element.hpp:77
FormaTarget buffer
Where this region's rendered output is written: a buffer of its own, or a slice of one it shares.
Definition Element.hpp:82
uint32_t id
Stable id assigned by Layer::add. Never zero.
Definition Element.hpp:63
std::optional< Kinesis::AABB2D > bounds_hint
Optional fast-reject bounds in NDC space.
Definition Element.hpp:67
std::shared_ptr< MappedState< T > > state
Shared value carrier. External systems hold a copy of this ptr.
Definition Mapped.hpp:98
std::vector< uint8_t > m_bytes
Definition Mapped.hpp:169
GeometryFn< T > geometry_fn
Geometry regeneration function. Set once at construction.
Definition Mapped.hpp:101
Element element
The Element registered with the Layer.
Definition Mapped.hpp:105
bool force_redraw_on_sync
When true, sync() regenerates geometry every call regardless of whether state->version has advanced.
Definition Mapped.hpp:114
Version last_version
Last version seen by sync().
Definition Mapped.hpp:109

References MayaFlux::Portal::Forma::Element::bounds_hint, MayaFlux::Portal::Forma::Element::buffer, MayaFlux::Portal::Forma::Element::contains, MayaFlux::Portal::Forma::Mapped< T >::element, MayaFlux::Portal::Forma::Mapped< T >::force_redraw_on_sync, MayaFlux::Portal::Forma::Mapped< T >::geometry_fn, MayaFlux::Portal::Forma::Element::id, MayaFlux::Portal::Forma::Mapped< T >::last_version, MayaFlux::Portal::Forma::Mapped< T >::m_bytes, MayaFlux::Portal::Forma::Mapped< T >::state, and MayaFlux::Portal::Forma::FormaTarget::submit().

Referenced by MayaFlux::Portal::Forma::Collapsible::place().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: