From 6e72cf8b710ffd8e79d1550c1a822cd145c794de Mon Sep 17 00:00:00 2001 From: antifallobst Date: Wed, 22 Feb 2023 23:07:55 +0100 Subject: [PATCH] feature (kernel): Implemented graphics_buffer show/hide functionality --- kernel/inc/drivers/graphics/renderer.h | 3 +++ kernel/src/drivers/graphics/renderer.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/kernel/inc/drivers/graphics/renderer.h b/kernel/inc/drivers/graphics/renderer.h index 1217ce9..39fdf55 100644 --- a/kernel/inc/drivers/graphics/renderer.h +++ b/kernel/inc/drivers/graphics/renderer.h @@ -39,6 +39,7 @@ struct graphics_buffer_T { uint32_t pos_x; uint32_t pos_y; bool blocked; + bool render; graphics_buffer_layer_E layer; graphics_buffer_T* prev; graphics_buffer_T* next; @@ -54,6 +55,8 @@ typedef struct { } 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); +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_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); diff --git a/kernel/src/drivers/graphics/renderer.c b/kernel/src/drivers/graphics/renderer.c index cb75dc4..efc3f1d 100644 --- a/kernel/src/drivers/graphics/renderer.c +++ b/kernel/src/drivers/graphics/renderer.c @@ -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->height = height; graphics_buffer->blocked = false; + graphics_buffer->render = true; graphics_buffer->layer = layer; graphics_buffer->buffer = memory_allocate(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; } +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) { if (graphics_buffer->prev != NULL) { 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) { + if (!graphics_buffer->render) { return; } + 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);