summaryrefslogtreecommitdiff
path: root/libraries/daguerre/include
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-05-19 04:34:40 -0400
committerBenji Dial <benji@benjidial.net>2024-05-19 04:34:40 -0400
commite60fa7740cd7d245d1b22a25fea9df0768d32668 (patch)
tree728fa422d3a2abc66a3e2d89e4ef03b72074bb3e /libraries/daguerre/include
parentb1a912a8a6ff472a49b2e0a09cfd433adfc2cb24 (diff)
downloadhilbert-os-e60fa7740cd7d245d1b22a25fea9df0768d32668.tar.gz
mouse support (working in qemu, semi-working in virtualbox)
Diffstat (limited to 'libraries/daguerre/include')
-rw-r--r--libraries/daguerre/include/daguerre.hpp34
1 files changed, 15 insertions, 19 deletions
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 <stdint.h>
+#include <cstring>
#include <cstdio>
namespace daguerre {
@@ -13,14 +14,6 @@ namespace daguerre {
uint8_t b;
};
- template <class to_type, class from_type>
- to_type convert_color(const from_type &from);
-
- template <>
- inline hilbert_color convert_color<hilbert_color, rgb24>(const rgb24 &from) {
- return __euler_encode_color(from.r, from.g, from.b);
- }
-
template <class color_t>
class image {
@@ -88,15 +81,15 @@ namespace daguerre {
//from [from_x, from_x + width) x [from_y, from_y + height).
template <class color_t>
void copy_region(
- image<color_t> &to, const image<color_t> &from, unsigned from_x,
- unsigned from_y, unsigned to_x, unsigned to_y, unsigned width,
- unsigned height) {
+ image<color_t> &to, unsigned to_x, unsigned to_y,
+ const image<color_t> &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<to_color_t, from_color_t>>
- void copy_region(
- image<to_color_t> &to, const image<from_color_t> &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_color_t> &to, unsigned to_x, unsigned to_y,
+ const image<from_color_t> &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<hilbert_color> get_hilbert_framebuffer();