Skip to content

Commit e4e0e70

Browse files
authored
Fix memory region in framebuffer (#65)
If screen size is less than virtual resolution, it will draw multiple screens on display. Use 'line_length' for calculation instead of screen size. Changeable information like virtual resolution or virtual terminal settings may not apply across different hardware and drivers. e.g., on VirtualBox, virtual resolution is 2048x2048, visible resolution is 800x600, and line length is 2048 * 4. Any settings from guest machine to these may be ignored.
1 parent b458e28 commit e4e0e70

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

backend/fbdev.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ static void _twin_fbdev_put_span(twin_coord_t left,
5353
return;
5454

5555
twin_coord_t width = right - left;
56-
off_t off = top * screen->width + left;
57-
uint32_t *dest =
58-
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(*dest)));
56+
uint32_t *dest;
57+
off_t off = sizeof(*dest) * left + top * tx->fb_fix.line_length;
58+
dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
5959
memcpy(dest, pixels, width * sizeof(*dest));
6060
}
6161

0 commit comments

Comments
 (0)