docs: documented the graphics renderer

This commit is contained in:
antifallobst 2023-02-21 11:55:36 +01:00
parent 885a7b1f31
commit 93706494ff
1 changed files with 102 additions and 0 deletions

View File

@ -280,6 +280,108 @@ This header provides the API to "communicate" with the limine bootloader.
More information can be found on the limine project's [GitHub](https://github.com/limine-bootloader/limine/blob/trunk/PROTOCOL.md).
## drivers
### graphics/color.h
#### `color_argb_T` - struct
| Name | Type | Description |
|-------|---------|---------------------------------|
| alpha | uint8_t | Transparency value of the color |
| red | uint8_t | Red value of the color |
| green | uint8_t | Green value of the color |
| blue | uint8_t | Blue value of the color |
#### `color_argb_blend_alpha(background, foreground)` - function (color_argb_T)
Blends **_background_** and **_foreground_** with the _alpha_ value of **_foreground_**.
### graphics/font.h
#### `font_T` - struct
| Name | Type | Description |
|------------|----------|------------------------------------------------|
| width | uint8_t | The width of each char (in pixels) |
| height | uint8_t | The height of each char (in pixels) |
| glyph_size | uint8_t | The amount of bytes a char takes in the buffer |
| buffer | uint8_t* | The buffer, where the char bitmaps lay |
#### `g_font` - global variable
A global usable 8x8 font.
### graphics/framebuffer.h
#### `framebuffer_T` - struct
| Name | Type | Description |
|-----------------|----------|-----------------------------------------------------|
| address | void* | The address of the framebuffer |
| width | uint64_t | The pixel width of the framebuffer |
| height | uint64_t | The pixel height of the framebuffer |
| pitch | uint64_t | The number of bytes in each row |
| bits_per_pixel | uint16_t | The amount of bits a pixel consumes in the buffer |
| bytes_per_pixel | uint8_t | The amount of bytes a pixel consumes in the buffer |
| shift_red | uint8_t | How many bits the red value is shifted in a pixel |
| shift_green | uint8_t | How many bits the green value is shifted in a pixel |
| shift_blue | uint8_t | How many bits the blue value is shifted in a pixel |
### graphics/renderer.h
#### `graphics_buffer_T` - struct
| Name | Type | Description |
|--------|--------------------|------------------------------------------------------------------------------|
| buffer | color_argb_T* | The buffer, where all the pixels are stored |
| width | uint32_t | The width of the buffer |
| height | uint32_t | The height of the buffer |
| pos_x | uint32_t | The buffers x offset (from the top-left corner) in the renderers main buffer |
| pos_y | uint32_t | The buffers y offset (from the top-left corner) in the renderers main buffer |
| prev | graphics_buffer_T* | The previous buffer in the rendering queue |
| next | graphics_buffer_T* | The next buffer in the rendering queue |
#### `graphics_renderer_T` - struct
| Name | Type | Description |
|------------------|--------------------|------------------------------------------------------------------------------------------|
| framebuffer | framebuffer_T | The systems framebuffer (requested from bootloader) |
| back_buffer | uint32_t* | The buffer, where the final image is calculated, before sending it to the framebuffer |
| buffer_size | uint64_t | The size of `back_buffer` (in bytes) |
| graphics_buffers | graphics_buffer_T* | Pointer to the first graphics_buffer |
| font | font_T | The font, all graphics buffers use to draw chars (could be moved to `graphics_buffer_T`) |
#### `graphics_buffer_request(pos_x, pos_y, width, height)` - function (graphics_buffer_T*)
Allocates a graphics buffer and pushes it on top of the rendering queue.
#### `graphics_buffer_destruct(graphics_buffer)` - function (void)
Removes **_graphics_buffer_** from the rendering queue and frees its memory allocations.
#### `graphics_buffer_set_pixel(graphics_buffer, x, y, color)` - function (void)
Sets a pixel with the given **_color_** at position(**_x_** | **_y_**) in **_graphics_buffer_**.
**_x_** and **_y_** are graphics buffer relative.
#### `graphics_buffer_get_pixel(graphics_buffer, x, y)` - function (color_argb_T)
Returns the color of the pixel at position(**_x_** | **_y_**) in **_graphics_buffer_**.
#### `graphics_buffer_draw_char(graphics_buffer, x, y, color, chr)` - function (void)
Draws a character (**_chr_**) at position(**_x_** | **_y_**) in **_graphics_buffer_**.
The position is the top-left corner of the char.
#### `graphics_renderer_init(boot_info)` - function (void)
Initializes the global graphics renderer.
Needs a pointer to `boot_info` to extract information about the framebuffer.
#### `graphics_renderer_update()` - function (void)
Updates the renderers back_buffer and swaps it into the framebuffer.
To update the back_buffer, it iterates over the rendering queue and copies every buffer to the back_buffer.
If there are overlapping graphics_buffers, it alpha blends them.
#### `graphics_renderer_get_top_buffer()` - function (graphics_buffer_T*)
Returns a pointer to the graphics_buffer, that is on top of the rendering queue.
#### `graphics_renderer_get_width()` - function (uint32_t)
Returns the width of the framebuffer.
#### `graphics_renderer_get_height()` - function (uint32_t)
Returns the height of the framebuffer.
## mm
### heap.h