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

◆ process()

void MayaFlux::Kakshya::WindowAccessProcessor::process ( const std::shared_ptr< SignalSourceContainer > &  container)
overridevirtual

Execute a full-surface pixel readback.

Allocates a format-appropriate DataVariant and updates container ProcessingState: PROCESSING → PROCESSED.

Implements MayaFlux::Kakshya::DataProcessor.

Definition at line 72 of file WindowAccessProcessor.cpp.

74{
75 auto wc = std::dynamic_pointer_cast<WindowContainer>(container);
76 if (!wc) {
78 "WindowAccessProcessor::process — container is not a WindowContainer");
79 return;
80 }
81
82 const auto& window = wc->get_window();
83
84 if (!is_readback_available(window)) {
86 "WindowAccessProcessor: no completed frame available for '{}'",
87 window->get_create_info().title);
88 return;
89 }
90
91 const auto [cur_w, cur_h] = query_surface_extent(window);
92 if (cur_w != m_width || cur_h != m_height) {
93 m_width = cur_w;
94 m_height = cur_h;
95
97
99 "WindowAccessProcessor: '{}' resized to {}x{} format={}",
100 window->get_create_info().title, m_width, m_height,
101 static_cast<uint32_t>(m_surface_format));
102 }
103
104 m_is_processing.store(true);
105 container->update_processing_state(ProcessingState::PROCESSING);
106
107 auto& processed = container->get_processed_data();
108 processed.resize(1);
109
110 readback_region(window, 0U, 0U, m_width, m_height, processed[0]);
111
112 const bool has_data = std::visit(
113 [](const auto& v) { return !v.empty(); }, processed[0]);
114
115 if (!has_data) {
117 "WindowAccessProcessor: readback returned no data for '{}'",
118 window->get_create_info().title);
119 m_is_processing.store(false);
120 container->update_processing_state(ProcessingState::ERROR);
121 return;
122 }
123
124 const auto* src = std::get_if<std::vector<uint8_t>>(&processed[0]);
125 if (src) {
126 if (uint8_t* dst = wc->mutable_frame_ptr(wc->get_write_head())) {
127 std::memcpy(dst, src->data(), src->size());
128 wc->advance_write_head();
129 }
130 }
131
132 const auto vk_fmt = Core::to_vk_format(m_surface_format);
133 m_last_readback_bytes = static_cast<size_t>(m_width) * m_height
135
136 m_is_processing.store(false);
137 container->update_processing_state(ProcessingState::PROCESSED);
138}
#define MF_INFO(comp, ctx,...)
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
Core::GraphicsSurfaceInfo::SurfaceFormat m_surface_format
vk::Format to_vk_format(GraphicsSurfaceInfo::SurfaceFormat fmt)
uint32_t vk_format_bytes_per_pixel(vk::Format fmt)
Byte width of a single pixel for a given Vulkan format.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ ERROR
Container is in an error state and cannot proceed.
@ PROCESSING
Container is actively being processed.
@ PROCESSED
Container has completed processing and results are available.
bool is_readback_available(const std::shared_ptr< Core::Window > &window)
Check whether a completed frame is currently available for readback.
std::pair< uint32_t, uint32_t > query_surface_extent(const std::shared_ptr< Core::Window > &window)
Query the current pixel dimensions of the window's swapchain.
DataAccess readback_region(const std::shared_ptr< Core::Window > &window, uint32_t x_offset, uint32_t y_offset, uint32_t pixel_width, uint32_t pixel_height, DataVariant &out_variant)
Read a pixel rectangle from the last completed swapchain frame into a DataVariant whose element type ...
Core::GraphicsSurfaceInfo::SurfaceFormat query_surface_format(const std::shared_ptr< Core::Window > &window)
Query the actual vk::Format in use by the window's live swapchain, translated back to the MayaFlux su...

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Kakshya::ERROR, MayaFlux::Kakshya::is_readback_available(), MayaFlux::Journal::Kakshya, m_height, m_is_processing, m_last_readback_bytes, m_surface_format, m_width, MF_INFO, MF_RT_ERROR, MF_RT_TRACE, MF_RT_WARN, MayaFlux::Kakshya::PROCESSED, MayaFlux::Kakshya::PROCESSING, MayaFlux::Kakshya::query_surface_extent(), MayaFlux::Kakshya::query_surface_format(), MayaFlux::Kakshya::readback_region(), MayaFlux::Core::to_vk_format(), and MayaFlux::Core::vk_format_bytes_per_pixel().

+ Here is the call graph for this function: