MayaFlux 0.2.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 53 of file WindowAccessProcessor.cpp.

55{
56 auto wc = std::dynamic_pointer_cast<WindowContainer>(container);
57 if (!wc) {
59 "WindowAccessProcessor::process — container is not a WindowContainer");
60 return;
61 }
62
63 const auto& window = wc->get_window();
64
65 if (!is_readback_available(window)) {
67 "WindowAccessProcessor: no completed frame available for '{}'",
68 window->get_create_info().title);
69 return;
70 }
71
72 const auto [cur_w, cur_h] = query_surface_extent(window);
73 if (cur_w != m_width || cur_h != m_height) {
74 m_width = cur_w;
75 m_height = cur_h;
76
78
80 "WindowAccessProcessor: '{}' resized to {}x{} format={}",
81 window->get_create_info().title, m_width, m_height,
82 static_cast<uint32_t>(m_surface_format));
83 }
84
85 m_is_processing.store(true);
86 container->update_processing_state(ProcessingState::PROCESSING);
87
88 auto& processed = container->get_processed_data();
89 processed.resize(1);
90
91 DataAccess result = readback_region(
92 window, 0U, 0U, m_width, m_height, processed[0]);
93
94 if (result.element_count() == 0) {
96 "WindowAccessProcessor: readback returned no data for '{}'",
97 window->get_create_info().title);
98 m_is_processing.store(false);
99 container->update_processing_state(ProcessingState::ERROR);
100 return;
101 }
102
103 const auto vk_fmt = Core::to_vk_format(m_surface_format);
104 m_last_readback_bytes = static_cast<size_t>(m_width) * m_height
106
107 m_is_processing.store(false);
108 container->update_processing_state(ProcessingState::PROCESSED);
109}
#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::DataAccess::element_count(), 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: