core: optimize VBO
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ic29424c13a4b2fbf6d74e6ec4c2bedde6a6a6964
This commit is contained in:
parent
46ea940242
commit
3d4974a128
1 changed files with 9 additions and 2 deletions
11
src/core.c
11
src/core.c
|
|
@ -96,6 +96,7 @@ static int assign_wallpaper_to_output(chroma_state_t *state,
|
|||
bool image_changed = (output->image != image);
|
||||
if (image_changed && output->image) {
|
||||
chroma_output_invalidate_texture(output);
|
||||
output->vbo_dirty = true; // VBO needs update for new image
|
||||
chroma_log("DEBUG", "Image changed for output %u, invalidated texture",
|
||||
output->id);
|
||||
}
|
||||
|
|
@ -103,6 +104,11 @@ static int assign_wallpaper_to_output(chroma_state_t *state,
|
|||
// Assign image to output
|
||||
output->image = image;
|
||||
|
||||
// Mark VBO as dirty if image changed
|
||||
if (image_changed) {
|
||||
output->vbo_dirty = true;
|
||||
}
|
||||
|
||||
// Store old configuration values for comparison
|
||||
chroma_scale_mode_t old_scale_mode = output->scale_mode;
|
||||
chroma_filter_quality_t old_filter_quality = output->filter_quality;
|
||||
|
|
@ -120,6 +126,7 @@ static int assign_wallpaper_to_output(chroma_state_t *state,
|
|||
if (had_config && (old_scale_mode != output->scale_mode ||
|
||||
old_filter_quality != output->filter_quality)) {
|
||||
chroma_output_invalidate_texture(output);
|
||||
output->vbo_dirty = true; // VBO needs update for new scale mode
|
||||
chroma_log("DEBUG",
|
||||
"Configuration changed for output %u, invalidated texture",
|
||||
output->id);
|
||||
|
|
@ -273,14 +280,14 @@ int chroma_run(chroma_state_t *state) {
|
|||
break;
|
||||
}
|
||||
|
||||
// Use select() to wait for events with timeout
|
||||
// Use `select()` to wait for events with longer timeout to reduce CPU usage
|
||||
fd_set readfds;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(fd, &readfds);
|
||||
|
||||
timeout.tv_sec = 1; // 1s timeout
|
||||
timeout.tv_sec = 10;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
int select_result = select(fd + 1, &readfds, NULL, NULL, &timeout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue