summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-05-06 03:19:27 +0300
committerLinus Groh <mail@linusgroh.de>2022-05-06 12:28:02 +0200
commit0d784de3a666898ba40c00fdac85917e4426437e (patch)
tree02ae05a8b7aa6f68e70efb5db40672e617603dd9 /Kernel
parent00a0b1bd1475dcd393a09c667629bfd5fa0f1057 (diff)
downloadserenity-0d784de3a666898ba40c00fdac85917e4426437e.zip
Kernel/Graphics: Implement basic cursor for FramebufferConsole
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Graphics/Console/GenericFramebufferConsole.cpp17
-rw-r--r--Kernel/Graphics/Console/GenericFramebufferConsole.h3
2 files changed, 19 insertions, 1 deletions
diff --git a/Kernel/Graphics/Console/GenericFramebufferConsole.cpp b/Kernel/Graphics/Console/GenericFramebufferConsole.cpp
index d77471a519..ed63eb73ad 100644
--- a/Kernel/Graphics/Console/GenericFramebufferConsole.cpp
+++ b/Kernel/Graphics/Console/GenericFramebufferConsole.cpp
@@ -213,16 +213,31 @@ size_t GenericFramebufferConsoleImpl::chars_per_line() const
return width() / bytes_per_base_glyph();
}
-void GenericFramebufferConsoleImpl::set_cursor(size_t, size_t)
+void GenericFramebufferConsoleImpl::set_cursor(size_t x, size_t y)
{
+ hide_cursor();
+ m_x = x;
+ m_y = y;
+ show_cursor();
}
void GenericFramebufferConsoleImpl::hide_cursor()
{
+ auto* offset_in_framebuffer = (u32*)&framebuffer_data()[m_x * sizeof(u32) * m_pixels_per_column + m_y * m_pixels_per_row * framebuffer_pitch()];
+ offset_in_framebuffer = (u32*)((u8*)offset_in_framebuffer + framebuffer_pitch() * 15);
+ for (size_t current_x = 0; current_x < m_pixels_per_column; current_x++) {
+ offset_in_framebuffer[current_x] = m_cursor_overriden_pixels[current_x];
+ }
}
void GenericFramebufferConsoleImpl::show_cursor()
{
+ auto* offset_in_framebuffer = (u32*)&framebuffer_data()[m_x * sizeof(u32) * m_pixels_per_column + m_y * m_pixels_per_row * framebuffer_pitch()];
+ offset_in_framebuffer = (u32*)((u8*)offset_in_framebuffer + framebuffer_pitch() * 15);
+ for (size_t current_x = 0; current_x < m_pixels_per_column; current_x++) {
+ m_cursor_overriden_pixels[current_x] = offset_in_framebuffer[current_x];
+ memset(offset_in_framebuffer + current_x, 0xff, 4);
+ }
}
void GenericFramebufferConsoleImpl::clear(size_t x, size_t y, size_t length)
diff --git a/Kernel/Graphics/Console/GenericFramebufferConsole.h b/Kernel/Graphics/Console/GenericFramebufferConsole.h
index 5eecdf4d9d..61f6950460 100644
--- a/Kernel/Graphics/Console/GenericFramebufferConsole.h
+++ b/Kernel/Graphics/Console/GenericFramebufferConsole.h
@@ -43,6 +43,7 @@ protected:
: Console(width, height)
, m_pitch(pitch)
{
+ m_cursor_overriden_pixels.fill(0);
}
virtual u8* framebuffer_data() = 0;
size_t framebuffer_pitch() const { return m_pitch; }
@@ -51,6 +52,8 @@ protected:
size_t const m_pixels_per_column { 8 };
size_t const m_pixels_per_row { 16 };
+ Array<u32, 8> m_cursor_overriden_pixels;
+
size_t m_pitch;
};