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