69 lines
4.1 KiB
C++
69 lines
4.1 KiB
C++
#pragma once
|
|
#include <nlohmann/json_fwd.hpp>
|
|
#include <render_2D/module/scene/Render_Scene_2D.hpp>
|
|
#include <render_3D/scene/Render_Scene_3D.hpp>
|
|
#include <scene/export/export.h>
|
|
#include <chrono>
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <utility>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
namespace aethera::web {
|
|
|
|
enum struct Gallery_Pixel_Layout : std::uint8_t {
|
|
bgra8, /* Blend2D native premultiplied BGRA8 bytes. */
|
|
rgba8 /* Datoviz native RGBA8 bytes. */
|
|
};
|
|
|
|
struct Gallery_Frame_Request {
|
|
std::chrono::steady_clock::time_point issued_at{}; /* Monotonic time at which the external request entered the control service. */
|
|
double time_milliseconds{}; /* Plot animation time supplied by the caller or derived from the runtime clock. */
|
|
std::uint64_t sequence{}; /* Runtime-assigned monotonic render request sequence. */
|
|
std::uint64_t correlation_id{}; /* Optional caller sequence carried through the rendered frame. */
|
|
std::uint32_t width{720}; /* Requested physical pixel width. */
|
|
std::uint32_t height{420}; /* Requested physical pixel height. */
|
|
};
|
|
|
|
struct Gallery_Frame_Slot {
|
|
using Native_Frame = std::variant<std::unique_ptr<render_2d::Frame_2D>, std::unique_ptr<render_3d::Frame_3D>>;
|
|
explicit Gallery_Frame_Slot(bool use_3d) : native(use_3d ? Native_Frame{std::in_place_type<std::unique_ptr<render_3d::Frame_3D>>, std::make_unique<render_3d::Frame_3D>(render_3d::Frame_Identity{})} : Native_Frame{std::in_place_type<std::unique_ptr<render_2d::Frame_2D>>, std::make_unique<render_2d::Frame_2D>(render_2d::Frame_Identity{})}) {}
|
|
Native_Frame native; /* Sole owner of the dimension-specific physical frame held by one Frame Policy slot. */
|
|
Gallery_Frame_Request request{}; /* Metadata for the current use of this slot. */
|
|
std::uint64_t generation{}; /* Slot-local reuse generation. */
|
|
bool taskflow_trace_reserved{}; /* This frame owns one requested diagnostic capture until Scene completion consumes it. */
|
|
};
|
|
|
|
struct Gallery_Pixel_Frame {
|
|
std::shared_ptr<const std::vector<std::byte>> pixels{}; /* Shared immutable bytes retained by the asynchronous FFmpeg Sink taskflow. */
|
|
Gallery_Pixel_Layout layout{Gallery_Pixel_Layout::rgba8}; /* Byte channel order. */
|
|
std::chrono::microseconds presentation_time{}; /* Plot animation timestamp. */
|
|
std::uint64_t sequence{}; /* Runtime-assigned monotonic rendered-frame sequence. */
|
|
std::uint64_t correlation_id{}; /* Caller request correlation. */
|
|
std::uint64_t rendered_sequence{}; /* Physical 3D frame actually read back; equals sequence for 2D. */
|
|
std::uint64_t rendered_correlation_id{}; /* Correlation carried by the physical rendered frame. */
|
|
std::uint32_t width{}; /* Pixel width. */
|
|
std::uint32_t height{}; /* Pixel height. */
|
|
};
|
|
|
|
struct Gallery_Component {
|
|
virtual ~Gallery_Component() = default;
|
|
[[nodiscard]] virtual nlohmann::json schema() const = 0;
|
|
[[nodiscard]] virtual nlohmann::json write_prop(std::string_view component, std::string_view key, const nlohmann::json& value) = 0;
|
|
[[nodiscard]] virtual nlohmann::json component_state(std::string_view component) const = 0;
|
|
[[nodiscard]] virtual nlohmann::json capture_components(const std::vector<std::string>& components) const = 0;
|
|
[[nodiscard]] virtual nlohmann::json data_generator_schema() const = 0;
|
|
[[nodiscard]] virtual nlohmann::json generate_data(const nlohmann::json& input) = 0;
|
|
virtual void update(const Gallery_Frame_Request& request) = 0;
|
|
};
|
|
|
|
using Gallery_Scene = std::variant<std::unique_ptr<render_2d::Render_Scene_2D>, std::unique_ptr<render_3d::Render_Scene_3D>>;
|
|
using Gallery_Build = std::pair<std::unique_ptr<Gallery_Component>, Gallery_Scene>;
|
|
|
|
} // namespace aethera::web
|