-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that damage is non-overlapping #1198
Conversation
8efbc9f
to
6d68722
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1198 +/- ##
==========================================
- Coverage 21.98% 21.85% -0.14%
==========================================
Files 154 155 +1
Lines 24093 24240 +147
==========================================
- Hits 5298 5297 -1
- Misses 18795 18943 +148
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
6d68722
to
8b6ee26
Compare
This should be ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I was writing this I'd absolutely add some proptest tests. Have it generate a random Vec of Rectangles of input, run the damage shaper, then verify that:
- All input rectangles are covered with damage.
- There's no overlap in the output.
Such algorithms could generally be proved by induction, you have a routine to shape tiles, and it's being checked, and you have a top-level driver that just uses sort and find gap inside of it, so all you need to test is sort of tested already. |
8b6ee26
to
8b04d13
Compare
this thing is harder than you think, because it's basically requires the same algorithm we're using, but for opaque regions. |
The previous logic was blindly merging and doing only a forward pass, however this won't work when after merging 2 rectangles already processed one could end up in overlap. This is an example of old renderer doing so: ``` [ 697101.942] [email protected]_buffer(66, 350, 36, 48) [ 697101.956] [email protected]_buffer(126, 446, 828, 168) [ 697101.965] [email protected]_buffer(90, 638, 744, 528) [ 697101.974] [email protected]_buffer(162, 1262, 420, 72) [ 697101.984] [email protected]_buffer(114, 1358, 312, 48) [ 697101.994] [email protected]() damage to be rendered: [ Rectangle<smithay::utils::geometry::Physical> { x: 158, y: 478, width: 828, height: 168, }, Rectangle<smithay::utils::geometry::Physical> { x: 194, y: 1294, width: 420, height: 72, }, Rectangle<smithay::utils::geometry::Physical> { x: 146, y: 1390, width: 312, height: 48, }, Rectangle<smithay::utils::geometry::Physical> { x: 32, y: 382, width: 834, height: 1152, }, ] ``` The new algorithm trying splits damage bounding box into non-overlapping regions containing damage, and then running tile-based damage shaping, where for each tile we try to find total intersection + union of damage rectangles.
8b04d13
to
09b1e60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks!
The previous logic was blindly merging and doing only a forward pass, however this won't work when after merging 2 rectangles already processed one could end up in overlap.
This is an example of old renderer doing so:
The new algorithm trying splits damage bounding box into non-overlapping regions containing damage, and then running tile-based damage shaping, where for each tile we try to find total intersection + union of damage rectangles.
--
I still should add tests for common patterns, but the main idea of implementation should be good.