MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
WindowAccessProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Kakshya {
7
8/**
9 * @class WindowAccessProcessor
10 * @brief Default DataProcessor for WindowContainer.
11 *
12 * Reads pixel data from the last completed swapchain frame into the
13 * container's processed_data.
14 * The DataVariant type is determined by the live swapchain format, queried
15 * at on_attach() time and re-evaluated if the surface dimensions change.
16 * It is based on live swapchain format reported bu DisplayService::get_swapchain_format,
17 * ensuring HDR and packed formats are stored with their native precision rather than truncated to uint8.
18 *
19 * Format → DataVariant element type:
20 * 8-bit UNORM/SRGB → std::vector<uint8_t>
21 * 16-bit SFLOAT → std::vector<uint16_t> (raw half-float bits)
22 * 10-bit packed → std::vector<uint32_t> (packed word per pixel)
23 * 32-bit SFLOAT → std::vector<float>
24 *
25 * One readback per frame regardless of region count — region extraction
26 * is a CPU-side crop performed by WindowContainer::get_region_data().
27 */
28class MAYAFLUX_API WindowAccessProcessor : public DataProcessor {
29public:
31 ~WindowAccessProcessor() override = default;
32
33 /**
34 * @brief Attach to a WindowContainer.
35 * Queries the live swapchain format and caches surface traits.
36 * Throws std::invalid_argument if container is not a WindowContainer.
37 */
38 void on_attach(const std::shared_ptr<SignalSourceContainer>& container) override;
39
40 /**
41 * @brief Release all cached state.
42 */
43 void on_detach(const std::shared_ptr<SignalSourceContainer>& container) override;
44
45 /**
46 * @brief Execute a full-surface pixel readback.
47 * Allocates a format-appropriate DataVariant and updates
48 * container ProcessingState: PROCESSING → PROCESSED.
49 */
50 void process(const std::shared_ptr<SignalSourceContainer>& container) override;
51
52 /**
53 * @brief Whether a process() call is currently executing.
54 */
55 [[nodiscard]] bool is_processing() const override { return m_is_processing.load(); }
56
57 /**
58 * @brief Byte size of the last successful readback.
59 */
60 [[nodiscard]] size_t get_last_readback_bytes() const { return m_last_readback_bytes; }
61
62 /**
63 * @brief The surface format currently in use for readback allocation.
64 */
66 {
67 return m_surface_format;
68 }
69
70private:
71 std::atomic<bool> m_is_processing { false };
72
73 uint32_t m_width {};
74 uint32_t m_height {};
75 size_t m_last_readback_bytes {};
76 bool m_previous_window_capture_supported {};
77
79 Core::GraphicsSurfaceInfo::SurfaceFormat::B8G8R8A8_SRGB
80 };
81};
82
83} // namespace MayaFlux::Kakshya
Interface for processing data within SignalSourceContainer objects.
Core::GraphicsSurfaceInfo::SurfaceFormat get_surface_format() const
The surface format currently in use for readback allocation.
size_t get_last_readback_bytes() const
Byte size of the last successful readback.
bool is_processing() const override
Whether a process() call is currently executing.
Default DataProcessor for WindowContainer.
SurfaceFormat
Default pixel format for window surfaces (Vulkan-compatible)