mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
WindowServer: Coalesce flushing buffers into one ioctl() call
We regularily need to flush many rectangles, so instead of making many expensive ioctl() calls to the framebuffer driver, collect the rectangles and only make one call. And if we have too many rectangles then it may be cheaper to just update the entire region, in which case we simply convert them all into a union and just flush that one rectangle instead.
This commit is contained in:
parent
56cd0f929e
commit
38af4c29e6
7 changed files with 123 additions and 31 deletions
|
@ -147,18 +147,26 @@ int VirtIOFrameBufferDevice::ioctl(FileDescription&, unsigned request, FlatPtr a
|
|||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
case FB_IOCTL_FLUSH_BUFFER: {
|
||||
FBRect user_dirty_rect;
|
||||
if (!copy_from_user(&user_dirty_rect, (FBRect*)arg))
|
||||
case FB_IOCTL_FLUSH_BUFFERS: {
|
||||
FBRects user_dirty_rects;
|
||||
if (!copy_from_user(&user_dirty_rects, (FBRects*)arg))
|
||||
return -EFAULT;
|
||||
VirtIOGPURect dirty_rect {
|
||||
.x = user_dirty_rect.x,
|
||||
.y = user_dirty_rect.y,
|
||||
.width = user_dirty_rect.width,
|
||||
.height = user_dirty_rect.height
|
||||
};
|
||||
if (m_are_writes_active)
|
||||
flush_dirty_window(dirty_rect);
|
||||
if (Checked<unsigned>::multiplication_would_overflow(user_dirty_rects.count, sizeof(FBRect)))
|
||||
return -EFAULT;
|
||||
for (unsigned i = 0; i < user_dirty_rects.count; i++) {
|
||||
FBRect user_dirty_rect;
|
||||
if (!copy_from_user(&user_dirty_rect, &user_dirty_rects.rects[i]))
|
||||
return -EFAULT;
|
||||
if (m_are_writes_active) {
|
||||
VirtIOGPURect dirty_rect {
|
||||
.x = user_dirty_rect.x,
|
||||
.y = user_dirty_rect.y,
|
||||
.width = user_dirty_rect.width,
|
||||
.height = user_dirty_rect.height
|
||||
};
|
||||
flush_dirty_window(dirty_rect);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue