Implement M9.2 native client lifecycle and immutable render boundary
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace evo::render {
|
||||
inline constexpr std::size_t max_rectangles = 4096;
|
||||
struct Color {
|
||||
std::uint8_t red{}, green{}, blue{}, alpha{255};
|
||||
};
|
||||
struct Rectangle {
|
||||
float x{}, y{}, width{}, height{};
|
||||
Color color;
|
||||
};
|
||||
enum class FrameError : std::uint8_t { too_many_primitives, invalid_geometry };
|
||||
// Owns copied logical-window coordinates; never stores simulation/native handles.
|
||||
class Frame {
|
||||
public:
|
||||
[[nodiscard]] static std::expected<Frame, FrameError>
|
||||
create(std::span<const Rectangle> rectangles, Color background = {});
|
||||
[[nodiscard]] std::span<const Rectangle> rectangles() const noexcept {
|
||||
return rectangles_;
|
||||
}
|
||||
[[nodiscard]] Color background() const noexcept {
|
||||
return background_;
|
||||
}
|
||||
|
||||
private:
|
||||
Frame(std::span<const Rectangle> rectangles, Color background)
|
||||
: rectangles_(rectangles.begin(), rectangles.end()), background_{background} {}
|
||||
std::vector<Rectangle> rectangles_;
|
||||
Color background_;
|
||||
};
|
||||
} // namespace evo::render
|
||||
Reference in New Issue
Block a user