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.
This commit is contained in:
Liav A 2021-09-21 10:56:32 +03:00 committed by Idan Horowitz
parent f476b49fd8
commit c7eb761b7f
Notes: sideshowbarker 2024-07-18 01:51:15 +09:00
3 changed files with 15 additions and 15 deletions

View File

@ -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 = {};
}

View File

@ -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()

View File

@ -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;