1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

WindowServer: Drop support for the DisplayConnector write interface

All DisplayConnectors should support the mmap interface and it should
provide better performance now, so let's just use it and drop support
for the DisplayConnector's write interface from the WindowServer side.
This commit is contained in:
Liav A 2022-05-13 03:25:16 +03:00 committed by Linus Groh
parent e2ed6ef741
commit f62cd52d12
6 changed files with 5 additions and 36 deletions

View file

@ -724,13 +724,6 @@ void Compositor::flush(Screen& screen)
// now so that they can be sent to the device.
screen.flush_display(screen_data.m_buffers_are_flipped ? 1 : 0);
}
// Note: We write all contents from the internal buffer of WindowServer Screen
// to the actual framebuffer with the write() syscall, but after we flush the screen
// to ensure we are in a "clean state"...
// FIXME: This write is completely inefficient and needs to be done in chunks
// only when appropriate...
screen.write_all_display_contents();
}
void Compositor::invalidate_screen()

View file

@ -43,7 +43,7 @@ HardwareScreenBackend::~HardwareScreenBackend()
m_framebuffer_fd = -1;
}
if (m_framebuffer) {
free(m_framebuffer);
MUST(Core::System::munmap(m_framebuffer, m_size_in_bytes));
m_framebuffer = nullptr;
m_size_in_bytes = 0;
@ -71,22 +71,8 @@ ErrorOr<void> HardwareScreenBackend::set_head_mode_setting(GraphicsHeadModeSetti
ErrorOr<void> HardwareScreenBackend::unmap_framebuffer()
{
if (m_framebuffer) {
free(m_framebuffer);
}
return {};
}
ErrorOr<void> HardwareScreenBackend::write_all_contents(Gfx::IntRect const& virtual_rect)
{
lseek(m_framebuffer_fd, 0, SEEK_SET);
write(m_framebuffer_fd, scanline(0, 0), virtual_rect.height() * m_pitch);
if (m_can_set_head_buffer) {
if (lseek(m_framebuffer_fd, virtual_rect.height() * m_pitch, SEEK_SET) < 0) {
VERIFY_NOT_REACHED();
}
if (write(m_framebuffer_fd, scanline(0, 0), virtual_rect.height() * m_pitch) < 0)
VERIFY_NOT_REACHED();
size_t previous_size_in_bytes = m_size_in_bytes;
return Core::System::munmap(m_framebuffer, previous_size_in_bytes);
}
return {};
}
@ -100,7 +86,8 @@ ErrorOr<void> HardwareScreenBackend::map_framebuffer()
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
}
m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
m_framebuffer = (Gfx::ARGB32*)malloc(m_size_in_bytes);
m_framebuffer = (Gfx::ARGB32*)TRY(Core::System::mmap(nullptr, m_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebuffer_fd, 0));
if (m_can_set_head_buffer) {
// Note: fall back to assuming the second buffer starts right after the last line of the first
// Note: for now, this calculation works quite well, so need to defer it to another function

View file

@ -34,8 +34,6 @@ public:
virtual ErrorOr<void> set_head_mode_setting(GraphicsHeadModeSetting) override;
virtual ErrorOr<GraphicsHeadModeSetting> get_head_mode_setting() override;
virtual ErrorOr<void> write_all_contents(Gfx::IntRect const&) override;
String m_device {};
int m_framebuffer_fd { -1 };

View file

@ -558,11 +558,6 @@ void Screen::flush_display(int buffer_index)
flush_rects.pending_flush_rects.clear_with_capacity();
}
void Screen::write_all_display_contents()
{
MUST(m_backend->write_all_contents(m_physical_rect));
}
void Screen::flush_display_entire_framebuffer()
{
VERIFY(m_backend->m_can_device_flush_entire_framebuffer);

View file

@ -176,8 +176,6 @@ public:
CompositorScreenData& compositor_screen_data() { return *m_compositor_screen_data; }
void write_all_display_contents();
private:
Screen(size_t);
bool open_device();

View file

@ -37,8 +37,6 @@ public:
virtual ErrorOr<void> set_head_mode_setting(GraphicsHeadModeSetting) = 0;
virtual ErrorOr<GraphicsHeadModeSetting> get_head_mode_setting() = 0;
virtual ErrorOr<void> write_all_contents(Gfx::IntRect const&) { return {}; }
bool m_can_device_flush_buffers { true };
bool m_can_device_flush_entire_framebuffer { true };
bool m_can_set_head_buffer { false };