summaryrefslogtreecommitdiff
path: root/Kernel/Graphics/VirtIOGPU
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-09-21 10:56:32 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2021-10-27 07:57:44 +0300
commitc7eb761b7f298ba9bf91510f8ee2b62ad6e29fb5 (patch)
tree283084380851828cad7461fbc4d59d1d134a1855 /Kernel/Graphics/VirtIOGPU
parentf476b49fd831161184df7829b6a8d9d6cf67febd (diff)
downloadserenity-c7eb761b7f298ba9bf91510f8ee2b62ad6e29fb5.zip
Kernel/Graphics: Re-order parameters in VirtIO GraphicsAdapter methods
As suggested by @ccapitalK, it makes the interface more neat and clean. The proper order is to get ScanoutID first, then ResourceID and after it everything else that is needed to complete the operation successfully.
Diffstat (limited to 'Kernel/Graphics/VirtIOGPU')
-rw-r--r--Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp10
-rw-r--r--Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp12
-rw-r--r--Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h8
3 files changed, 15 insertions, 15 deletions
diff --git a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp
index 6f11e06799..b8fe17ca5a 100644
--- a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp
+++ b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp
@@ -76,7 +76,7 @@ void FramebufferDevice::create_buffer(Buffer& buffer, size_t framebuffer_offset,
buffer.resource_id = adapter().create_2d_resource(info.rect);
// 2. Attach backing storage using VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING
- adapter().ensure_backing_storage(*m_framebuffer, buffer.framebuffer_offset, framebuffer_size, buffer.resource_id);
+ adapter().ensure_backing_storage(buffer.resource_id, *m_framebuffer, buffer.framebuffer_offset, framebuffer_size);
// 3. Use VIRTIO_GPU_CMD_SET_SCANOUT to link the framebuffer to a display scanout.
if (&buffer == m_current_buffer)
adapter().set_scanout_resource(m_scanout.value(), buffer.resource_id, info.rect);
@@ -111,17 +111,17 @@ Protocol::DisplayInfoResponse::Display& FramebufferDevice::display_info()
void FramebufferDevice::transfer_framebuffer_data_to_host(Protocol::Rect const& rect, Buffer& buffer)
{
- adapter().transfer_framebuffer_data_to_host(m_scanout, rect, buffer.resource_id);
+ adapter().transfer_framebuffer_data_to_host(m_scanout, buffer.resource_id, rect);
}
void FramebufferDevice::flush_dirty_window(Protocol::Rect const& dirty_rect, Buffer& buffer)
{
- adapter().flush_dirty_rectangle(m_scanout, dirty_rect, buffer.resource_id);
+ adapter().flush_dirty_rectangle(m_scanout, buffer.resource_id, dirty_rect);
}
void FramebufferDevice::flush_displayed_image(Protocol::Rect const& dirty_rect, Buffer& buffer)
{
- adapter().flush_displayed_image(dirty_rect, buffer.resource_id);
+ adapter().flush_displayed_image(buffer.resource_id, dirty_rect);
}
KResult FramebufferDevice::try_to_set_resolution(size_t width, size_t height)
@@ -151,7 +151,7 @@ void FramebufferDevice::set_buffer(int buffer_index)
return;
m_current_buffer = &buffer;
adapter().set_scanout_resource(m_scanout.value(), buffer.resource_id, display_info().rect);
- adapter().flush_displayed_image(buffer.dirty_rect, buffer.resource_id); // QEMU SDL backend requires this (as per spec)
+ adapter().flush_displayed_image(buffer.resource_id, buffer.dirty_rect); // QEMU SDL backend requires this (as per spec)
buffer.dirty_rect = {};
}
diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
index 22f801cc43..1eb4d1824b 100644
--- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
+++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
@@ -186,7 +186,7 @@ ResourceID GraphicsAdapter::create_2d_resource(Protocol::Rect rect)
return resource_id;
}
-void GraphicsAdapter::ensure_backing_storage(Memory::Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id)
+void GraphicsAdapter::ensure_backing_storage(ResourceID resource_id, Memory::Region const& region, size_t buffer_offset, size_t buffer_length)
{
VERIFY(m_operation_lock.is_locked());
@@ -250,7 +250,7 @@ void GraphicsAdapter::set_scanout_resource(ScanoutID scanout, ResourceID resourc
dbgln_if(VIRTIO_DEBUG, "VirtIO::GraphicsAdapter: Set backing scanout");
}
-void GraphicsAdapter::transfer_framebuffer_data_to_host(ScanoutID scanout, Protocol::Rect const& dirty_rect, ResourceID resource_id)
+void GraphicsAdapter::transfer_framebuffer_data_to_host(ScanoutID scanout, ResourceID resource_id, Protocol::Rect const& dirty_rect)
{
VERIFY(m_operation_lock.is_locked());
auto writer = create_scratchspace_writer();
@@ -267,7 +267,7 @@ void GraphicsAdapter::transfer_framebuffer_data_to_host(ScanoutID scanout, Proto
VERIFY(response.type == static_cast<u32>(Protocol::CommandType::VIRTIO_GPU_RESP_OK_NODATA));
}
-void GraphicsAdapter::flush_displayed_image(Protocol::Rect const& dirty_rect, ResourceID resource_id)
+void GraphicsAdapter::flush_displayed_image(ResourceID resource_id, Protocol::Rect const& dirty_rect)
{
VERIFY(m_operation_lock.is_locked());
auto writer = create_scratchspace_writer();
@@ -308,11 +308,11 @@ void GraphicsAdapter::populate_virtio_gpu_request_header(Protocol::ControlHeader
header.padding = 0;
}
-void GraphicsAdapter::flush_dirty_rectangle(ScanoutID scanout_id, Protocol::Rect const& dirty_rect, ResourceID resource_id)
+void GraphicsAdapter::flush_dirty_rectangle(ScanoutID scanout_id, ResourceID resource_id, Protocol::Rect const& dirty_rect)
{
MutexLocker locker(m_operation_lock);
- transfer_framebuffer_data_to_host(scanout_id, dirty_rect, resource_id);
- flush_displayed_image(dirty_rect, resource_id);
+ transfer_framebuffer_data_to_host(scanout_id, resource_id, dirty_rect);
+ flush_displayed_image(resource_id, dirty_rect);
}
ResourceID GraphicsAdapter::allocate_resource_id()
diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
index 9ffc881595..78dd2dc4ce 100644
--- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
+++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
@@ -49,7 +49,7 @@ public:
virtual void initialize() override;
private:
- void flush_dirty_rectangle(ScanoutID, Protocol::Rect const& dirty_rect, ResourceID);
+ void flush_dirty_rectangle(ScanoutID, ResourceID, Protocol::Rect const& dirty_rect);
template<typename F>
IterationDecision for_each_framebuffer(F f)
@@ -120,11 +120,11 @@ private:
void query_display_information();
ResourceID create_2d_resource(Protocol::Rect rect);
void delete_resource(ResourceID resource_id);
- void ensure_backing_storage(Memory::Region const& region, size_t buffer_offset, size_t buffer_length, ResourceID resource_id);
+ void ensure_backing_storage(ResourceID resource_id, Memory::Region const& region, size_t buffer_offset, size_t buffer_length);
void detach_backing_storage(ResourceID resource_id);
void set_scanout_resource(ScanoutID scanout, ResourceID resource_id, Protocol::Rect rect);
- void transfer_framebuffer_data_to_host(ScanoutID scanout, Protocol::Rect const& rect, ResourceID resource_id);
- void flush_displayed_image(Protocol::Rect const& dirty_rect, ResourceID resource_id);
+ void transfer_framebuffer_data_to_host(ScanoutID scanout, ResourceID resource_id, Protocol::Rect const& rect);
+ void flush_displayed_image(ResourceID resource_id, Protocol::Rect const& dirty_rect);
bool m_created_framebuffer_devices { false };
Optional<ScanoutID> m_default_scanout;