From e60fa7740cd7d245d1b22a25fea9df0768d32668 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 04:34:40 -0400 Subject: mouse support (working in qemu, semi-working in virtualbox) --- libraries/daguerre/include/daguerre.hpp | 34 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'libraries/daguerre/include') diff --git a/libraries/daguerre/include/daguerre.hpp b/libraries/daguerre/include/daguerre.hpp index 274e257..62d10f0 100644 --- a/libraries/daguerre/include/daguerre.hpp +++ b/libraries/daguerre/include/daguerre.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace daguerre { @@ -13,14 +14,6 @@ namespace daguerre { uint8_t b; }; - template - to_type convert_color(const from_type &from); - - template <> - inline hilbert_color convert_color(const rgb24 &from) { - return __euler_encode_color(from.r, from.g, from.b); - } - template class image { @@ -88,15 +81,15 @@ namespace daguerre { //from [from_x, from_x + width) x [from_y, from_y + height). template void copy_region( - image &to, const image &from, unsigned from_x, - unsigned from_y, unsigned to_x, unsigned to_y, unsigned width, - unsigned height) { + image &to, unsigned to_x, unsigned to_y, + const image &from, unsigned from_x, unsigned from_y, + unsigned width, unsigned height) { color_t *to_start = to.buffer + to.pitch * to_y + to_x; const color_t *from_start = from.buffer + from.pitch * from_y + from_x; for (unsigned y = 0; y < height; ++y) - memcpy( + std::memcpy( to_start + to.pitch * y, from_start + from.pitch * y, width * sizeof(color_t)); @@ -107,12 +100,11 @@ namespace daguerre { //from [from_x, from_x + width) x [from_y, from_y + height). template < class to_color_t, class from_color_t, - to_color_t converter(const from_color_t &) = - convert_color> - void copy_region( - image &to, const image &from, unsigned from_x, - unsigned from_y, unsigned to_x, unsigned to_y, unsigned width, - unsigned height) { + void overlay(to_color_t &dest, const from_color_t &src)> + void overlay_region( + image &to, unsigned to_x, unsigned to_y, + const image &from, unsigned from_x, unsigned from_y, + unsigned width, unsigned height) { to_color_t *to_start = to.buffer + to.pitch * to_y + to_x; const from_color_t *from_start = @@ -120,8 +112,12 @@ namespace daguerre { for (unsigned y = 0; y < height; ++y) for (unsigned x = 0; x < width; ++x) - to_start[to.pitch * y + x] = converter(from_start[from.pitch * y + x]); + overlay(to_start[to.pitch * y + x], from_start[from.pitch * y + x]); + + } + static inline void encode(hilbert_color &dest, const rgb24 &src) { + dest = __euler_encode_color(src.r, src.g, src.b); } image get_hilbert_framebuffer(); -- cgit v1.2.3