Remove unused drawing files

This commit is contained in:
apio 2022-09-10 18:44:14 +02:00
parent 6a0cf7cf98
commit 4aeada05d3
7 changed files with 5 additions and 146 deletions

View File

@ -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;
};

View File

@ -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);
};

View File

@ -1,8 +0,0 @@
#pragma once
#include "render/BaseRenderer.h"
namespace Draw
{
bool try_initialize();
BaseRenderer* renderer();
}

View File

@ -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]); }
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;