Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upClip against near plane for bounds calculus #2741
Conversation
|
|
176e93c
to
cf5c87b
|
Inviting reviewers! cc @glennw |
|
|
||
| // All clipping ClipScrollNodes should have outer rectangles, because they never | ||
| // use the BorderCorner clip type and they always have at last one non-ClipOut | ||
| // Rectangle ClipSource. | ||
| let screen_outer_rect = screen_outer_rect.expect("Clipping node didn't have outer rect."); | ||
| let screen_outer_rect = match screen_outer_rect { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
kvark
May 9, 2018
Author
Member
In this code, it may be None if either local_outer_rect of the clip source is None, or the computed bounding rect is outside the screen.
This comment has been minimized.
This comment has been minimized.
mrobinson
May 9, 2018
Member
For ClipScrollNodes, the local_outer_rect is never None. We use None to indicate situations where an outer rect cannot be calculated and an empty rectangle to indicate a situation where the clip rect is empty. I think the case where the outer bounds do not intersect with the screen rect is an empty clip rectangle situation. In order to avoid having None do double duty (and subtly breaking other parts of the code), I think we should maintain the expect here and have the non-intersection case produce an empty rectangle.
| transform.transform_point2d(&rect.bottom_left()), | ||
| transform.transform_point2d(&rect.bottom_right()), | ||
| screen_bounds: Option<&DeviceIntRect>, | ||
| ) -> Option<DeviceIntRect> { |
This comment has been minimized.
This comment has been minimized.
mrobinson
May 9, 2018
Member
I recall this function as being extremely performance sensitive, so is there any way to have a fast path when it isn't necessary to do all of these calculations?
This comment has been minimized.
This comment has been minimized.
kvark
May 9, 2018
Author
Member
The way it's build is to avoid extra steps unless necessary. So the old transform_point2d for each corner is equivalent to transform_point_2d_homogeneous followed by to_point2d at the end.
Extra overhead may come from the following sources:
- more stuff being moved around (copies are the doom of Rust code)
- comparing 4 f32 values to 0 in
homogens.iter().any(|h| h.w <= 0.0) - worse instruction cache utilization for the function body being grown
Overall, I think it's a reasonable compromise, and it's not clear to me if we can do better here.
This comment has been minimized.
This comment has been minimized.
mrobinson
May 9, 2018
•
Member
One thing we could do here is to detect when transformation doesn't project into three dimensions and to use the old code for this situation. You could have this path be an early return and avoid the long if statement in the body.
|
I'm a bit puzzled over AppVeyor reftest failure... |
|
The try push also looks good. |
|
|
||
| // All clipping ClipScrollNodes should have outer rectangles, because they never | ||
| // use the BorderCorner clip type and they always have at last one non-ClipOut | ||
| // Rectangle ClipSource. | ||
| let screen_outer_rect = screen_outer_rect.expect("Clipping node didn't have outer rect."); | ||
| let screen_outer_rect = match screen_outer_rect { |
This comment has been minimized.
This comment has been minimized.
kvark
May 9, 2018
Author
Member
In this code, it may be None if either local_outer_rect of the clip source is None, or the computed bounding rect is outside the screen.
| transform.transform_point2d(&rect.bottom_left()), | ||
| transform.transform_point2d(&rect.bottom_right()), | ||
| screen_bounds: Option<&DeviceIntRect>, | ||
| ) -> Option<DeviceIntRect> { |
This comment has been minimized.
This comment has been minimized.
kvark
May 9, 2018
Author
Member
The way it's build is to avoid extra steps unless necessary. So the old transform_point2d for each corner is equivalent to transform_point_2d_homogeneous followed by to_point2d at the end.
Extra overhead may come from the following sources:
- more stuff being moved around (copies are the doom of Rust code)
- comparing 4 f32 values to 0 in
homogens.iter().any(|h| h.w <= 0.0) - worse instruction cache utilization for the function body being grown
Overall, I think it's a reasonable compromise, and it's not clear to me if we can do better here.
|
@mrobinson thanks for taking a look! I think we are all set, unless there are more concerns. |
| @@ -15,7 +15,7 @@ extern crate core_graphics; | |||
| extern crate crossbeam; | |||
| #[cfg(target_os = "windows")] | |||
| extern crate dwrote; | |||
| #[cfg(feature = "logging")] | |||
| #[cfg(feature = "env_logger")] | |||
This comment has been minimized.
This comment has been minimized.
|
Sorry for the weird review on my part! This is looking pretty reasonable to me, but I have a few minor nits that I think could be addressed before landing. |
… where transformed polygons intersect the near plane.
|
@mrobinson
It would involve more logic duplication and control flow tweaks, so I'm not sure it's worth it. Maybe we can leave a TODO comment in the code saying to keep an eye for this branch when profiling? |
|
I don't want this to stall any longer. |
|
|
Clip against near plane for bounds calculus Fixes #2389 Fixes #2272 Improves #2429 a great deal (there are general plane splitting issues in there still) TODO: - [x] reviews - [x] green CI - [x] try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ddccbd9f16aea173fe950293f1a4f429650dea6a <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2741) <!-- Reviewable:end -->
|
|
Proper near plane splitting The PR is built on the shoulders of #2913, #2741, servo/euclid#277, servo/euclid#291, servo/plane-split#12, and (last but not the least!) servo/plane-split#15 It uses the new clipping semantics in `plane-split` crate uniformly for both bounding box computation and 3d plane splitting itself, ensuring that no incorrect perspective divisions are performed (and closing quite a few TODO entries). Also adds a small reftest for the latter. Fixes #2272 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2947) <!-- Reviewable:end -->
kvark commentedMay 8, 2018
•
edited
Fixes #2389
Fixes #2272
Improves #2429 a great deal (there are general plane splitting issues in there still)
TODO:
This change is