mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
WindowServer: Flush display buffer when flashing
If the device requires a flush and we modify the front buffer, we need to flush those changes to the front buffer. This makes the flashing work using the VirtIOGPU. Also fix a minor bug where we flushed the front buffer instead of the back buffer after flipping, which caused the VirtIOGPU to not work as expected when using the SDL backend and disabling buffer flipping.
This commit is contained in:
parent
02651f8dc6
commit
83b512789c
3 changed files with 40 additions and 5 deletions
|
@ -591,15 +591,28 @@ void Compositor::flush(Screen& screen)
|
|||
}
|
||||
screen_data.m_have_flush_rects = false;
|
||||
|
||||
auto screen_rect = screen.rect();
|
||||
if (m_flash_flush) {
|
||||
for (auto& rect : screen_data.m_flush_rects.rects())
|
||||
Gfx::IntRect bounding_flash;
|
||||
for (auto& rect : screen_data.m_flush_rects.rects()) {
|
||||
screen_data.m_front_painter->fill_rect(rect, Color::Yellow);
|
||||
for (auto& rect : screen_data.m_flush_transparent_rects.rects())
|
||||
bounding_flash = bounding_flash.united(rect);
|
||||
}
|
||||
for (auto& rect : screen_data.m_flush_transparent_rects.rects()) {
|
||||
screen_data.m_front_painter->fill_rect(rect, Color::Green);
|
||||
usleep(10000);
|
||||
bounding_flash = bounding_flash.united(rect);
|
||||
}
|
||||
if (!bounding_flash.is_empty()) {
|
||||
if (device_can_flush_buffers) {
|
||||
// If the device needs a flush we need to let it know that we
|
||||
// modified the front buffer!
|
||||
bounding_flash.translate_by(-screen_rect.location());
|
||||
screen.flush_display_front_buffer((!screen_data.m_screen_can_set_buffer || !screen_data.m_buffers_are_flipped) ? 0 : 1, bounding_flash);
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
auto screen_rect = screen.rect();
|
||||
if (device_can_flush_buffers && screen_data.m_screen_can_set_buffer) {
|
||||
if (!screen_data.m_has_flipped) {
|
||||
// If we have not flipped any buffers before, we should be flushing
|
||||
|
@ -680,7 +693,7 @@ void Compositor::flush(Screen& screen)
|
|||
// Instead, we skip this step and just keep track of them until shortly before the next flip.
|
||||
// If we however don't support flipping buffers then we need to flush the changed areas right
|
||||
// now so that they can be sent to the device.
|
||||
screen.flush_display(screen_data.m_buffers_are_flipped ? 0 : 1);
|
||||
screen.flush_display(screen_data.m_buffers_are_flipped ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue