Skip to content

Commit

Permalink
Fix memory region in framebuffer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a1091150 committed Nov 7, 2024
1 parent efe7d49 commit 144ff6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ static void _twin_fbdev_put_span(twin_coord_t left,
return;

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

Expand Down

0 comments on commit 144ff6d

Please sign in to comment.