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