From ec2a9d1883721c0b065e0de0d223f0b9742fd1b3 Mon Sep 17 00:00:00 2001 From: boreddevnl Date: Sun, 22 Mar 2026 18:55:55 +0100 Subject: [PATCH] OPTIMIZATION: Browser loading optimization --- fix_syscalls.sh | 7 ------- src/userland/gui/browser.c | 6 +++--- src/userland/gui/paint.c | 10 +++++----- src/wm/explorer.c | 2 +- src/wm/wm.h | 11 +++++------ 5 files changed, 14 insertions(+), 22 deletions(-) delete mode 100755 fix_syscalls.sh diff --git a/fix_syscalls.sh b/fix_syscalls.sh deleted file mode 100755 index e1d7072..0000000 --- a/fix_syscalls.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -sed -i '' -e 's/asm volatile("pushfq; pop %0; cli" : "=r"(rflags));/rflags = wm_lock_acquire();/g' src/sys/syscall.c -sed -i '' -e 's/asm volatile("push %0; popfq" : : "r"(rflags));/wm_lock_release(rflags);/g' src/sys/syscall.c -sed -i '' -e 's/asm volatile("pushfq; pop %0; cli" : "=r"(rflags));/rflags = wm_lock_acquire();/g' src/wm/wm.c -sed -i '' -e 's/asm volatile("push %0; popfq" : : "r"(rflags));/wm_lock_release(rflags);/g' src/wm/wm.c -sed -i '' -e 's/uint64_t rflags;/uint64_t rflags;/g' src/sys/syscall.c -echo "Done" diff --git a/src/userland/gui/browser.c b/src/userland/gui/browser.c index 996fc4f..709aa2d 100644 --- a/src/userland/gui/browser.c +++ b/src/userland/gui/browser.c @@ -521,7 +521,7 @@ static void flush_line(void) { if (el->tag == TAG_IMG && el->img_h + 10 > max_h) max_h = el->img_h + 10; if ((el->tag == TAG_INPUT || el->tag == TAG_BUTTON) && 20 + 10 > max_h) max_h = 20 + 10; if (el->tag == TAG_NONE) { - int fh = ui_get_font_height_scaled(el->scale); + int fh = el->h; if (fh + 4 > max_h) max_h = fh + 4; if (fh > max_baseline) max_baseline = fh; } @@ -531,7 +531,7 @@ static void flush_line(void) { RenderElement *el = &elements[line_elements[i]]; el->x = offset_x; if (el->tag == TAG_NONE) { - int fh = ui_get_font_height_scaled(el->scale); + int fh = el->h; el->y = cur_line_y + (max_baseline - fh); } else { el->y = cur_line_y; @@ -1504,7 +1504,7 @@ static void browser_paint(void) { ui_draw_string_scaled(win_browser, el->x + 1, draw_y - 1, el->content, el->color, el->scale); } if (el->underline) { - int fh = ui_get_font_height_scaled(el->scale); + int fh = el->h; ui_draw_rect(win_browser, el->x, draw_y + fh - 1, el->w, 1, el->color); } } diff --git a/src/userland/gui/paint.c b/src/userland/gui/paint.c index 4153735..6bd0545 100644 --- a/src/userland/gui/paint.c +++ b/src/userland/gui/paint.c @@ -15,9 +15,9 @@ #define COLOR_BLACK 0xFF000000 #define COLOR_WHITE 0xFFFFFFFF #define COLOR_RED 0xFFFF0000 -#define COLOR_APPLE_GREEN 0xFF4CD964 -#define COLOR_APPLE_BLUE 0xFF007AFF -#define COLOR_APPLE_YELLOW 0xFFFFCC00 +#define COLOR_GREEN 0xFF4CD964 +#define COLOR_BLUE 0xFF007AFF +#define COLOR_YELLOW 0xFFFFCC00 #define COLOR_DARK_BG 0xFF121212 #define COLOR_DARK_PANEL 0xFF202020 @@ -58,7 +58,7 @@ static void paint_paint(ui_window_t win) { ui_draw_rounded_rect_filled(win, canvas_x - 2, canvas_y - 2, CANVAS_W + 4, CANVAS_H + 4, 4, COLOR_DARK_BG); ui_draw_rounded_rect_filled(win, 10, 0, 40, 230, 6, COLOR_DARK_PANEL); - uint32_t colors[] = {COLOR_BLACK, COLOR_RED, COLOR_APPLE_GREEN, COLOR_APPLE_BLUE, COLOR_APPLE_YELLOW, COLOR_WHITE}; + uint32_t colors[] = {COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_YELLOW, COLOR_WHITE}; for (int i = 0; i < 6; i++) { int cy = 10 + (i * 25); ui_draw_rounded_rect_filled(win, 15, cy, 30, 20, 3, colors[i]); @@ -202,7 +202,7 @@ static void paint_click(ui_window_t win, int x, int y) { for (int i = 0; i < 6; i++) { int cy = 10 + (i * 25); if (y >= cy && y < cy + 20) { - uint32_t colors[] = {COLOR_BLACK, COLOR_RED, COLOR_APPLE_GREEN, COLOR_APPLE_BLUE, COLOR_APPLE_YELLOW, COLOR_WHITE}; + uint32_t colors[] = {COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_YELLOW, COLOR_WHITE}; current_color = colors[i]; paint_paint(win); ui_mark_dirty(win, 0, 0, 380, 230); diff --git a/src/wm/explorer.c b/src/wm/explorer.c index d748236..c9eae17 100644 --- a/src/wm/explorer.c +++ b/src/wm/explorer.c @@ -715,7 +715,7 @@ static void explorer_load_directory(Window *win, const char *path) { explorer_strcpy(state->items[temp_count].name, entries[i].name); state->items[temp_count].is_directory = entries[i].is_directory; state->items[temp_count].size = entries[i].size; - state->items[temp_count].color = entries[i].is_directory ? COLOR_APPLE_BLUE : COLOR_APPLE_YELLOW; + state->items[temp_count].color = entries[i].is_directory ? COLOR_BLUE : COLOR_YELLOW; temp_count++; } diff --git a/src/wm/wm.h b/src/wm/wm.h index e5b30e8..b246bb7 100644 --- a/src/wm/wm.h +++ b/src/wm/wm.h @@ -18,14 +18,13 @@ void wm_lock_release(uint64_t flags); #define COLOR_BLUE 0xFF000080 #define COLOR_LTGRAY 0xFFDFDFDF #define COLOR_DKGRAY 0xFF808080 -#define COLOR_RED 0xFFFF0000 #define COLOR_PURPLE 0xFF800080 #define COLOR_COFFEE 0xFF6B4423 -#define COLOR_APPLE_RED 0xFFFF0000 -#define COLOR_APPLE_ORANGE 0xFFFF7F00 -#define COLOR_APPLE_YELLOW 0xFFFFFF00 -#define COLOR_APPLE_GREEN 0xFF00FF00 -#define COLOR_APPLE_BLUE 0xFF0000FF +#define COLOR_RED 0xFFFF0000 +#define COLOR_ORANGE 0xFFFF7F00 +#define COLOR_YELLOW 0xFFFFFF00 +#define COLOR_GREEN 0xFF00FF00 +#define COLOR_BLUE 0xFF0000FF #define COLOR_APPLE_INDIGO 0xFF4B0082 #define COLOR_APPLE_VIOLET 0xFF9400D3