add fb_fill()
This commit is contained in:
parent
dba3d28bbf
commit
41152cb4ca
15
src/fb.c
15
src/fb.c
@ -95,3 +95,18 @@ void fb_blend_alpha8(const uint8_t * bitmap, int width, int height, int pitch, i
|
||||
target += (fb_pitch / 4u);
|
||||
}
|
||||
}
|
||||
|
||||
void fb_fill(int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
uint32_t * target = &fb[fb_pitch * y / 4u + x];
|
||||
uint32_t pixel = build_pixel(r, g, b);
|
||||
/* TODO: use memset32() */
|
||||
for (int row = 0; row < height; row++)
|
||||
{
|
||||
for (int col = 0; col < width; col++)
|
||||
{
|
||||
target[col] = pixel;
|
||||
}
|
||||
target += fb_pitch / 4u;
|
||||
}
|
||||
}
|
||||
|
1
src/fb.h
1
src/fb.h
@ -7,5 +7,6 @@
|
||||
void fb_init(uint32_t * addr, uint32_t width, uint32_t height, uint32_t pitch);
|
||||
bool fb_ready(void);
|
||||
void fb_blend_alpha8(const uint8_t * bitmap, int width, int height, int pitch, int x, int y, uint8_t r, uint8_t g, uint8_t b);
|
||||
void fb_fill(int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
#endif
|
||||
|
11
src/fb_text.c
Normal file
11
src/fb_text.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "fb_text.h"
|
||||
#include "kfont.h"
|
||||
#include "fb.h"
|
||||
|
||||
void fb_text_render_char(int c, int x, int y, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
const fontgen_char_info_t * char_info = kfont.char_infos[c];
|
||||
y += kfont.line_height - kfont.baseline_offset - char_info->top;
|
||||
x += char_info->left;
|
||||
fb_blend_alpha8(char_info->bitmap, char_info->width, char_info->height, char_info->width, x, y, 0xFFu, 0x88u, 0u);
|
||||
}
|
8
src/fb_text.h
Normal file
8
src/fb_text.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef FB_TEXT_H
|
||||
#define FB_TEXT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void fb_text_render_char(int c, int x, int y, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include "fb.h"
|
||||
#include "fb_text.h"
|
||||
#include "mbinfo.h"
|
||||
#include "kfont.h"
|
||||
|
||||
@ -10,6 +11,5 @@ void hos_main(uint32_t mbinfo_addr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const fontgen_char_info_t * char_info = kfont.char_infos['H'];
|
||||
fb_blend_alpha8(char_info->bitmap, char_info->width, char_info->height, char_info->width, 10, 10, 0xFFu, 0x88u, 0u);
|
||||
fb_text_render_char('H', 10, 10, 0xFFu, 0x88u, 0u);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user