mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel/Graphics: Implement basic cursor for FramebufferConsole
This commit is contained in:
parent
00a0b1bd14
commit
0d784de3a6
Notes:
sideshowbarker
2024-07-17 11:15:16 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/0d784de3a6 Pull-request: https://github.com/SerenityOS/serenity/pull/13924
2 changed files with 19 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue