Skip to content
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

Use get_relative_transform for clip <-> prim space conversions. #2977

Merged
merged 1 commit into from Aug 21, 2018

Conversation

@gw3583
Copy link
Collaborator

gw3583 commented Aug 20, 2018

This expands the functionality in get_relative_transform to work
for both primitive and clip space conversions.

This code path is not super efficient (it could be improved), but
on the majority of sites it never runs, and even on cases where it
does run, the coordinate system tree is typically very shallow. We
can optimize this function if it ever shows up in a profile.


This change is Reviewable

@gw3583
Copy link
Collaborator Author

gw3583 commented Aug 20, 2018

r? @kvark

Try run here (looks good I think, just a few unrelated intermittents):
https://treeherder.mozilla.org/#/jobs?repo=try&revision=ffd9a4eb3c27b46449058123fec949ff4d3cdea1

I changed the expected result for one of the wrench tests - it is an incorrect test that came from Servo, and the item should actually be clipped in this case.

@gw3583 gw3583 force-pushed the gw3583:get-rel-4 branch from c84dc05 to 5f75f2b Aug 20, 2018
Copy link
Member

kvark left a comment

Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @gw3583)


webrender/src/clip_scroll_tree.rs, line 146 at r1 (raw file):

        for node in nodes {
            let coord_system = &self.coord_systems[node.0 as usize];

I wonder if we can do it the other way, so that we don't have to collect/reverse nodes and everything is a simple pass? I.e. currently we collect nodes by ascending from child to parent, then reverse them, then accumulate the transforms on the way from parent to child. Can we instead accumulate it from child to parent in the first place?


webrender/src/clip_scroll_tree.rs, line 495 at r1 (raw file):

    let m = cst.get_relative_transform(from, to).unwrap();
    let pt = m.transform_point2d(&p).unwrap();
    assert!((pt.x - expected_x).abs() < 0.0001 &&

nit: can we use the euclid::approx_eq::ApproxEq::approx_epsilon here?


webrender/src/clip_scroll_tree.rs, line 595 at r1 (raw file):

#[test]
fn test_cst_scale_translation() {

wow nice set of tests! 👏


webrender/src/clip_scroll_tree.rs, line 625 at r1 (raw file):

    test_pt(100.0, 100.0, &cst, child1, root, 200.0, 150.0);
    test_pt(100.0, 100.0, &cst, child2, root, 300.0, 450.0);
    // test_pt(100.0, 100.0, &cst, root, child1, 0.0, 50.0);

what about those commented out ones?


wrench/reftests/transforms/reftest.list, line 13 at r1 (raw file):

== segments-bug.yaml segments-bug-ref.yaml
platform(linux,mac) == content-offset.yaml content-offset.png
platform(linux,mac) != coord-system.yaml coord-system.png

oh, shouldn't we just update the png instead to make it match? Equality test is more useful than the non-equality one

This expands the functionality in get_relative_transform to work
for both primitive and clip space conversions.

This code path is not super efficient (it could be improved), but
on the majority of sites it never runs, and even on cases where it
does run, the coordinate system tree is typically very shallow. We
can optimize this function if it ever shows up in a profile.
@gw3583 gw3583 force-pushed the gw3583:get-rel-4 branch from 5f75f2b to 4c1689f Aug 20, 2018
Copy link
Collaborator Author

gw3583 left a comment

Reviewable status: 2 of 6 files reviewed, 4 unresolved discussions (waiting on @kvark and @gw3583)


webrender/src/clip_scroll_tree.rs, line 146 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

I wonder if we can do it the other way, so that we don't have to collect/reverse nodes and everything is a simple pass? I.e. currently we collect nodes by ascending from child to parent, then reverse them, then accumulate the transforms on the way from parent to child. Can we instead accumulate it from child to parent in the first place?

We definitely can, at least in some cases. I was planning to do this as a later follow up, if that's ok (once I've got more of the patches done that will rely on this code). But, I can do this optimization now, if you'd prefer?


webrender/src/clip_scroll_tree.rs, line 495 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

nit: can we use the euclid::approx_eq::ApproxEq::approx_epsilon here?

Done


webrender/src/clip_scroll_tree.rs, line 595 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

wow nice set of tests! 👏

Done.


webrender/src/clip_scroll_tree.rs, line 625 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

what about those commented out ones?

Re-enabled those.


wrench/reftests/transforms/reftest.list, line 13 at r1 (raw file):

Previously, kvark (Dzmitry Malyshau) wrote…

oh, shouldn't we just update the png instead to make it match? Equality test is more useful than the non-equality one

Add blank.yaml and made it an equality check to ensure the primitive is culled.

@gw3583
Copy link
Collaborator Author

gw3583 commented Aug 21, 2018

@kvark Thanks for the review - comments addressed, I think.

@kvark
Copy link
Member

kvark commented Aug 21, 2018

Thank you!
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Aug 21, 2018

📌 Commit 4c1689f has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Aug 21, 2018

Testing commit 4c1689f with merge 939e955...

bors-servo added a commit that referenced this pull request Aug 21, 2018
Use get_relative_transform for clip <-> prim space conversions.

This expands the functionality in get_relative_transform to work
for both primitive and clip space conversions.

This code path is not super efficient (it could be improved), but
on the majority of sites it never runs, and even on cases where it
does run, the coordinate system tree is typically very shallow. We
can optimize this function if it ever shows up in a profile.

<!-- 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/2977)
<!-- Reviewable:end -->
@kvark
kvark approved these changes Aug 21, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Aug 21, 2018

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: kvark
Pushing 939e955 to master...

@bors-servo bors-servo merged commit 4c1689f into servo:master Aug 21, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 4 files, 4 discussions left (kvark)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.