summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-07-18 10:11:27 -0600
committerAndreas Kling <kling@serenityos.org>2021-07-21 00:06:58 +0200
commit5ae42736f8162afab49be35b0fbe5f0587d3f9ca (patch)
treea79262eeef155a2b7766fbf540195e8a2f2baeeb /Kernel/Graphics
parent8a6f69f2c87b3a13ce4705f2f6ca0c6dcc9a89cb (diff)
downloadserenity-5ae42736f8162afab49be35b0fbe5f0587d3f9ca.zip
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.
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
index 005feae366..4ea92dcb99 100644
--- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
+++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.cpp
@@ -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;
}