summaryrefslogtreecommitdiffhomepage
path: root/Kernel
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-06-08 17:22:38 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-06-08 17:22:38 +0200
commit9679f4d8676cb72feb80d95bca6ce26965f40042 (patch)
tree40e7a667681d3d9a3b9a3cdc303479222b058387 /Kernel
parent00861fe008e33e6be0f538191683169f72e1f54f (diff)
MHR-23: GX builtin.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Builtins/GX/GX (renamed from Kernel/Builtins/Toolbox/Toolbox.hxx)42
-rw-r--r--Kernel/Builtins/GX/Lerp (renamed from Kernel/Builtins/Toolbox/Lerp.hxx)8
-rw-r--r--Kernel/Builtins/GX/Rsrc/Cursor.rsrc (renamed from Kernel/Builtins/Toolbox/Rsrc/Cursor.rsrc)9
-rw-r--r--Kernel/Builtins/ReadMe.txt2
-rw-r--r--Kernel/FirmwareKit/EFI/API.hxx8
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMouse.cxx6
-rw-r--r--Kernel/Sources/AppMain.cxx2
8 files changed, 48 insertions, 31 deletions
diff --git a/Kernel/Builtins/Toolbox/Toolbox.hxx b/Kernel/Builtins/GX/GX
index e65da9d2..61e3a6fe 100644
--- a/Kernel/Builtins/Toolbox/Toolbox.hxx
+++ b/Kernel/Builtins/GX/GX
@@ -15,15 +15,15 @@ EXTERN_C NewOS::Boolean _hal_left_button_pressed();
EXTERN_C NewOS::Boolean _hal_middle_button_pressed();
EXTERN_C NewOS::Boolean _hal_right_button_pressed();
-#define ToolboxInitRsrc() NewOS::SizeT __ToolboxCursor = 0
+#define GXInit() NewOS::SizeT __GXCursor = 0
-#define kClearClr RGB(00, 00, 00)
+#define gxClearClr RGB(00, 00, 00)
-#define ToolboxClearRsrc() __ToolboxCursor = 0
+#define GXFini() __GXCursor = 0
/// @brief Performs OR drawing on the framebuffer.
-#define ToolboxDrawOrRsrc(ImgPtr, _Height, _Width, BaseX, BaseY) \
- __ToolboxCursor = 0; \
+#define GXDrawAlphaImg(ImgPtr, _Height, _Width, BaseX, BaseY) \
+ __GXCursor = 0; \
\
for (NewOS::SizeT i = BaseX; i < (_Height + BaseX); ++i) \
{ \
@@ -32,15 +32,15 @@ EXTERN_C NewOS::Boolean _hal_right_button_pressed();
*(((volatile NewOS::UInt32*)(kHandoverHeader->f_GOP.f_The + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
i + \
- 4 * u))) |= ImgPtr[__ToolboxCursor]; \
+ 4 * u))) |= ImgPtr[__GXCursor]; \
\
- ++__ToolboxCursor; \
+ ++__GXCursor; \
} \
}
/// @brief Draws a resource.
-#define ToolboxDrawRsrc(ImgPtr, _Height, _Width, BaseX, BaseY) \
- __ToolboxCursor = 0; \
+#define GXDrawImg(ImgPtr, _Height, _Width, BaseX, BaseY) \
+ __GXCursor = 0; \
\
for (NewOS::SizeT i = BaseX; i < (_Height + BaseX); ++i) \
{ \
@@ -49,14 +49,14 @@ EXTERN_C NewOS::Boolean _hal_right_button_pressed();
*(((volatile NewOS::UInt32*)(kHandoverHeader->f_GOP.f_The + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
i + \
- 4 * u))) = ImgPtr[__ToolboxCursor]; \
+ 4 * u))) = ImgPtr[__GXCursor]; \
\
- ++__ToolboxCursor; \
+ ++__GXCursor; \
} \
}
/// @brief Cleans a resource.
-#define ToolboxClearZone(_Height, _Width, BaseX, BaseY) \
+#define GXClear(_Height, _Width, BaseX, BaseY) \
\
for (NewOS::SizeT i = BaseX; i < _Height + BaseX; ++i) \
{ \
@@ -65,12 +65,12 @@ EXTERN_C NewOS::Boolean _hal_right_button_pressed();
*(((volatile NewOS::UInt32*)(kHandoverHeader->f_GOP.f_The + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
i + \
- 4 * u))) = kClearClr; \
+ 4 * u))) = gxClearClr; \
} \
}
/// @brief Draws inside a zone.
-#define ToolboxDrawZone(_Clr, _Height, _Width, BaseX, BaseY) \
+#define GXDraw(_Clr, _Height, _Width, BaseX, BaseY) \
\
for (NewOS::SizeT i = BaseX; i < (_Width + BaseX); ++i) \
{ \
@@ -82,3 +82,17 @@ EXTERN_C NewOS::Boolean _hal_right_button_pressed();
4 * u))) = _Clr; \
} \
}
+
+
+#ifdef __CG_USE_GX__
+/// @brief This function creates a new framebuffer for GX.
+/// @return
+inline cairo_surface_t* GXCreateFramebufferCairo()
+{
+ cairo_format_t format = CAIRO_FORMAT_ARGB32;
+
+ NewOS::Int32 stride = cairo_format_stride_for_width(format, kHandoverHeader->f_GOP.f_Width);
+
+ return cairo_image_surface_create_for_data((unsigned char *)kHandoverHeader->f_GOP.f_The, format, kHandoverHeader->f_GOP.f_Width, kHandoverHeader->f_GOP.f_Height, stride);
+}
+#endif \ No newline at end of file
diff --git a/Kernel/Builtins/Toolbox/Lerp.hxx b/Kernel/Builtins/GX/Lerp
index f987457f..08066c82 100644
--- a/Kernel/Builtins/Toolbox/Lerp.hxx
+++ b/Kernel/Builtins/GX/Lerp
@@ -9,12 +9,14 @@
/// @file Lerp.hxx
/// @brief Linear interpolation implementation.
+typedef float GXReal;
+
/// @brief Linear interpolation equation solver.
/// @param from where?
/// @param to to?
/// @param at which state we're at **to**.
-inline int Lerp(int from, int to, float percent) noexcept
+inline GXReal GXLerp(GXReal to, GXReal from, GXReal stat)
{
- int difference = to - from;
- return from + (difference * percent);
+ register GXReal difference = to - from;
+ return from + (difference * stat);
}
diff --git a/Kernel/Builtins/Toolbox/Rsrc/Cursor.rsrc b/Kernel/Builtins/GX/Rsrc/Cursor.rsrc
index 7943b805..2283cb32 100644
--- a/Kernel/Builtins/Toolbox/Rsrc/Cursor.rsrc
+++ b/Kernel/Builtins/GX/Rsrc/Cursor.rsrc
@@ -1,8 +1,9 @@
-#define CURSOR_HEIGHT 57
-#define CURSOR_WIDTH 53
+#define cCurHeight (57)
+#define cCurWidth (53)
-// array size is 9063
-static const unsigned int Cursor[] = {
+#define cCurLength (3021)
+
+static const unsigned int Cursor[cCurLength] = {
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
diff --git a/Kernel/Builtins/ReadMe.txt b/Kernel/Builtins/ReadMe.txt
index b090b2e5..b0a5a327 100644
--- a/Kernel/Builtins/ReadMe.txt
+++ b/Kernel/Builtins/ReadMe.txt
@@ -14,6 +14,6 @@ Maintainers/Authors
ACPIFactoryInterface: Amlal EL Mahrouss.
AHCI: Amlal EL Mahrouss.
-Toolbox: Amlal EL Mahrouss.
+GX: Amlal EL Mahrouss.
PS2: Amlal EL Mahrouss
ATA: Amlal EL Mahrouss \ No newline at end of file
diff --git a/Kernel/FirmwareKit/EFI/API.hxx b/Kernel/FirmwareKit/EFI/API.hxx
index 8e8183d6..362886b2 100644
--- a/Kernel/FirmwareKit/EFI/API.hxx
+++ b/Kernel/FirmwareKit/EFI/API.hxx
@@ -21,7 +21,7 @@ class BTextWriter;
#include <BootKit/BootKit.hxx>
#include <BootKit/Rsrc/NewBootFatal.rsrc>
#include <BootKit/Vendor/Qr.hxx>
-#include <Builtins/Toolbox/Toolbox.hxx>
+#include <Builtins/GX/GX>
#endif // ifdef __NEWBOOT__
inline EfiSystemTable* ST = nullptr;
@@ -89,13 +89,13 @@ Bascially frees everything we have in the EFI side.
#endif // ifdef __DEBUG__
#ifdef __NEWBOOT__
- ToolboxInitRsrc();
+ GXInit();
- ToolboxDrawRsrc(NewBootFatal, NEWBOOTFATAL_HEIGHT, NEWBOOTFATAL_WIDTH,
+ GXDrawImg(NewBootFatal, NEWBOOTFATAL_HEIGHT, NEWBOOTFATAL_WIDTH,
(kHandoverHeader->f_GOP.f_Width - NEWBOOTFATAL_WIDTH) / 2,
(kHandoverHeader->f_GOP.f_Height - NEWBOOTFATAL_HEIGHT) / 2);
- ToolboxClearRsrc();
+ GXFini();
/// Show the QR code now.
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 3136bf76..bd415168 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Toolbox.hxx>
+#include <Builtins/GX/GX>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
#include <KernelKit/Framebuffer.hpp>
diff --git a/Kernel/HALKit/AMD64/HalKernelMouse.cxx b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
index 1e1ddd5b..68d387c7 100644
--- a/Kernel/HALKit/AMD64/HalKernelMouse.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
@@ -5,8 +5,8 @@
------------------------------------------- */
#include <Builtins/PS2/PS2MouseInterface.hxx>
-#include <Builtins/Toolbox/Toolbox.hxx>
-#include <Builtins/Toolbox/Rsrc/Cursor.rsrc>
+#include <Builtins/GX/GX>
+#include <Builtins/GX/Rsrc/Cursor.rsrc>
#include <KernelKit/Framebuffer.hpp>
#include <NewKit/Defines.hpp>
@@ -23,7 +23,7 @@ STATIC NewOS::PS2MouseInterface kMousePS2;
STATIC NewOS::Char kMousePacket[4] = {};
STATIC NewOS::Boolean kMousePacketReady = false;
-STATIC ToolboxInitRsrc();
+STATIC GXInit();
#define kPS2Leftbutton 0b00000001
#define kPS2Middlebutton 0b00000010
diff --git a/Kernel/Sources/AppMain.cxx b/Kernel/Sources/AppMain.cxx
index 41619673..b06d8460 100644
--- a/Kernel/Sources/AppMain.cxx
+++ b/Kernel/Sources/AppMain.cxx
@@ -8,7 +8,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Toolbox.hxx>
+#include <Builtins/GX/GX>
#include <CompilerKit/Detail.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>