Skip to content

Implement partial updates using damage rectangles for Orbital#344

Open
yagizgil wants to merge 7 commits intorust-windowing:masterfrom
yagizgil:branch1
Open

Implement partial updates using damage rectangles for Orbital#344
yagizgil wants to merge 7 commits intorust-windowing:masterfrom
yagizgil:branch1

Conversation

@yagizgil
Copy link

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:
beforecahnges

after changes
afterchanges

Tested on:

  • AppKit (tier 1)
  • Wayland (tier 1)
  • Win32 (tier 1)
  • XCB / Xlib (tier 1)
  • Android NDK (tier 2)
  • UIKit (tier 2)
  • Web (tier 2)
  • DRM/KMS (tier 3)
  • Orbital (tier 3)

@yagizgil yagizgil requested a review from jackpot51 as a code owner March 15, 2026 01:27
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@madsmtm madsmtm added DS - Orbital enhancement New feature or request labels Mar 15, 2026
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

@yagizgil yagizgil Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did as you said and short the code.
I couldn't find "union_rect" I used "union_damage"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant as an alternative to is_full_damage etc., something similar to what Web did before #321

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did i do it right?

@yagizgil yagizgil requested review from jackpot51 and madsmtm March 15, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - Orbital enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants