diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-15 18:35:34 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-15 18:35:34 +0200 |
| commit | f3d931aa7cfaf96baef8383b59a8938779541ee7 (patch) | |
| tree | fdb9fc51badb3dbd03e46ab0766a49d9522e13e2 /dev/Kernel/KernelKit/Framebuffer.hxx | |
| parent | 86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 (diff) | |
[IMP] Moved source code into dev/ folder.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/KernelKit/Framebuffer.hxx')
| -rw-r--r-- | dev/Kernel/KernelKit/Framebuffer.hxx | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/dev/Kernel/KernelKit/Framebuffer.hxx b/dev/Kernel/KernelKit/Framebuffer.hxx new file mode 100644 index 00000000..dac9b514 --- /dev/null +++ b/dev/Kernel/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 <NewKit/Defines.hxx> +#include <NewKit/Ref.hxx> + +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<FramebufferContext*>& 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<FramebufferContext*>& 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<FramebufferContext*> 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__ */ |
