diff --git a/kernel/include/render/BBRenderer.h b/kernel/include/render/BBRenderer.h deleted file mode 100644 index d61bb7c1..00000000 --- a/kernel/include/render/BBRenderer.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "render/BaseRenderer.h" - -class BBRenderer : public BaseRenderer -{ - public: - bool init() override; - void set_pixel(uint32_t x, uint32_t y, Color color) override; - Color get_pixel(uint32_t x, uint32_t y) override; - void paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color color) override; - void paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color* colors) override; - void clear(Color color) override; -}; \ No newline at end of file diff --git a/kernel/include/render/BaseRenderer.h b/kernel/include/render/BaseRenderer.h deleted file mode 100644 index cf8c7651..00000000 --- a/kernel/include/render/BaseRenderer.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "render/Color.h" - -class BaseRenderer -{ - public: - virtual bool init(); - virtual void set_pixel(uint32_t x, uint32_t y, Color color); - virtual Color get_pixel(uint32_t x, uint32_t y); - virtual void paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color color); - virtual void paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color* colors); - virtual void clear(Color color); -}; \ No newline at end of file diff --git a/kernel/include/render/Draw.h b/kernel/include/render/Draw.h deleted file mode 100644 index c7123de3..00000000 --- a/kernel/include/render/Draw.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "render/BaseRenderer.h" - -namespace Draw -{ - bool try_initialize(); - BaseRenderer* renderer(); -} \ No newline at end of file diff --git a/kernel/src/render/BBRenderer.cpp b/kernel/src/render/BBRenderer.cpp deleted file mode 100644 index f8175e1c..00000000 --- a/kernel/src/render/BBRenderer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "render/BBRenderer.h" -#include "assert.h" -#include "bootboot.h" - -extern BOOTBOOT bootboot; -extern uint8_t fb[4]; - -bool BBRenderer::init() -{ - // FIXME: Support more framebuffer types - return bootboot.fb_type == FB_ARGB; -} - -void BBRenderer::set_pixel(uint32_t x, uint32_t y, Color color) -{ - *(uint32_t*)(fb + bootboot.fb_scanline * y + x * 4) = *(uint32_t*)&color; -} - -Color BBRenderer::get_pixel(uint32_t x, uint32_t y) -{ - return *(Color*)(fb + bootboot.fb_scanline * y + x * 4); -} - -void BBRenderer::clear(Color color) -{ - paint_rect(0, 0, bootboot.fb_width, bootboot.fb_height, color); -} - -void BBRenderer::paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color color) -{ - for (uint32_t i = y; i < (y + h); i++) - { - uint64_t addr = (uint64_t)(fb + (bootboot.fb_scanline * i) + (x * 4)); - for (uint64_t addr_current = addr; addr_current < (addr + w * 4); addr_current += 4) - { - *(uint32_t*)addr_current = *(uint32_t*)&color; - } - } -} - -void BBRenderer::paint_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color* colors) -{ - uint32_t j; - for (uint32_t l = j = 0; l < h; l++) - { - for (uint32_t i = 0; i < w; i++, j++) { set_pixel(x + i, y + l, colors[j]); } - } -} \ No newline at end of file diff --git a/kernel/src/render/BaseRenderer.cpp b/kernel/src/render/BaseRenderer.cpp deleted file mode 100644 index 27329fa9..00000000 --- a/kernel/src/render/BaseRenderer.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "render/BaseRenderer.h" - -bool BaseRenderer::init() -{ - return false; -} - -void BaseRenderer::set_pixel([[maybe_unused]] uint32_t x, [[maybe_unused]] uint32_t y, [[maybe_unused]] Color color) -{ - return; -} - -Color BaseRenderer::get_pixel([[maybe_unused]] uint32_t x, [[maybe_unused]] uint32_t y) -{ - return Color::Black; -} - -void BaseRenderer::paint_rect([[maybe_unused]] uint32_t x, [[maybe_unused]] uint32_t y, [[maybe_unused]] uint32_t w, - [[maybe_unused]] uint32_t h, [[maybe_unused]] Color color) -{ - return; -} - -void BaseRenderer::paint_rect([[maybe_unused]] uint32_t x, [[maybe_unused]] uint32_t y, [[maybe_unused]] uint32_t w, - [[maybe_unused]] uint32_t h, [[maybe_unused]] Color* colors) -{ - return; -} - -void BaseRenderer::clear([[maybe_unused]] Color color) -{ - return; -} \ No newline at end of file diff --git a/kernel/src/render/Draw.cpp b/kernel/src/render/Draw.cpp deleted file mode 100644 index 5243f62a..00000000 --- a/kernel/src/render/Draw.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "render/Draw.h" -#include "render/BBRenderer.h" - -static BaseRenderer* s_renderer; -BBRenderer bbRenderer; - -bool Draw::try_initialize() -{ - if (bbRenderer.init()) - { - s_renderer = &bbRenderer; - return true; - } - return false; -} - -BaseRenderer* Draw::renderer() -{ - return s_renderer; -} \ No newline at end of file diff --git a/kernel/src/render/TextRenderer.cpp b/kernel/src/render/TextRenderer.cpp index 2b26638f..740fd184 100644 --- a/kernel/src/render/TextRenderer.cpp +++ b/kernel/src/render/TextRenderer.cpp @@ -3,14 +3,13 @@ #include "init/InitRD.h" #include "io/Serial.h" #include "psf2.h" -#include "render/BBRenderer.h" +#include "render/Framebuffer.h" #include "std/stdio.h" #include "std/string.h" extern BOOTBOOT bootboot; static psf2_t* font; -static BBRenderer textRenderer; static Color bgColor = Color::Black; static Color fgColor = Color::White; static uint32_t xpos = 0; @@ -18,11 +17,6 @@ static uint32_t ypos = 0; bool TextRenderer::try_initialize() { - if (!textRenderer.init()) - { - Serial::println("Failed to initialize BBRenderer"); - return false; - } InitRD::File font_file = InitRD::find_file("boot/font.psf"); if (!font_file.addr) { @@ -53,7 +47,7 @@ static void putchar_at_offset(char c, int cx, int cy, Color& fg, Color& bg) mask = 1 << (font->width - 1); for (uint32_t x = 0; x < font->width; x++) { - textRenderer.set_pixel(cx + x, cy + y, *((uint32_t*)glyph) & mask ? fg : bg); + framebuffer0.set_pixel(cx + x, cy + y, *((uint32_t*)glyph) & mask ? fg : bg); mask >>= 1; } } @@ -70,7 +64,7 @@ void TextRenderer::putchar(char chr) memcpy((void*)bootboot.fb_ptr, (uint32_t*)bootboot.fb_ptr + (bootboot.fb_scanline * font->height), bootboot.fb_size - (sizeof(uint32_t) * bootboot.fb_scanline * font->height)); ypos -= font->height; - textRenderer.paint_rect(0, ypos, bootboot.fb_width, font->height, Color::Black); + framebuffer0.paint_rect(0, ypos, bootboot.fb_width, font->height, Color::Black); } xpos = 0; break; @@ -79,7 +73,7 @@ void TextRenderer::putchar(char chr) if (xpos != 0) { xpos -= font->width + 1; - textRenderer.paint_rect(xpos, ypos, font->width + 1, font->height, Color::Black); + framebuffer0.paint_rect(xpos, ypos, font->width + 1, font->height, Color::Black); } break; default: @@ -94,7 +88,7 @@ void TextRenderer::putchar(char chr) memcpy((void*)bootboot.fb_ptr, (uint32_t*)bootboot.fb_ptr + (bootboot.fb_scanline * font->height), bootboot.fb_size - (sizeof(uint32_t) * bootboot.fb_scanline * font->height)); ypos -= font->height; - textRenderer.paint_rect(0, ypos, bootboot.fb_width, font->height, Color::Black); + framebuffer0.paint_rect(0, ypos, bootboot.fb_width, font->height, Color::Black); } } break;