OPTIMIZATION: Browser loading optimization

This commit is contained in:
boreddevnl 2026-03-22 18:55:55 +01:00
parent 4c46650c64
commit ec2a9d1883
5 changed files with 14 additions and 22 deletions

View file

@ -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"

View file

@ -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_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_INPUT || el->tag == TAG_BUTTON) && 20 + 10 > max_h) max_h = 20 + 10;
if (el->tag == TAG_NONE) { 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 + 4 > max_h) max_h = fh + 4;
if (fh > max_baseline) max_baseline = fh; if (fh > max_baseline) max_baseline = fh;
} }
@ -531,7 +531,7 @@ static void flush_line(void) {
RenderElement *el = &elements[line_elements[i]]; RenderElement *el = &elements[line_elements[i]];
el->x = offset_x; el->x = offset_x;
if (el->tag == TAG_NONE) { 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); el->y = cur_line_y + (max_baseline - fh);
} else { } else {
el->y = cur_line_y; 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); ui_draw_string_scaled(win_browser, el->x + 1, draw_y - 1, el->content, el->color, el->scale);
} }
if (el->underline) { 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); ui_draw_rect(win_browser, el->x, draw_y + fh - 1, el->w, 1, el->color);
} }
} }

View file

@ -15,9 +15,9 @@
#define COLOR_BLACK 0xFF000000 #define COLOR_BLACK 0xFF000000
#define COLOR_WHITE 0xFFFFFFFF #define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFFFF0000 #define COLOR_RED 0xFFFF0000
#define COLOR_APPLE_GREEN 0xFF4CD964 #define COLOR_GREEN 0xFF4CD964
#define COLOR_APPLE_BLUE 0xFF007AFF #define COLOR_BLUE 0xFF007AFF
#define COLOR_APPLE_YELLOW 0xFFFFCC00 #define COLOR_YELLOW 0xFFFFCC00
#define COLOR_DARK_BG 0xFF121212 #define COLOR_DARK_BG 0xFF121212
#define COLOR_DARK_PANEL 0xFF202020 #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, 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); 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++) { for (int i = 0; i < 6; i++) {
int cy = 10 + (i * 25); int cy = 10 + (i * 25);
ui_draw_rounded_rect_filled(win, 15, cy, 30, 20, 3, colors[i]); 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++) { for (int i = 0; i < 6; i++) {
int cy = 10 + (i * 25); int cy = 10 + (i * 25);
if (y >= cy && y < cy + 20) { 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]; current_color = colors[i];
paint_paint(win); paint_paint(win);
ui_mark_dirty(win, 0, 0, 380, 230); ui_mark_dirty(win, 0, 0, 380, 230);

View file

@ -715,7 +715,7 @@ static void explorer_load_directory(Window *win, const char *path) {
explorer_strcpy(state->items[temp_count].name, entries[i].name); explorer_strcpy(state->items[temp_count].name, entries[i].name);
state->items[temp_count].is_directory = entries[i].is_directory; state->items[temp_count].is_directory = entries[i].is_directory;
state->items[temp_count].size = entries[i].size; 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++; temp_count++;
} }

View file

@ -18,14 +18,13 @@ void wm_lock_release(uint64_t flags);
#define COLOR_BLUE 0xFF000080 #define COLOR_BLUE 0xFF000080
#define COLOR_LTGRAY 0xFFDFDFDF #define COLOR_LTGRAY 0xFFDFDFDF
#define COLOR_DKGRAY 0xFF808080 #define COLOR_DKGRAY 0xFF808080
#define COLOR_RED 0xFFFF0000
#define COLOR_PURPLE 0xFF800080 #define COLOR_PURPLE 0xFF800080
#define COLOR_COFFEE 0xFF6B4423 #define COLOR_COFFEE 0xFF6B4423
#define COLOR_APPLE_RED 0xFFFF0000 #define COLOR_RED 0xFFFF0000
#define COLOR_APPLE_ORANGE 0xFFFF7F00 #define COLOR_ORANGE 0xFFFF7F00
#define COLOR_APPLE_YELLOW 0xFFFFFF00 #define COLOR_YELLOW 0xFFFFFF00
#define COLOR_APPLE_GREEN 0xFF00FF00 #define COLOR_GREEN 0xFF00FF00
#define COLOR_APPLE_BLUE 0xFF0000FF #define COLOR_BLUE 0xFF0000FF
#define COLOR_APPLE_INDIGO 0xFF4B0082 #define COLOR_APPLE_INDIGO 0xFF4B0082
#define COLOR_APPLE_VIOLET 0xFF9400D3 #define COLOR_APPLE_VIOLET 0xFF9400D3