ladybird/Kernel/Graphics/Console/GenericFramebufferConsole.h
Sahan Fernando 34e9fa4d3b Kernel: Abstract FramebufferConsole away from contiguous physical range
Currently, Kernel::Graphics::FramebufferConsole is written assuming that
the underlying framebuffer memory exists in physically contiguous
memory. There are a bunch of framebuffer devices that would need to use
the components of FramebufferConsole (in particular access to the kernel
bitmap font rendering logic). To reduce code duplication, framebuffer
console has been split into two parts, the abstract
GenericFramebufferConsole class which does the rendering, and the
ContiguousFramebufferConsole class which contains all logic related to
managing the underling vm object.

Also, a new flush method has been added to the class, to support devices
that require an extra flush step to render.
2021-06-25 19:26:30 +02:00

53 lines
1.7 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/RefCounted.h>
#include <AK/Types.h>
#include <Kernel/Graphics/Console/Console.h>
#include <Kernel/PhysicalAddress.h>
namespace Kernel::Graphics {
class GenericFramebufferConsole : public Console {
public:
virtual size_t bytes_per_base_glyph() const override;
virtual size_t chars_per_line() const override;
virtual size_t max_column() const override { return m_width / 8; }
virtual size_t max_row() const override { return m_height / 8; }
virtual bool is_hardware_paged_capable() const override { return false; }
virtual bool has_hardware_cursor() const override { return false; }
virtual void set_cursor(size_t x, size_t y) override;
virtual void hide_cursor() override;
virtual void show_cursor() override;
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 write(size_t x, size_t y, char ch, bool critical = false) override;
virtual void write(char ch, bool critical = false) override;
virtual void enable() override;
virtual void disable() override;
virtual void set_resolution(size_t width, size_t height, size_t pitch) = 0;
virtual void flush() = 0;
protected:
GenericFramebufferConsole(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);
size_t m_pitch;
mutable SpinLock<u8> m_lock;
};
}