From be691582ee12613278af24cb5a824eeb357f6324 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 29 Jul 2024 11:27:22 -0400 Subject: some work on compositor --- .../daguerre/include/daguerre/impl/fixed-font.hpp | 4 +- libraries/daguerre/include/daguerre/impl/image.hpp | 2 +- libraries/goldman/include/goldman/protocol.hpp | 85 ++++++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 libraries/goldman/include/goldman/protocol.hpp (limited to 'libraries') diff --git a/libraries/daguerre/include/daguerre/impl/fixed-font.hpp b/libraries/daguerre/include/daguerre/impl/fixed-font.hpp index dbff798..1a5f3d8 100644 --- a/libraries/daguerre/include/daguerre/impl/fixed-font.hpp +++ b/libraries/daguerre/include/daguerre/impl/fixed-font.hpp @@ -20,7 +20,7 @@ namespace daguerre { template fixed_font::fixed_font(fixed_font &&other) : glyph_width(other.glyph_width), glyph_height(other.glyph_height) { - for (int i = 0; 0 < 128; ++i) + for (int i = 0; i < 128; ++i) glyphs[i] = std::move(other.glyphs[i]); other.glyph_width = 0; other.glyph_height = 0; @@ -31,7 +31,7 @@ namespace daguerre { fixed_font &&other) { glyph_width = other.glyph_width; glyph_height = other.glyph_height; - for (int i = 0; 0 < 128; ++i) + for (int i = 0; i < 128; ++i) glyphs[i] = std::move(other.glyphs[i]); other.glyph_width = 0; other.glyph_height = 0; diff --git a/libraries/daguerre/include/daguerre/impl/image.hpp b/libraries/daguerre/include/daguerre/impl/image.hpp index 1264879..9160951 100644 --- a/libraries/daguerre/include/daguerre/impl/image.hpp +++ b/libraries/daguerre/include/daguerre/impl/image.hpp @@ -185,7 +185,7 @@ namespace daguerre { const param_t ¶m, const image &other, int to_x, int to_y, param_converter_t *conversion) { convert_from( - param, other, to_x, to_y, 0, 0, other.width, other.y, conversion); + param, other, to_x, to_y, 0, 0, other.width, other.height, conversion); } template diff --git a/libraries/goldman/include/goldman/protocol.hpp b/libraries/goldman/include/goldman/protocol.hpp new file mode 100644 index 0000000..b7f4d51 --- /dev/null +++ b/libraries/goldman/include/goldman/protocol.hpp @@ -0,0 +1,85 @@ +#pragma once + +#include +#include + +//TODO: handle stream errors, make thread safe + +namespace goldman::protocol { + + typedef euler::syscall::encoded_color color; + typedef uint16_t window; + + static inline void send_open_window( + euler::syscall::stream_handle socket, uint32_t width, uint32_t height) { + + struct [[gnu::packed]] { + uint8_t type; + uint32_t width; + uint32_t height; + } packet { + .type = 0x00, + .width = width, + .height = height + }; + + euler::syscall::write_to_stream(socket, sizeof(packet), &packet); + + } + + void send_update_window_region( + euler::syscall::stream_handle socket, window the_window, + uint32_t start_x, uint32_t start_y, uint32_t width, + uint32_t height, const color *the_data, size_t data_pitch) { + + struct [[gnu::packed]] { + uint8_t type; + window the_window; + uint32_t start_x; + uint32_t start_y; + uint32_t width; + uint32_t height; + } packet_head { + .type = 0x01, + .the_window = the_window, + .start_x = start_x, + .start_y = start_y, + .width = width, + .height = height + }; + + euler::syscall::write_to_stream(socket, sizeof(packet_head), &packet_head); + for (uint32_t y = 0; y < height; ++y) + euler::syscall::write_to_stream( + socket, width * sizeof(color), the_data + data_pitch * y); + + } + + void send_close_window( + euler::syscall::stream_handle socket, window the_window) { + + struct [[gnu::packed]] { + uint8_t type; + window the_window; + } packet { + .type = 0x02, + .the_window = the_window + }; + + euler::syscall::write_to_stream(socket, sizeof(packet), &packet); + + } + + enum class response_id : uint8_t { + window_opened + }; + + window get_window_opened_body(euler::syscall::stream_handle socket) { + + window w; + euler::syscall::read_from_stream(socket, sizeof(w), &w); + return w; + + } + +} -- cgit v1.2.3