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

Basic preserve-3d support #1169

Merged
merged 7 commits into from May 1, 2017
Merged

Basic preserve-3d support #1169

merged 7 commits into from May 1, 2017

Conversation

@kvark
Copy link
Member

kvark commented Apr 26, 2017

Goes towards #739

This is a basic implementation that features a green test case. It can be merged independently, but more work is expected to solidify it.
There is a lot of interaction of "preserve3d" stacking contexts with filters, composite ops, and such, that is not thought-through or tested at the moment. The new code should be totally safe as long as the client continues to use TransformStyle::Flat (as both Gecko/Servo still do).

r? @glennw


This change is Reviewable

@kvark kvark force-pushed the kvark:isolation branch from 49be854 to c85dbb0 Apr 26, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Apr 26, 2017

The latest upstream changes (presumably #1165) made this pull request unmergeable. Please resolve the merge conflicts.

@glennw
Copy link
Member

glennw commented Apr 26, 2017

Reviewed 17 of 22 files at r1.
Review status: 17 of 22 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


wrench/reftests/split/simple.yaml, line 7 at r1 (raw file):

    - type: stacking-context
      bounds: [0, 0, 1024, 1024]
      transform-style: preserve3d

CSS uses preserve-3d - let's use the CSS keyword in YAML files.


Comments from Reviewable

@glennw
Copy link
Member

glennw commented Apr 26, 2017

Partial review only so far - I'll be working through the remaining files today.

@glennw
Copy link
Member

glennw commented Apr 26, 2017

Reviewed 5 of 22 files at r1.
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


webrender/res/ps_split_composite.vs.glsl, line 26 at r1 (raw file):

    vec2 normalized_pos = mix(
        mix(geometry.points[0], geometry.points[1], aPosition.x),

Extracting this into a bilerp() function might make the intent clearer.


webrender/src/frame.rs, line 440 at r1 (raw file):

                                              level == 0,
                                              composition_operations,
                                              bounds.clone(),

I think this type might be Copy?


webrender/src/frame_builder.rs, line 85 at r1 (raw file):

}

fn make_polygon(sc: &StackingContext, node: &ClipScrollNode, anchor: usize)

Could you explain how the anchor parameter works?


webrender/src/frame_builder.rs, line 254 at r1 (raw file):

                // is the root of the page
                let isolation = &mut self.stacking_context_store[parent_index.0].isolation;
                if *isolation != ContextIsolation::None {

What could cause this - I guess if we have mix-blend-mode on a preserve-3d?


webrender/src/frame_builder.rs, line 1145 at r1 (raw file):

                    if stacking_context.isolation == ContextIsolation::Items {
                        let task_size = DeviceIntSize::from_untyped(&stacking_context.local_bounds.size.ceil().to_i32().to_untyped());

This doesn't seem right - the local bounds won't take the zoom / transform etc into effect. Shouldn't this be based on the screen bounding rect?


webrender/src/frame_builder.rs, line 1155 at r1 (raw file):

                    }

                    if composite_count == 0 && stacking_context.isolation == ContextIsolation::Full {

It might be clearer to combine this if and the one above into a match statement?


webrender/src/frame_builder.rs, line 1284 at r1 (raw file):

                    }

                    let group_index_opt = match stacking_context.isolation {

I'm not sure I fully understand this part - does this imply that any primitives in a preserve-3d context get rendered without any transform to the intermediate surface?


Comments from Reviewable

@glennw
Copy link
Member

glennw commented Apr 26, 2017

@kvark In general this looks great! It's far fewer lines of code than I expected (although I guess it helps having the plane splitting crate separate). I have a few questions about the PR above that I don't fully understand - it might be easier to discuss on IRC / Vidyo?

@glennw
Copy link
Member

glennw commented Apr 26, 2017

@kvark Ah, I think I understand a bit better now. So the current implementation renders those intermediate sources untransformed into a target. Then it splits them and composites them, applying the transform when compositing the split planes - is that right?

I think that if we do it this way, we may have quality issues when the transformed planes have an interesting transform on them - since, I think, we'll end up drawing things like text and borders at the un-zoomed quality level into the intermediate target.

If that's right - I wonder if we could do it the inverse way - draw the intermediate surfaces transformed at full zoom / scale, and then composite them in screen space?

I'm not sure how easy / feasible that is, or if I'm completely mis-understanding something - does that make any sense? :)

@glennw
Copy link
Member

glennw commented Apr 26, 2017

@kvark Also, even if the above is correct - it might still make sense to merge this now, as a step towards that?

@kvark
Copy link
Member Author

kvark commented Apr 27, 2017

Reviewed 1 of 5 files at r2.
Review status: 19 of 23 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


webrender/res/ps_split_composite.vs.glsl, line 26 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

Extracting this into a bilerp() function might make the intent clearer.

thanks, fixed!


webrender/src/frame.rs, line 440 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

I think this type might be Copy?

fixed


webrender/src/frame_builder.rs, line 85 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

Could you explain how the anchor parameter works?

added a comment


webrender/src/frame_builder.rs, line 254 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

What could cause this - I guess if we have mix-blend-mode on a preserve-3d?

yes. These interactions are not supported nicely yet


webrender/src/frame_builder.rs, line 1145 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

This doesn't seem right - the local bounds won't take the zoom / transform etc into effect. Shouldn't this be based on the screen bounding rect?

I believe you answered this yourself later on: I draw primitives without transforms, then transform the layer when compositing.


webrender/src/frame_builder.rs, line 1155 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

It might be clearer to combine this if and the one above into a match statement?

good idea! fixed


webrender/src/frame_builder.rs, line 1284 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

I'm not sure I fully understand this part - does this imply that any primitives in a preserve-3d context get rendered without any transform to the intermediate surface?

yes


wrench/reftests/split/simple.yaml, line 7 at r1 (raw file):

Previously, glennw (Glenn Watson) wrote…

CSS uses preserve-3d - let's use the CSS keyword in YAML files.

agreed, fixed


Comments from Reviewable

@kvark kvark force-pushed the kvark:isolation branch 3 times, most recently from 3f21d66 to d34ba26 Apr 27, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Apr 27, 2017

The latest upstream changes (presumably #1150) made this pull request unmergeable. Please resolve the merge conflicts.

@kvark kvark force-pushed the kvark:isolation branch from 66936fa to 9d46a4b Apr 27, 2017
@glennw
Copy link
Member

glennw commented Apr 28, 2017

Nice! The change to bake in screen space actually simplifies quite a bit of the code (conceptually at least), I think.

It's perhaps worth a couple of comments describing how the has_primitives_stack code works - I think I understand it but it would be good to clarify.

Apart from that, this looks good to me once we get the reftest issue resolved!

@kvark kvark force-pushed the kvark:isolation branch from 9d46a4b to 893cb27 Apr 28, 2017
@kvark kvark force-pushed the kvark:isolation branch from 893cb27 to aa9b65d Apr 28, 2017
@kvark kvark changed the title [WIP] Basic preserve-3d support Basic preserve-3d support Apr 28, 2017
@kvark kvark force-pushed the kvark:isolation branch from 846b855 to f8c3f5b Apr 29, 2017
bors-servo added a commit that referenced this pull request May 1, 2017
Combined clip rect workaround

There is a problem with `combined_local_viewport_rect` that makes it too tight for transformed layers. This PR attempts to work around this, not a proper fix. Having it would make the new reftest of #1169 to pass.

r? @mrobinson

<!-- 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/1177)
<!-- Reviewable:end -->
kvark added 6 commits Apr 12, 2017
  - match statement for `isolaton` in frame_builder
  - preserve-3d
  - make_polygon comments
  - blerp
Rich comments for in build_render_task().
Removed the hack of getting the reference frame for SplitComposite primitives.
…ve3d content, with a new ref test.
@kvark kvark force-pushed the kvark:isolation branch from f8c3f5b to 8d4bb22 May 1, 2017
@kvark kvark force-pushed the kvark:isolation branch from 49cc365 to 6930348 May 1, 2017
@@ -51,9 +52,10 @@ pub enum RenderTaskLocation {

#[derive(Debug, Clone)]
pub enum AlphaRenderItem {
Primitive(ClipScrollGroupIndex, PrimitiveIndex, i32),
Primitive(Option<ClipScrollGroupIndex>, PrimitiveIndex, i32),

This comment has been minimized.

Copy link
@glennw

glennw May 1, 2017

Member

This Option can be removed now.

@glennw
Copy link
Member

glennw commented May 1, 2017

@kvark One minor change above - the Option in the AlphaRenderItem is no longer required, now that we bake in screen space. Once that is done and CI is happy, r=me - let's get this merged!

@kvark
Copy link
Member Author

kvark commented May 1, 2017

@glennw
Copy link
Member

glennw commented May 1, 2017

That's fine - if it's intentional let's leave it :)

@glennw
Copy link
Member

glennw commented May 1, 2017

@bors-servo
Copy link
Contributor

bors-servo commented May 1, 2017

📌 Commit 6930348 has been approved by glennw

@bors-servo
Copy link
Contributor

bors-servo commented May 1, 2017

Testing commit 6930348 with merge d126eba...

bors-servo added a commit that referenced this pull request May 1, 2017
Basic preserve-3d support

Goes towards #739

This is a basic implementation that features a green test case. It can be merged independently, but more work is expected to solidify it.
There is a lot of interaction of "preserve3d" stacking contexts with filters, composite ops, and such, that is not thought-through or tested at the moment. The new code should be totally safe as long as the client continues to use `TransformStyle::Flat` (as both Gecko/Servo still do).

r? @glennw

<!-- 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/1169)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 1, 2017

☀️ Test successful - status-travis
Approved by: glennw
Pushing d126eba to master...

@bors-servo bors-servo merged commit 6930348 into servo:master May 1, 2017
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 21 files, 9 discussions left (glennw, kvark)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@kvark kvark mentioned this pull request May 5, 2017
@kvark kvark deleted the kvark:isolation branch May 5, 2017
bors-servo added a commit that referenced this pull request May 8, 2017
Better Preserve3D support

Follow up to #1169
Includes #1207

r? @glennw @mrobinson

  - "preserve-3d" only affects children stacking contexts and contained items
  - generated polygon coordinates of non-zero local bounds
  - sorting order

The Servo PR is being [worked on](servo/servo@master...kvark:preserve3d), but it's not required here, since it may safely continue using `TransformStyle::Flat`.

There is at least one feature on the horizon to be implemented before  #739 can be truly closed.
The `TransformStyle` should be moved out of the stacking context and deserve it's own pushable item (similar to clip-scroll groups). This is required because an item without "preserve-3d" automatically becomes "flat" but does not establish a stacking context, which is [tested by Servo](https://raw.githubusercontent.com/servo/servo/master/tests/wpt/css-tests/css-transforms-1_dev/html/transform3d-sorting-004.htm).

Edit: apparently, Chrome disagrees here, so the current approach of WR might stay.
Create Bugstar [issue-1362543](https://bugzilla.mozilla.org/show_bug.cgi?id=1362543).

<!-- 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/1208)
<!-- Reviewable:end -->
@kvark kvark mentioned this pull request May 8, 2017
3 of 5 tasks complete
bors-servo added a commit to servo/servo that referenced this pull request May 14, 2017
WR update: preserve-3d support

<!-- Please describe your changes on the following line: -->

This is WR update to servo/webrender@d335555 having new features:
  - limited "preserve-3d" support (servo/webrender#1169, servo/webrender#1208)
  - rayon thread pool (servo/webrender#1202)
  - further border rendering improvements

Edit: the references to bincode serialization and border styles are removed from here, since they are already integrated into Servo.
Edit2: this is alternative/similar to  #16801, based on @mrobinson code (see first commit).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Related to #9087
Note that I'm unlocking a few tests as well as changing some related to `preserve-3d`. The changes come from common sense and comparison to Chromium. I'm ready to discuss them on a individual basis.

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

There is still an investigation to do with regards to the differences of preserve3d logic between Blink and Gecko.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16775)
<!-- Reviewable:end -->
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.