Allow preloading multiple background images to GPU for fast switching

Fixes #9836
This commit is contained in:
Kovid Goyal
2026-04-15 22:34:20 +05:30
parent 92262ca095
commit 2c9541cf21
15 changed files with 255 additions and 85 deletions

View File

@@ -76,3 +76,33 @@ func read_window_logo(io_data *rc_io_data, path string) (func(io_data *rc_io_dat
return false, nil
}, nil
}
func is_index_arg(s string) bool {
if len(s) == 0 {
return false
}
start := 0
if s[0] == '+' || s[0] == '-' {
start = 1
}
if start >= len(s) {
return false
}
for _, c := range s[start:] {
if c < '0' || c > '9' {
return false
}
}
return true
}
func read_background_image(io_data *rc_io_data, path string) (func(io_data *rc_io_data) (bool, error), error) {
if is_index_arg(path) {
io_data.rc.Stream = false
return func(io_data *rc_io_data) (bool, error) {
set_payload_data(io_data, "index:"+path)
return true, nil
}, nil
}
return read_window_logo(io_data, path)
}