mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel/Graphics: Flush the entire buffer if using VirtIO console
Keeping the exact details of a dirty rectangle doesn't make any sense when we just flush the entire screen, so just keep a simple boolean value to know if the screen needs to be flushed or not.
This commit is contained in:
parent
6fca2134d2
commit
d84d81fc4e
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/d84d81fc4e Pull-request: https://github.com/SerenityOS/serenity/pull/14029 Reviewed-by: https://github.com/FireFox317 Reviewed-by: https://github.com/linusg
2 changed files with 6 additions and 43 deletions
|
@ -11,24 +11,6 @@ namespace Kernel::Graphics::VirtIOGPU {
|
|||
|
||||
constexpr static AK::Time refresh_interval = AK::Time::from_milliseconds(16);
|
||||
|
||||
void DirtyRect::union_rect(size_t x, size_t y, size_t width, size_t height)
|
||||
{
|
||||
if (width == 0 || height == 0)
|
||||
return;
|
||||
if (m_is_dirty) {
|
||||
m_x0 = min(x, m_x0);
|
||||
m_y0 = min(y, m_y0);
|
||||
m_x1 = max(x + width, m_x1);
|
||||
m_y1 = max(y + height, m_y1);
|
||||
} else {
|
||||
m_is_dirty = true;
|
||||
m_x0 = x;
|
||||
m_y0 = y;
|
||||
m_x1 = x + width;
|
||||
m_y1 = y + height;
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<Console> Console::initialize(VirtIODisplayConnector& parent_display_connector)
|
||||
{
|
||||
auto current_resolution = parent_display_connector.current_mode_setting();
|
||||
|
@ -47,23 +29,22 @@ void Console::set_resolution(size_t, size_t, size_t)
|
|||
// FIXME: Update some values here?
|
||||
}
|
||||
|
||||
void Console::flush(size_t x, size_t y, size_t width, size_t height)
|
||||
void Console::flush(size_t, size_t, size_t, size_t)
|
||||
{
|
||||
m_dirty_rect.union_rect(x, y, width, height);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void Console::enqueue_refresh_timer()
|
||||
{
|
||||
NonnullRefPtr<Timer> refresh_timer = adopt_ref(*new Timer());
|
||||
refresh_timer->setup(CLOCK_MONOTONIC, refresh_interval, [this]() {
|
||||
auto rect = m_dirty_rect;
|
||||
if (m_enabled.load() && rect.is_dirty()) {
|
||||
if (m_enabled.load() && m_dirty) {
|
||||
MUST(g_io_work->try_queue([this]() {
|
||||
{
|
||||
MutexLocker locker(m_parent_display_connector->m_flushing_lock);
|
||||
MUST(m_parent_display_connector->flush_first_surface());
|
||||
}
|
||||
m_dirty_rect.clear();
|
||||
m_dirty = false;
|
||||
}));
|
||||
}
|
||||
enqueue_refresh_timer();
|
||||
|
@ -78,7 +59,7 @@ void Console::enable()
|
|||
m_width = current_resolution.horizontal_active;
|
||||
m_height = current_resolution.vertical_active;
|
||||
m_pitch = current_resolution.horizontal_stride;
|
||||
m_dirty_rect.union_rect(0, 0, m_width, m_height);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
u8* Console::framebuffer_data()
|
||||
|
|
|
@ -12,24 +12,6 @@
|
|||
|
||||
namespace Kernel::Graphics::VirtIOGPU {
|
||||
|
||||
class DirtyRect {
|
||||
public:
|
||||
void union_rect(size_t x, size_t y, size_t width, size_t height);
|
||||
bool is_dirty() const { return m_is_dirty; }
|
||||
size_t x() const { return m_x0; }
|
||||
size_t y() const { return m_y0; }
|
||||
size_t width() const { return m_x1 - m_x0; }
|
||||
size_t height() const { return m_y1 - m_y0; }
|
||||
void clear() { m_is_dirty = false; }
|
||||
|
||||
private:
|
||||
bool m_is_dirty { false };
|
||||
size_t m_x0 { 0 };
|
||||
size_t m_y0 { 0 };
|
||||
size_t m_x1 { 0 };
|
||||
size_t m_y1 { 0 };
|
||||
};
|
||||
|
||||
class Console final : public GenericFramebufferConsole {
|
||||
public:
|
||||
static NonnullRefPtr<Console> initialize(VirtIODisplayConnector& parent_display_connector);
|
||||
|
@ -44,7 +26,7 @@ private:
|
|||
|
||||
Console(VirtIODisplayConnector const& parent_display_connector, DisplayConnector::ModeSetting current_resolution);
|
||||
NonnullRefPtr<VirtIODisplayConnector> m_parent_display_connector;
|
||||
DirtyRect m_dirty_rect;
|
||||
bool m_dirty { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue