summaryrefslogtreecommitdiffhomepage
path: root/dev/modules/CoreGfx/CoreGfx.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-01 08:39:18 +0200
committerGitHub <noreply@github.com>2025-04-01 08:39:18 +0200
commitf88f6074479c627529559f690bf836960d5a6378 (patch)
treea1acef0bd6286f03197c0e1839e8d41ac5e5538f /dev/modules/CoreGfx/CoreGfx.h
parent6849e75f2e95e88b43e2f8804abf1b862e3981cb (diff)
parent2a7a9825fd275d6d999b94614fe87c1d705c7f8f (diff)
Merge pull request #4 from amlel-el-mahrouss/dev
pr/general: mostly minor patches.
Diffstat (limited to 'dev/modules/CoreGfx/CoreGfx.h')
-rw-r--r--dev/modules/CoreGfx/CoreGfx.h150
1 files changed, 150 insertions, 0 deletions
diff --git a/dev/modules/CoreGfx/CoreGfx.h b/dev/modules/CoreGfx/CoreGfx.h
new file mode 100644
index 00000000..df22fed0
--- /dev/null
+++ b/dev/modules/CoreGfx/CoreGfx.h
@@ -0,0 +1,150 @@
+/* -------------------------------------------
+
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.h>
+
+#define fb_init() Kernel::SizeT kCGCursor = 0
+
+#define fb_color(R, G, B) RGB(R, G, B)
+
+#define fb_get_clear_clr() fb_color(0x20, 0x20, 0x20)
+
+#define fb_clear() kCGCursor = 0
+
+#ifdef __NE_AMD64__
+/// @brief Performs Alpha drawing on the framebuffer.
+#define FBDrawBitMapInRegionA(reg_ptr, height, width, base_x, base_y) \
+ for (Kernel::SizeT i = base_x; i < (width + base_x); ++i) \
+ { \
+ for (Kernel::SizeT 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::SizeT i = base_x; i < (width + base_x); ++i) \
+ { \
+ for (Kernel::SizeT 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::SizeT i = base_x; i < (width + base_x); ++i) \
+ { \
+ for (Kernel::SizeT 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::SizeT i = base_x; i < (width + base_x); ++i) \
+ { \
+ for (Kernel::SizeT 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))) = fb_get_clear_clr(); \
+ } \
+ }
+
+/// @brief Draws inside a zone.
+#define FBDrawInRegion(clr, height, width, base_x, base_y) \
+ for (Kernel::SizeT x_base = base_x; x_base < (width + base_x); ++x_base) \
+ { \
+ for (Kernel::SizeT 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::SizeT x_base = base_x; x_base < (width + base_x); ++x_base) \
+ { \
+ for (Kernel::SizeT 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::SizeT x_base = base_x; x_base < (width + base_x); ++x_base) \
+ { \
+ for (Kernel::SizeT 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 GFX_MGR_ACCESSIBILITY_H
+#include <modules/CoreGfx/CoreAccess.h>
+#endif // ifndef GFX_MGR_ACCESSIBILITY_H
+
+namespace FB
+{
+ struct FB_CONTROL_BLOCK;
+
+ inline void fb_clear_video() noexcept
+ {
+ fb_init();
+
+ FBDrawInRegion(fb_get_clear_clr(), FB::FBAccessibilty::Height(), FB::FBAccessibilty::Width(),
+ 0, 0);
+
+ fb_clear();
+ }
+
+} // namespace FB \ No newline at end of file