From da70596895d8135e08f8caac6978117697b4c021 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 18 Aug 2024 21:39:29 +0200 Subject: [REFACTOR] Improved project structure. Signed-off-by: Amlal El Mahrouss --- dev/ZKA/KernelKit/Framebuffer.hxx | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dev/ZKA/KernelKit/Framebuffer.hxx (limited to 'dev/ZKA/KernelKit/Framebuffer.hxx') diff --git a/dev/ZKA/KernelKit/Framebuffer.hxx b/dev/ZKA/KernelKit/Framebuffer.hxx new file mode 100644 index 00000000..dac9b514 --- /dev/null +++ b/dev/ZKA/KernelKit/Framebuffer.hxx @@ -0,0 +1,85 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + + File: Framebuffer.hpp + Purpose: Framebuffer object. + +------------------------------------------- */ + +#ifndef __INC_FB_HPP__ +#define __INC_FB_HPP__ + +#include +#include + +namespace Kernel +{ + enum class FramebufferColorKind : UChar + { + RGB32, + RGB16, + RGB8, + INVALID, + }; + + class FramebufferContext final + { + public: + UIntPtr fBase; + UIntPtr fBpp; + UInt fWidth; + UInt fHeight; + }; + + class Framebuffer final + { + public: + explicit Framebuffer(Ref& addr); + ~Framebuffer() = default; + + Framebuffer& operator=(const Framebuffer&) = delete; + Framebuffer(const Framebuffer&) = default; + + volatile UIntPtr* operator[](const UIntPtr& pos); + + operator bool(); + + const FramebufferColorKind& Color( + const FramebufferColorKind& colour = FramebufferColorKind::INVALID); + + Ref& Leak(); + + /// @brief Draws a rectangle inside the fb. + /// @param width the width of it + /// @param height the height of it + /// @param x its x coord. + /// @param y its y coord. + /// @param color the color of it. + /// @return the framebuffer object. + Framebuffer& DrawRect(SizeT width, SizeT height, SizeT x, SizeT y, UInt32 color); + + /// @brief Puts a pixel on the screen. + /// @param x where in X + /// @param y where in Y + /// @param color the color of it. + /// @return the framebuffer object. + Framebuffer& PutPixel(SizeT x, SizeT y, UInt32 color); + + private: + Ref fFrameBufferAddr; + FramebufferColorKind fColour; + }; + + /***********************************************************************************/ + /// Some common colors. + /***********************************************************************************/ + + extern const UInt32 kRgbRed; + extern const UInt32 kRgbGreen; + extern const UInt32 kRgbBlue; + extern const UInt32 kRgbBlack; + extern const UInt32 kRgbWhite; +} // namespace Kernel + +#endif /* ifndef __INC_FB_HPP__ */ -- cgit v1.2.3