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

Kernel: VirtIO framebuffer should clamp pending dirty rects if needed

If we change to a resolution smaller than what any pending dirty
rectangles contain, we need to clamp them to the new resolution.
This commit is contained in:
Tom 2021-07-18 10:11:27 -06:00 committed by Andreas Kling
parent 8a6f69f2c8
commit 5ae42736f8

View file

@ -73,6 +73,14 @@ void FrameBufferDevice::create_buffer(Buffer& buffer, size_t framebuffer_offset,
if (&buffer == m_current_buffer)
flush_displayed_image(info.rect, buffer);
// Make sure we constrain the existing dirty rect (if any)
if (buffer.dirty_rect.width != 0 || buffer.dirty_rect.height != 0) {
auto dirty_right = buffer.dirty_rect.x + buffer.dirty_rect.width;
auto dirty_bottom = buffer.dirty_rect.y + buffer.dirty_rect.height;
buffer.dirty_rect.width = min(dirty_right, info.rect.x + info.rect.width) - buffer.dirty_rect.x;
buffer.dirty_rect.height = min(dirty_bottom, info.rect.y + info.rect.height) - buffer.dirty_rect.y;
}
info.enabled = 1;
}