vbe: Ensure that the format is xRGB8888 for the graphical menu

This commit is contained in:
mintsuki 2020-11-09 11:15:54 +01:00
parent cfb1734f43
commit 495b1570db
6 changed files with 19 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -316,9 +316,18 @@ void vbe_putchar(char c) {
}
}
void vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
bool vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _margin_gradient, struct image *_background) {
init_vbe(&fbinfo, 0, 0, 0);
// Ensure this is xRGB8888, we only support that for the menu
if (fbinfo.red_mask_size != 8
|| fbinfo.red_mask_shift != 16
|| fbinfo.green_mask_size != 8
|| fbinfo.green_mask_shift != 8
|| fbinfo.blue_mask_size != 8
|| fbinfo.blue_mask_shift != 0)
return false;
vbe_framebuffer = (void *)fbinfo.framebuffer_addr;
vbe_width = fbinfo.framebuffer_width;
vbe_height = fbinfo.framebuffer_height;
@ -348,6 +357,8 @@ void vbe_tty_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _
vbe_plot_background(0, 0, vbe_width, vbe_height);
vbe_clear(true);
return true;
}
struct vbe_info_struct {

View File

@ -23,7 +23,7 @@ struct vbe_framebuffer_info {
bool init_vbe(struct vbe_framebuffer_info *ret,
uint16_t target_width, uint16_t target_height, uint16_t target_bpp);
void vbe_tty_init(int *rows, int *cols, uint32_t *colours, int margin, int margin_gradient, struct image *background);
bool vbe_tty_init(int *rows, int *cols, uint32_t *colours, int margin, int margin_gradient, struct image *background);
void vbe_putchar(char c);
void vbe_clear(bool move);

View File

@ -43,6 +43,7 @@ static uint32_t get_pixel(struct image *this, int x, int y) {
size_t pixel_offset = local->pitch * (header->bi_height - y - 1) + x * (header->bi_bpp / 8);
// TODO: Perhaps use masks here, they're there for a reason
uint32_t composite = 0;
for (int i = 0; i < header->bi_bpp / 8; i++)
composite |= (uint32_t)local->image[pixel_offset + i] << (i * 8);

View File

@ -26,7 +26,11 @@ int term_rows, term_cols;
void term_vbe(uint32_t *colours, int margin, int margin_gradient, struct image *background) {
term_deinit();
vbe_tty_init(&term_rows, &term_cols, colours, margin, margin_gradient, background);
if (!vbe_tty_init(&term_rows, &term_cols, colours, margin, margin_gradient, background)) {
// Failed to set VBE properly, default to text mode
term_textmode();
return;
}
raw_putchar = vbe_putchar;
clear = vbe_clear;