From 3b3b36dcc6542e203475fe1d50ed89799e3f3fc6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 25 Mar 2024 20:17:53 +0100 Subject: Kernel: implement some tickets, improved stuff. Signed-off-by: Amlal El Mahrouss --- Private/Source/Framebuffer.cxx | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'Private/Source/Framebuffer.cxx') diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 6ea2fa5b..9c964a3c 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -33,13 +33,14 @@ volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) { /// @brief Boolean operator. Framebuffer::operator bool() { - return m_FrameBufferAddr.Leak()->m_Base != 0 && m_Colour != FramebufferColorKind::INVALID && - m_FrameBufferAddr.Leak()->m_Base != kBadPtr; + return m_FrameBufferAddr.Leak()->m_Base != 0 && + m_Colour != FramebufferColorKind::INVALID && + m_FrameBufferAddr.Leak()->m_Base != kBadPtr; } /// @brief Set color kind of framebuffer. -/// @param colour -/// @return +/// @param colour +/// @return const FramebufferColorKind &Framebuffer::Color( const FramebufferColorKind &colour) { if (m_Colour != FramebufferColorKind::INVALID && @@ -50,8 +51,29 @@ const FramebufferColorKind &Framebuffer::Color( return m_Colour; } -/// @brief Leak fraembuffer context. +/// @brief Leak framebuffer context. /// @return The reference of the framebuffer context. Ref &Framebuffer::Leak() { return this->m_FrameBufferAddr; } + +Framebuffer &Framebuffer::DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, + UInt32 color) { + for (HCore::SizeT i = x; i < width + x; ++i) { + for (HCore::SizeT u = y; u < height + y; ++u) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * i + + 4 * u))) = color; + } + } + + return *this; +} + +Framebuffer &Framebuffer::PutPixel(SizeT x, SizeT y, UInt32 color) { + *(((volatile HCore::UInt32 *)(m_FrameBufferAddr.Leak()->m_Base + + 4 * m_FrameBufferAddr.Leak()->m_Bpp * x + + 4 * y))) = color; + + return *this; +} \ No newline at end of file -- cgit v1.2.3