1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 05:57:35 +00:00

Kernel: Separate GenericFramebufferConsole implementation

The GenericFramebufferConsoleImpl class implements the logic without
taking into account any other details such as synchronization. The
GenericFramebufferConsole class then is a simple wrapper around
GenericFramebufferConsoleImpl that takes care of synchronization.

This allows us to re-use this implementation with e.g. different
synchronization schemes.
This commit is contained in:
Tom 2022-01-28 18:48:07 -07:00 committed by Andreas Kling
parent 99e3e42fa5
commit eb446725d5
2 changed files with 65 additions and 20 deletions

View file

@ -13,7 +13,7 @@
namespace Kernel::Graphics {
class GenericFramebufferConsole : public Console {
class GenericFramebufferConsoleImpl : public Console {
public:
virtual size_t bytes_per_base_glyph() const override;
virtual size_t chars_per_line() const override;
@ -39,14 +39,33 @@ public:
virtual void set_resolution(size_t width, size_t height, size_t pitch) = 0;
protected:
GenericFramebufferConsole(size_t width, size_t height, size_t pitch)
GenericFramebufferConsoleImpl(size_t width, size_t height, size_t pitch)
: Console(width, height)
, m_pitch(pitch)
{
}
virtual u8* framebuffer_data() = 0;
void clear_glyph(size_t x, size_t y);
virtual void clear_glyph(size_t x, size_t y);
size_t m_pitch;
};
class GenericFramebufferConsole : public GenericFramebufferConsoleImpl {
public:
virtual void clear(size_t x, size_t y, size_t length) override;
virtual void write(size_t x, size_t y, char ch, Color background, Color foreground, bool critical = false) override;
virtual void enable() override;
virtual void disable() override;
protected:
GenericFramebufferConsole(size_t width, size_t height, size_t pitch)
: GenericFramebufferConsoleImpl(width, height, pitch)
{
}
virtual void clear_glyph(size_t x, size_t y) override;
mutable Spinlock m_lock;
};
}