Kernel: Add fast fill method to framebuffer device

This makes `clear` much faster when running without kvm!
This commit is contained in:
Bananymous 2025-07-01 13:53:19 +03:00
parent c2d09b64ca
commit fb7e9719a1
3 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,7 @@ namespace Kernel
uint32_t get_pixel(uint32_t x, uint32_t y) const;
void set_pixel(uint32_t x, uint32_t y, uint32_t rgb);
void fill(uint32_t rgb);
// positive rows -> empty pixels on bottom
// negative rows -> empty pixels on top

View File

@ -140,6 +140,14 @@ namespace Kernel
reinterpret_cast<uint32_t*>(m_video_buffer->vaddr())[y * m_width + x] = rgb;
}
void FramebufferDevice::fill(uint32_t rgb)
{
static_assert(BANAN_FB_BPP == 32);
auto* video_buffer_u32 = reinterpret_cast<uint32_t*>(m_video_buffer->vaddr());
for (uint32_t i = 0; i < m_width * m_height; i++)
video_buffer_u32[i] = rgb;
}
void FramebufferDevice::scroll(int32_t rows, uint32_t rgb)
{
if (rows == 0)

View File

@ -79,9 +79,7 @@ namespace Kernel
for (auto& pixel : m_cursor_data)
pixel = color.rgb;
for (uint32_t y = 0; y < m_framebuffer_device->height(); y++)
for (uint32_t x = 0; x < m_framebuffer_device->width(); x++)
m_framebuffer_device->set_pixel(x, y, color.rgb);
m_framebuffer_device->fill(color.rgb);
m_framebuffer_device->sync_pixels_full();
if (m_cursor_shown)