mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
Kernel: Simplify VirtIOGPU attach_physical_range_to_framebuffer method
According to the specification, modesetting can be invoked with no need for flushing the framebuffer nor with DMA to transfer the framebuffer rendering.
This commit is contained in:
parent
657bc71247
commit
3337a5722a
3 changed files with 0 additions and 67 deletions
|
@ -185,65 +185,6 @@ void VirtIODisplayConnector::clear_to_black()
|
|||
}
|
||||
}
|
||||
|
||||
void VirtIODisplayConnector::draw_ntsc_test_pattern(Badge<VirtIOGraphicsAdapter>)
|
||||
{
|
||||
constexpr u8 colors[12][4] = {
|
||||
{ 0xff, 0xff, 0xff, 0xff }, // White
|
||||
{ 0x00, 0xff, 0xff, 0xff }, // Primary + Composite colors
|
||||
{ 0xff, 0xff, 0x00, 0xff },
|
||||
{ 0x00, 0xff, 0x00, 0xff },
|
||||
{ 0xff, 0x00, 0xff, 0xff },
|
||||
{ 0x00, 0x00, 0xff, 0xff },
|
||||
{ 0xff, 0x00, 0x00, 0xff },
|
||||
{ 0xba, 0x01, 0x5f, 0xff }, // Dark blue
|
||||
{ 0x8d, 0x3d, 0x00, 0xff }, // Purple
|
||||
{ 0x22, 0x22, 0x22, 0xff }, // Shades of gray
|
||||
{ 0x10, 0x10, 0x10, 0xff },
|
||||
{ 0x00, 0x00, 0x00, 0xff },
|
||||
};
|
||||
size_t width = m_display_info.rect.width;
|
||||
size_t height = m_display_info.rect.height;
|
||||
u8* data = framebuffer_data();
|
||||
// Draw NTSC test card
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
for (size_t y = 0; y < height; ++y) {
|
||||
for (size_t x = 0; x < width; ++x) {
|
||||
size_t color = 0;
|
||||
if (3 * y < 2 * height) {
|
||||
// Top 2/3 of image is 7 vertical stripes of color spectrum
|
||||
color = (7 * x) / width;
|
||||
} else if (4 * y < 3 * height) {
|
||||
// 2/3 mark to 3/4 mark is backwards color spectrum alternating with black
|
||||
auto segment = (7 * x) / width;
|
||||
color = segment % 2 ? 10 : 6 - segment;
|
||||
} else {
|
||||
if (28 * x < 5 * width) {
|
||||
color = 8;
|
||||
} else if (28 * x < 10 * width) {
|
||||
color = 0;
|
||||
} else if (28 * x < 15 * width) {
|
||||
color = 7;
|
||||
} else if (28 * x < 20 * width) {
|
||||
color = 10;
|
||||
} else if (7 * x < 6 * width) {
|
||||
// Grayscale gradient
|
||||
color = 26 - ((21 * x) / width);
|
||||
} else {
|
||||
// Solid black
|
||||
color = 10;
|
||||
}
|
||||
}
|
||||
u8* pixel = &data[4 * (y * width + x)];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
pixel[i] = colors[color][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
data = data + (width * height * sizeof(u32));
|
||||
}
|
||||
dbgln_if(VIRTIO_DEBUG, "Finish drawing the pattern");
|
||||
}
|
||||
|
||||
ErrorOr<void> VirtIODisplayConnector::flush_displayed_image(Graphics::VirtIOGPU::Protocol::Rect const& dirty_rect, bool main_buffer)
|
||||
{
|
||||
VERIFY(m_graphics_adapter->operation_lock().is_locked());
|
||||
|
|
|
@ -37,8 +37,6 @@ public:
|
|||
Graphics::VirtIOGPU::ScanoutID scanout_id() const { return m_scanout_id; }
|
||||
Graphics::VirtIOGPU::Protocol::DisplayInfoResponse::Display display_information(Badge<VirtIOGraphicsAdapter>) const;
|
||||
|
||||
void draw_ntsc_test_pattern(Badge<VirtIOGraphicsAdapter>);
|
||||
|
||||
void initialize_console(Badge<VirtIOGraphicsAdapter>);
|
||||
|
||||
private:
|
||||
|
|
|
@ -121,12 +121,6 @@ ErrorOr<void> VirtIOGraphicsAdapter::attach_physical_range_to_framebuffer(VirtIO
|
|||
TRY(ensure_backing_storage(buffer.resource_id, connector.framebuffer_region(), buffer.framebuffer_offset, framebuffer_size));
|
||||
// 3. Use VIRTIO_GPU_CMD_SET_SCANOUT to link the framebuffer to a display scanout.
|
||||
TRY(set_scanout_resource(connector.scanout_id(), buffer.resource_id, display_info.rect));
|
||||
// 4. Render our test pattern
|
||||
connector.draw_ntsc_test_pattern({});
|
||||
// 5. Use VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D to update the host resource from guest memory.
|
||||
TRY(transfer_framebuffer_data_to_host(connector.scanout_id(), buffer.resource_id, display_info.rect));
|
||||
// 6. Use VIRTIO_GPU_CMD_RESOURCE_FLUSH to flush the updated resource to the display.
|
||||
TRY(flush_displayed_image(buffer.resource_id, display_info.rect));
|
||||
|
||||
// Make sure we constrain the existing dirty rect (if any)
|
||||
if (buffer.dirty_rect.width != 0 || buffer.dirty_rect.height != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue