diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
| commit | 83d870e58457a1d335a1d9b9966a6a1887cc297b (patch) | |
| tree | 72888f88c7728c82f3f6df1f4f70591de15eab36 /src/modules/CoreGfx/CoreGfx.h | |
| parent | ab37adbacf0f33845804c788b39680cd754752a8 (diff) | |
feat! breaking changes on kernel sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/modules/CoreGfx/CoreGfx.h')
| -rw-r--r-- | src/modules/CoreGfx/CoreGfx.h | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/modules/CoreGfx/CoreGfx.h b/src/modules/CoreGfx/CoreGfx.h new file mode 100644 index 00000000..e1bfe462 --- /dev/null +++ b/src/modules/CoreGfx/CoreGfx.h @@ -0,0 +1,118 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#pragma once + +#include <NeKit/Defines.h> + +#define cg_init() Kernel::UInt32 kCGCursor = 0 + +#define cg_color(R, G, B) RGB(R, G, B) + +#define cg_get_clear_clr() RGB(0, 0, 0x80) + +#define cg_clear() kCGCursor = 0UL + +#ifdef __NE_AMD64__ +/// @brief Performs Alpha drawing on the framebuffer. +#define FBDrawBitMapInRegionA(reg_ptr, height, width, base_x, base_y) \ + for (Kernel::UInt32 i = base_x; i < (width + base_x); ++i) { \ + for (Kernel::UInt32 u = base_y; u < (height + base_y); ++u) { \ + *(((Kernel::UInt32*) (kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * i + 4 * u))) |= \ + (reg_ptr)[kCGCursor]; \ + \ + ++kCGCursor; \ + } \ + } + +/// @brief Performs drawing on the framebuffer. +#define FBDrawBitMapInRegion(reg_ptr, height, width, base_x, base_y) \ + for (Kernel::UInt32 i = base_x; i < (width + base_x); ++i) { \ + for (Kernel::UInt32 u = base_y; u < (height + base_y); ++u) { \ + *(((Kernel::UInt32*) (kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * i + 4 * u))) = \ + (reg_ptr)[kCGCursor]; \ + \ + ++kCGCursor; \ + } \ + } + +#define FBDrawBitMapInRegionToRgn(_Rgn, reg_ptr, height, width, base_x, base_y) \ + for (Kernel::UInt32 i = base_x; i < (width + base_x); ++i) { \ + for (Kernel::UInt32 u = base_y; u < (height + base_y); ++u) { \ + *(((Kernel::UInt32*) (_Rgn + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * i + 4 * u))) = \ + (reg_ptr)[kCGCursor]; \ + \ + ++kCGCursor; \ + } \ + } + +/// @brief Cleans a resource. +#define FBClearRegion(height, width, base_x, base_y) \ + for (Kernel::UInt32 i = base_x; i < (width + base_x); ++i) { \ + for (Kernel::UInt32 u = base_y; u < (height + base_y); ++u) { \ + *(((volatile Kernel::UInt32*) (kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * i + 4 * u))) = \ + cg_get_clear_clr(); \ + } \ + } + +/// @brief Draws inside a zone. +#define FBDrawInRegion(clr, height, width, base_x, base_y) \ + for (Kernel::UInt32 x_base = base_x; x_base < (width + base_x); ++x_base) { \ + for (Kernel::UInt32 y_base = base_y; y_base < (height + base_y); ++y_base) { \ + *(((volatile Kernel::UInt32*) (kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * x_base + \ + 4 * y_base))) = clr; \ + } \ + } + +/// @brief Draws inside a zone. +#define FBDrawInRegionToRgn(_Rgn, clr, height, width, base_x, base_y) \ + for (Kernel::UInt32 x_base = base_x; x_base < (width + base_x); ++x_base) { \ + for (Kernel::UInt32 y_base = base_y; y_base < (height + base_y); ++y_base) { \ + *(((volatile Kernel::UInt32*) (_Rgn + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * x_base + \ + 4 * y_base))) = clr[kCGCursor]; \ + ++kCGCursor; \ + } \ + } + +#define FBDrawInRegionA(clr, height, width, base_x, base_y) \ + for (Kernel::UInt32 x_base = base_x; x_base < (width + base_x); ++x_base) { \ + for (Kernel::UInt32 y_base = base_y; y_base < (height + base_y); ++y_base) { \ + *(((volatile Kernel::UInt32*) (kHandoverHeader->f_GOP.f_The + \ + 4 * kHandoverHeader->f_GOP.f_PixelPerLine * x_base + \ + 4 * y_base))) |= clr; \ + } \ + } +#else +#define FBDrawBitMapInRegionA(reg_ptr, height, width, base_x, base_y) +#define FBDrawBitMapInRegion(reg_ptr, height, width, base_x, base_y) +#define FBDrawBitMapInRegionToRgn(_Rgn, reg_ptr, height, width, base_x, base_y) +#define FBClearRegion(height, width, base_x, base_y) +#define FBDrawInRegion(clr, height, width, base_x, base_y) +#define FBDrawInRegionToRgn(_Rgn, clr, height, width, base_x, base_y) +#define FBDrawInRegionA(clr, height, width, base_x, base_y) +#define FBDrawBitMapInRegionA(reg_ptr, height, width, base_x, base_y) +#define FBDrawBitMapInRegion(reg_ptr, height, width, base_x, base_y) +#define FBDrawBitMapInRegionToRgn(_Rgn, reg_ptr, height, width, base_x, base_y) +#define FBClearRegion(height, width, base_x, base_y) +#define FBDrawInRegion(clr, height, width, base_x, base_y) +#define FBDrawInRegionToRgn(_Rgn, clr, height, width, base_x, base_y) +#define FBDrawInRegionA(clr, height, width, base_x, base_y) +#endif // __NE_AMD64__ + +#ifndef CORE_GFX_ACCESSIBILITY_H +#include <modules/CoreGfx/CoreAccess.h> +#endif // ifndef CORE_GFX_ACCESSIBILITY_H + +namespace FB { +inline Void cg_clear_video() noexcept { + FBDrawInRegion(cg_get_clear_clr(), FB::CGAccessibilty::Height(), FB::CGAccessibilty::Width(), 0, + 0); +} +} // namespace FB
\ No newline at end of file |
