feature (kernel): Implemented graphics_buffer show/hide functionality

This commit is contained in:
antifallobst 2023-02-22 23:07:55 +01:00
parent 8505345de9
commit 6e72cf8b71
2 changed files with 14 additions and 0 deletions

View File

@ -39,6 +39,7 @@ struct graphics_buffer_T {
uint32_t pos_x; uint32_t pos_x;
uint32_t pos_y; uint32_t pos_y;
bool blocked; bool blocked;
bool render;
graphics_buffer_layer_E layer; graphics_buffer_layer_E layer;
graphics_buffer_T* prev; graphics_buffer_T* prev;
graphics_buffer_T* next; graphics_buffer_T* next;
@ -54,6 +55,8 @@ typedef struct {
} graphics_renderer_T; } graphics_renderer_T;
graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer); graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer);
void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer); void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color); void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y); color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);

View File

@ -27,6 +27,7 @@ graphics_buffer_T* graphics_buffer_request(uint32_t pos_x, uint32_t pos_y, uint3
graphics_buffer->width = width; graphics_buffer->width = width;
graphics_buffer->height = height; graphics_buffer->height = height;
graphics_buffer->blocked = false; graphics_buffer->blocked = false;
graphics_buffer->render = true;
graphics_buffer->layer = layer; graphics_buffer->layer = layer;
graphics_buffer->buffer = memory_allocate(width * height * sizeof(color_argb_T)); graphics_buffer->buffer = memory_allocate(width * height * sizeof(color_argb_T));
memory_set(graphics_buffer->buffer, 0, width * height * sizeof(color_argb_T)); memory_set(graphics_buffer->buffer, 0, width * height * sizeof(color_argb_T));
@ -43,6 +44,14 @@ graphics_buffer_T* graphics_buffer_request(uint32_t pos_x, uint32_t pos_y, uint3
return graphics_buffer; return graphics_buffer;
} }
void graphics_buffer_show (graphics_buffer_T* graphics_buffer) {
graphics_buffer->render = true;
}
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer) {
graphics_buffer->render = false;
}
void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) { void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) {
if (graphics_buffer->prev != NULL) { if (graphics_buffer->prev != NULL) {
graphics_buffer->prev->next = graphics_buffer->next; graphics_buffer->prev->next = graphics_buffer->next;
@ -144,6 +153,8 @@ bool graphics_renderer_is_initialized() {
} }
void graphics_renderer_update_graphics_buffer(graphics_buffer_T* graphics_buffer) { void graphics_renderer_update_graphics_buffer(graphics_buffer_T* graphics_buffer) {
if (!graphics_buffer->render) { return; }
uint32_t size_x = MIN(graphics_buffer->pos_x + graphics_buffer->width, g_renderer.framebuffer.width); uint32_t size_x = MIN(graphics_buffer->pos_x + graphics_buffer->width, g_renderer.framebuffer.width);
uint32_t size_y = MIN(graphics_buffer->pos_y + graphics_buffer->height, g_renderer.framebuffer.height); uint32_t size_y = MIN(graphics_buffer->pos_y + graphics_buffer->height, g_renderer.framebuffer.height);