Implement partial updates using damage rectangles for Orbital#344
Implement partial updates using damage rectangles for Orbital#344yagizgil wants to merge 7 commits intorust-windowing:masterfrom
Conversation
src/backends/orbital.rs
Outdated
| let offset_data = y * window_width; | ||
| window_data[offset_data..offset_data + min_width] | ||
| .copy_from_slice(&buffer[offset_buffer..offset_buffer + min_width]); | ||
| // let min_width = cmp::min(width, window_width); |
There was a problem hiding this comment.
Please remove commented out code
src/backends/orbital.rs
Outdated
| if width == window_width && (damage.is_empty() || is_full_damage(damage, width, height)) { | ||
| let total_pixels = width * height; | ||
| window_data[..total_pixels].copy_from_slice(&buffer[..total_pixels]); | ||
| } else { |
There was a problem hiding this comment.
I'm not that interested in a bunch of extra code for a code path that's ideally gonna never be taken (Pixels::Mapping is the way to go). Especially if the perf wins aren't even really there.
If you really want damage tracking here, maybe you could use util::union_rect instead, and then just copy the resulting rect? That'd be a simpler implementation, and probably just as fast.
There was a problem hiding this comment.
I did as you said and short the code.
I couldn't find "union_rect" I used "union_damage"
There was a problem hiding this comment.
I meant as an alternative to is_full_damage etc., something similar to what Web did before #321
Updated present_with_damage to actually use the provided damage rects instead of ignoring them.
If damage covers the full screen or is empty, it performs a single copy_from_slice.
If a specific damage rect covers the full width of the window, it copies that block contiguously.
Otherwise, it performs row-by-row copying for specific damaged areas, avoiding unnecessary memory operations for unchanged pixels.
Even though its not very accurate, i saw a minimal difference
The performance difference was measured in qemu.
Host specific results may vary, but the implementation of damage tracking ensures that we only update the necesary parts of the buffer
before changes:

after changes

Tested on: