Skip to content

Commit 144ff6d

Browse files
committed
Fix memory region in framebuffer
The size of the screen may be different to the virtual resolution. If the size is less than virtual resolution, it will draw multiple windows on display. Use `line_length` to calculate instead of the size of the screen. Changable information like virtual resoultion or setting different information on virtual terminal may not be applied on different hardware and driver. For example on VirtualBox, virtual resolution's width and height are 2048 and 2048, visible resolutions' are 800 and 600, and line length is 2048 * 4. Any setting from guest machine to these maybe ignored.
1 parent efe7d49 commit 144ff6d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

backend/fbdev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ static void _twin_fbdev_put_span(twin_coord_t left,
5656
return;
5757

5858
twin_coord_t width = right - left;
59-
off_t off = top * screen->width + left;
60-
uint32_t *dest =
61-
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(*dest)));
59+
uint32_t *dest;
60+
off_t off = sizeof(*dest) * left + top * tx->fb_fix.line_length;
61+
dest = (uint32_t *) ((uintptr_t) tx->fb_base + off);
6262
memcpy(dest, pixels, width * sizeof(*dest));
6363
}
6464

0 commit comments

Comments
 (0)