diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-27 11:41:44 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-27 11:41:44 +0200 |
| commit | 8db6fc60063757628f92bd1c4d4855775f4ff9e2 (patch) | |
| tree | e27013969dc749bbb8131e24e4171034fdb80f56 /dev/zka/Modules | |
| parent | daa4f8c748d290feba8a71e889743a8a3097ad7d (diff) | |
feat&wip: Math API for CG, WiP HAL Paging API.
- NOTE: HAL Paging API is still in wip, issues have to be fixed.
- Moved WM code to corecg driver.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/zka/Modules')
| -rw-r--r-- | dev/zka/Modules/CoreCG/Accessibility.hxx | 14 | ||||
| -rw-r--r-- | dev/zka/Modules/CoreCG/DesktopRenderer.hxx | 45 | ||||
| -rw-r--r-- | dev/zka/Modules/CoreCG/FbRenderer.hxx | 36 | ||||
| -rw-r--r-- | dev/zka/Modules/CoreCG/Math.hxx | 61 | ||||
| -rw-r--r-- | dev/zka/Modules/CoreCG/TextRenderer.hxx | 2 | ||||
| -rw-r--r-- | dev/zka/Modules/CoreCG/WindowRenderer.hxx | 265 | ||||
| -rw-r--r-- | dev/zka/Modules/GLCG/.keepme (renamed from dev/zka/Modules/GL/.keepme) | 0 | ||||
| -rw-r--r-- | dev/zka/Modules/NVME/NVME.hxx (renamed from dev/zka/Modules/NVME/Defines.hxx) | 4 |
8 files changed, 124 insertions, 303 deletions
diff --git a/dev/zka/Modules/CoreCG/Accessibility.hxx b/dev/zka/Modules/CoreCG/Accessibility.hxx index 4a3efbcb..1f26dec4 100644 --- a/dev/zka/Modules/CoreCG/Accessibility.hxx +++ b/dev/zka/Modules/CoreCG/Accessibility.hxx @@ -17,18 +17,18 @@ namespace CG { using namespace Kernel; - /// @brief common User interface class. - class UIAccessibilty final + /// @brief Accessibilty manager class. + class CGAccessibilty final { - explicit UIAccessibilty() = default; - ~UIAccessibilty() = default; + explicit CGAccessibilty() = default; + ~CGAccessibilty() = default; public: - ZKA_COPY_DELETE(UIAccessibilty); + ZKA_COPY_DELETE(CGAccessibilty); - STATIC UIAccessibilty& The() + STATIC CGAccessibilty& The() { - STATIC UIAccessibilty the; + STATIC CGAccessibilty the; return the; } diff --git a/dev/zka/Modules/CoreCG/DesktopRenderer.hxx b/dev/zka/Modules/CoreCG/DesktopRenderer.hxx new file mode 100644 index 00000000..e83ec8ef --- /dev/null +++ b/dev/zka/Modules/CoreCG/DesktopRenderer.hxx @@ -0,0 +1,45 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include <Modules/CoreCG/Accessibility.hxx> +#include <KernelKit/Heap.hxx> +#include <KernelKit/UserProcessScheduler.hxx> +#include <KernelKit/LPC.hxx> +#include <NewKit/Defines.hxx> +#include <NewKit/Utils.hxx> +#include <Modules/CoreCG/FbRenderer.hxx> +#include <Modules/CoreCG/Rsrc/WndControls.rsrc> +#include <Modules/CoreCG/TextRenderer.hxx> + +namespace CG +{ + using namespace Kernel; + + class ICGBackground; + + /// \brief Draw background (either image or solid color) + inline Void CGDrawDesktopBackground(UInt32* raw_bmp = nullptr, SizeT width = 0, SizeT height = 0) noexcept + { + CGInit(); + + if (!raw_bmp) + { + const auto cColorBackground = CGColor(0x45, 0x00, 0x06); + + CGDrawInRegion(cColorBackground, CG::CGAccessibilty::The().Height(), CG::CGAccessibilty::The().Width(), + 0, 0); + } + else + { + CGDrawBitMapInRegion(raw_bmp, height, width, + 0, 0); + } + + CGFini(); + } +} // namespace CG diff --git a/dev/zka/Modules/CoreCG/FbRenderer.hxx b/dev/zka/Modules/CoreCG/FbRenderer.hxx index ca660602..9235e1f3 100644 --- a/dev/zka/Modules/CoreCG/FbRenderer.hxx +++ b/dev/zka/Modules/CoreCG/FbRenderer.hxx @@ -8,17 +8,17 @@ #include <NewKit/Defines.hxx> -#define CGInit() Kernel::SizeT __GXCursor = 0 +#define CGInit() Kernel::SizeT __CG_CURSOR = 0 #define CGColor(R, G, B) RGB(R, G, B) #define cCGClearClr CGColor(0x0, 0x0, 0x0) -#define CGFini() __GXCursor = 0 +#define CGFini() __CG_CURSOR = 0 /// @brief Performs OR drawing on the framebuffer. #define CGDrawBitMapInRegionA(_BitMp, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ { \ @@ -27,15 +27,15 @@ *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ i + \ - 4 * u))) |= (_BitMp)[__GXCursor]; \ + 4 * u))) |= (_BitMp)[__CG_CURSOR]; \ \ - ++__GXCursor; \ + ++__CG_CURSOR; \ } \ } /// @brief Draws a resource. #define CGDrawBitMapInRegion(_BitMp, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ { \ @@ -44,14 +44,14 @@ *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ i + \ - 4 * u))) = (_BitMp)[__GXCursor]; \ + 4 * u))) = (_BitMp)[__CG_CURSOR]; \ \ - ++__GXCursor; \ + ++__CG_CURSOR; \ } \ } #define CGDrawBitMapInRegionToRgn(_Rgn, _BitMp, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \ { \ @@ -60,9 +60,9 @@ *(((Kernel::UInt32*)(_Rgn + \ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ i + \ - 4 * u))) = (_BitMp)[__GXCursor]; \ + 4 * u))) = (_BitMp)[__CG_CURSOR]; \ \ - ++__GXCursor; \ + ++__CG_CURSOR; \ } \ } @@ -96,7 +96,7 @@ /// @brief Draws inside a zone. #define CGDrawInRegionToRgn(_Rgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ { \ @@ -105,13 +105,13 @@ *(((volatile Kernel::UInt32*)(_Rgn + \ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ x_base + \ - 4 * y_base))) = _Clr[__GXCursor]; \ - ++__GXCursor; \ + 4 * y_base))) = _Clr[__CG_CURSOR]; \ + ++__CG_CURSOR; \ } \ } #define CGDrawInRegionToVideoRgn(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ { \ @@ -121,12 +121,12 @@ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ x_base + \ 4 * y_base))) = _Clr; \ - ++__GXCursor; \ + ++__CG_CURSOR; \ } \ } #define CGDrawInRegionToVideoRgnA(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \ - __GXCursor = 0; \ + __CG_CURSOR = 0; \ \ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \ { \ @@ -136,7 +136,7 @@ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \ x_base + \ 4 * y_base))) |= _Clr; \ - ++__GXCursor; \ + ++__CG_CURSOR; \ } \ } diff --git a/dev/zka/Modules/CoreCG/Math.hxx b/dev/zka/Modules/CoreCG/Math.hxx index bfa28a3d..07da020d 100644 --- a/dev/zka/Modules/CoreCG/Math.hxx +++ b/dev/zka/Modules/CoreCG/Math.hxx @@ -6,17 +6,56 @@ #pragma once -/// @file Math.hxx -/// @brief Linear interpolation implementation. +#include <NewKit/Defines.hxx> -typedef float CGReal; +/// @file Math.hxx +/// @brief Math functions. -/// @brief Linear interpolation equation solver. -/// @param from where? -/// @param to to? -/// @param at which state we're at **to**. -inline CGReal CGLerp(CGReal to, CGReal from, CGReal stat) +namespace CG { - CGReal difference = to - from; - return from + (difference * stat); -} + using namespace Kernel; + +#ifdef __ZKA_USE_DOUBLE__ + typedef double CGReal; +#else + typedef float CGReal; +#endif + + /// @brief Square of function, with Base template argument. + /// @param of Base argument to find sqquare of + template <CGReal Base> + inline CGReal SqrOf(CGReal of) + { + return (of / (1.0 / Base)); + } + + /// @brief Power function, with Repeat argument. + template <CGReal Exponent> + inline CGReal Pow(CGReal in) + { + if (Exponent == 0) + return 1; // Any number to the power of 0 is 1. + + if (Exponent == 1) + return in; // Any number to the power of 1 is itself. + + Int32 cnt = Exponent; + + CGReal result = 1; + + for (auto i = 0; i < (cnt); ++i) + result *= in; + + return result; + } + + /// @brief Linear interpolation equation solver. + /// @param from where? + /// @param to to? + /// @param at which state we're at **to**. + inline CGReal CGLerp(CGReal to, CGReal from, CGReal stat) + { + CGReal diff = (to - from); + return from + (diff * stat); + } +} // namespace CG diff --git a/dev/zka/Modules/CoreCG/TextRenderer.hxx b/dev/zka/Modules/CoreCG/TextRenderer.hxx index 34caa420..b3a6b88c 100644 --- a/dev/zka/Modules/CoreCG/TextRenderer.hxx +++ b/dev/zka/Modules/CoreCG/TextRenderer.hxx @@ -161,7 +161,9 @@ inline Kernel::Void CGRenderStringFromBitMap(const Kernel::UInt8* bitmap, const set = bitmap[x] & (1 << y);
if (set)
+ {
CGDrawInRegion(color, 1, 1, ((x_dst) + x), ((y_dst) + y));
+ }
}
}
}
diff --git a/dev/zka/Modules/CoreCG/WindowRenderer.hxx b/dev/zka/Modules/CoreCG/WindowRenderer.hxx deleted file mode 100644 index 775b80c0..00000000 --- a/dev/zka/Modules/CoreCG/WindowRenderer.hxx +++ /dev/null @@ -1,265 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include <Modules/CoreCG/Accessibility.hxx> -#include <KernelKit/Heap.hxx> -#include <KernelKit/UserProcessScheduler.hxx> -#include <KernelKit/LPC.hxx> -#include <NewKit/Defines.hxx> -#include <NewKit/Utils.hxx> -#include <Modules/CoreCG/FbRenderer.hxx> -#include <Modules/CoreCG/Rsrc/WndControls.rsrc> -#include <Modules/CoreCG/TextRenderer.hxx> - -namespace CG -{ - using namespace Kernel; - - struct UI_WINDOW_STRUCT; - - enum - { - cWndFlagNoShow = 0x02, - cWndFlagButton = 0x04, - cWndFlagWindow = 0x06, - cWndFlagButtonSelect = 0x08, - cWndFlagHideCloseControl = 0x010, - cWndFlagCloseControlSelect = 0x012, - }; - - struct UI_WINDOW_STRUCT final - { - static constexpr auto cChildElementCount = 255; - - Char w_window_name[255]{0}; - Char w_class_name[255]{0}; - Int32 w_type{0}; - Int32 w_sub_type{0}; - Int32 w_x{0}; - Int32 w_y{0}; - Int32 w_w{0}; - Int32 w_h{0}; - Size w_child_count{0}; - struct UI_WINDOW_STRUCT* w_child_elements[cChildElementCount]{0}; - struct UI_WINDOW_STRUCT* w_parent{nullptr}; - UInt32* w_display_ptr{nullptr}; - Bool w_needs_repaint{false}; - }; - - typedef struct UI_WINDOW_STRUCT UI_WINDOW_STRUCT; - - /// \brief Draw background (either image or solid color) - inline Void CGDrawBackground(UInt32* raw_bmp = nullptr, SizeT width = 0, SizeT height = 0) noexcept - { - CGInit(); - - if (!raw_bmp) - { - const auto cColorBackground = CGColor(0x45, 0x00, 0x06); - - CGDrawInRegion(cColorBackground, CG::UIAccessibilty::The().Height(), CG::UIAccessibilty::The().Width(), - 0, 0); - } - else - { - CGDrawBitMapInRegion(raw_bmp, height, width, - 0, 0); - } - - CGFini(); - } - - inline struct UI_WINDOW_STRUCT* CGCreateWindow(Int32 kind, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, UI_WINDOW_STRUCT* parent = nullptr) - { - UI_WINDOW_STRUCT* wnd = new UI_WINDOW_STRUCT(); - - if (!wnd) - { - ErrLocal() = kErrorHeapOutOfMemory; - return nullptr; - } - - rt_copy_memory((VoidPtr)window_name, wnd->w_window_name, rt_string_len(window_name)); - rt_copy_memory((VoidPtr)class_name, wnd->w_class_name, rt_string_len(class_name)); - - if (parent) - { - wnd->w_parent = parent; - - ++wnd->w_parent->w_child_count; - wnd->w_parent->w_child_elements[wnd->w_parent->w_child_count - 1] = wnd; - } - - wnd->w_sub_type = 0; - wnd->w_type = kind; - wnd->w_x = x; - wnd->w_y = y; - - wnd->w_w = width; - wnd->w_h = height; - - wnd->w_display_ptr = new UInt32[width * height]; - rt_set_memory(wnd->w_display_ptr, CGColor(0xF5, 0xF5, 0xF5), width * height); - - return wnd; - } - - /// \brief Destroys a window and it's contents. - inline Bool CGDestroyWindow(struct UI_WINDOW_STRUCT* wnd) - { - if (wnd) - { - if (!mm_is_valid_heap(wnd)) - { - wnd = nullptr; - return true; - } - - wnd->w_needs_repaint = No; - - for (SizeT index = 0UL; index < wnd->w_child_count; ++index) - { - CGDestroyWindow(wnd->w_child_elements[index]); - } - - delete wnd; - wnd = nullptr; - - return true; - } - - return false; - } - - inline Kernel::Void CGDrawStringToWnd(UI_WINDOW_STRUCT* wnd, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color) - { - y_dst += wnd->w_y + FLATCONTROLS_HEIGHT; - x_dst += wnd->w_x; - - if (y_dst > (wnd->w_h + wnd->w_y)) - return; - - for (Kernel::SizeT i = 0; text[i] != 0; ++i) - { - if (x_dst > (wnd->w_w + wnd->w_x)) - break; - - CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color); - x_dst += FONT_SIZE_Y; - } - } - - inline SizeT CGDrawWindowList(UI_WINDOW_STRUCT** wnd, SizeT wnd_cnt) - { - if (wnd_cnt == 0 || - !wnd) - return 0; - - SizeT cnt = 0; - - for (SizeT index = 0; index < wnd_cnt; ++index) - { - if (!wnd[index] || - (wnd[index]->w_type == cWndFlagNoShow) || - !wnd[index]->w_needs_repaint) - continue; - - CGInit(); - - wnd[index]->w_needs_repaint = false; - - if (UIAccessibilty::The().Width() < wnd[index]->w_x) - { - if ((wnd[index]->w_x - UIAccessibilty::The().Width()) > 1) - { - wnd[index]->w_x -= wnd[index]->w_x - UIAccessibilty::The().Width(); - } - else - { - wnd[index]->w_x = 0; - } - } - - if (UIAccessibilty::The().Height() < wnd[index]->w_y) - { - if ((wnd[index]->w_y - UIAccessibilty::The().Height()) > 1) - { - wnd[index]->w_y -= wnd[index]->w_y - UIAccessibilty::The().Width(); - } - else - { - wnd[index]->w_y = 0; - } - } - - ++cnt; - - // Draw fake controls, just for the looks of it (WINDOW ONLY) - if (wnd[index]->w_type == cWndFlagWindow) - { - CGDrawBitMapInRegion(wnd[index]->w_display_ptr, wnd[index]->w_h, wnd[index]->w_w, wnd[index]->w_y, wnd[index]->w_x); - CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w, FLATCONTROLS_HEIGHT, wnd[index]->w_y, wnd[index]->w_x); - - if (wnd[index]->w_sub_type != cWndFlagHideCloseControl) - { - if (wnd[index]->w_sub_type == cWndFlagCloseControlSelect) - { - CGDrawBitMapInRegion(FlatControlsClose, FLATCONTROLS_CLOSE_HEIGHT, FLATCONTROLS_CLOSE_WIDTH, wnd[index]->w_y, wnd[index]->w_x + wnd[index]->w_w - FLATCONTROLS_WIDTH); - } - else - { - CGDrawBitMapInRegion(FlatControls, FLATCONTROLS_HEIGHT, FLATCONTROLS_WIDTH, wnd[index]->w_y, wnd[index]->w_x + wnd[index]->w_w - FLATCONTROLS_WIDTH); - } - } - - CGDrawString(wnd[index]->w_window_name, wnd[index]->w_y + 8, wnd[index]->w_x + 8, CGColor(0x00, 0x00, 0x00)); - } - /// @note buttons in this library are dynamic, it's because we want to avoid as much as computations as possible. - /// (Such as getting the middle coordinates of a button, to center the text.) - else if (wnd[index]->w_type == cWndFlagButtonSelect) - { - auto x_center = wnd[index]->w_x + 6; - auto y_center = wnd[index]->w_y + 7; - - CGDrawInRegion(CGColor(0xD3, 0x74, 0x00), wnd[index]->w_w + 1, wnd[index]->w_h + 1, wnd[index]->w_y, wnd[index]->w_x); - CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1, wnd[index]->w_h - 1, wnd[index]->w_y + 1, wnd[index]->w_x + 1); - CGDrawStringToWnd(wnd[index], wnd[index]->w_window_name, y_center, x_center, CGColor(0x00, 0x00, 0x00)); - } - else if (wnd[index]->w_type == cWndFlagButton) - { - auto x_center = wnd[index]->w_x + 6; - auto y_center = wnd[index]->w_y + 7; - - CGDrawInRegion(CGColor(0xDC, 0xDC, 0xDC), wnd[index]->w_w + 1, wnd[index]->w_h + 1, wnd[index]->w_y, wnd[index]->w_x); - CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1, wnd[index]->w_h - 1, wnd[index]->w_y + 1, wnd[index]->w_x + 1); - CGDrawString(wnd[index]->w_window_name, y_center, x_center, CGColor(0x00, 0x00, 0x00)); - } - - CGFini(); - - // draw child windows and controls. - // doesn't have to be a window, enabling then windows in windows. - - for (SizeT child = 0; child < wnd[index]->w_child_count; ++child) - { - wnd[index]->w_child_elements[child]->w_x += wnd[index]->w_x; - wnd[index]->w_child_elements[child]->w_y += wnd[index]->w_y + FLATCONTROLS_HEIGHT; - - if ((wnd[index]->w_child_elements[child]->w_w + wnd[index]->w_child_elements[child]->w_x) > (wnd[index]->w_x + wnd[index]->w_w) || - (wnd[index]->w_child_elements[child]->w_h + wnd[index]->w_child_elements[child]->w_y) > (wnd[index]->w_y + wnd[index]->w_h)) - continue; - - CGDrawWindowList(&wnd[index]->w_child_elements[child], 1); - } - - CGFini(); - } - - return cnt; - } -} // namespace CG diff --git a/dev/zka/Modules/GL/.keepme b/dev/zka/Modules/GLCG/.keepme index e69de29b..e69de29b 100644 --- a/dev/zka/Modules/GL/.keepme +++ b/dev/zka/Modules/GLCG/.keepme diff --git a/dev/zka/Modules/NVME/Defines.hxx b/dev/zka/Modules/NVME/NVME.hxx index 3e8b9c98..3667b980 100644 --- a/dev/zka/Modules/NVME/Defines.hxx +++ b/dev/zka/Modules/NVME/NVME.hxx @@ -24,8 +24,8 @@ namespace Kernel struct ALIGN_NVME NVMEBar0 final { - NVMEInt32 fCap; - NVMEInt32 fVer; + NVMEInt32 fCapabilities; + NVMEInt32 fVersion; NVMEInt32 fIntMaskSet; NVMEInt32 fIntMaskClr; NVMEInt32 fContrlConf; |
