Get 3D transforms working

RESOLVED FIXED

Status

()

Core
Graphics: WebRender
RESOLVED FIXED
2 years ago
a year ago

People

(Reporter: rhunt, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
Currently we do not pass 3D transforms to webrender.
(Reporter)

Comment 1

2 years ago
Created attachment 8827589 [details] [diff] [review]
transform-preserve.patch

Here is my work in progress. It tries to cover passing 3D transforms to webrender, and also the trickiness of Extend3DContext.
Blocks: 1322815
Comment on attachment 8827589 [details] [diff] [review]
transform-preserve.patch

Review of attachment 8827589 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/wr/WebRenderBorderLayer.cpp
@@ +34,2 @@
>    Rect overflow(0, 0, relBounds.width, relBounds.height);
> +  Matrix4x4 transform = GetEffectiveTransform();

I believe we want to be using GetTransform() here instead of GetEffectiveTransform() as we want to use the the transform relative to our parent.
(Reporter)

Comment 3

2 years ago
(In reply to Jeff Muizelaar [:jrmuizel] from comment #2)
> Comment on attachment 8827589 [details] [diff] [review]
> transform-preserve.patch
> 
> Review of attachment 8827589 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: gfx/layers/wr/WebRenderBorderLayer.cpp
> @@ +34,2 @@
> >    Rect overflow(0, 0, relBounds.width, relBounds.height);
> > +  Matrix4x4 transform = GetEffectiveTransform();
> 
> I believe we want to be using GetTransform() here instead of
> GetEffectiveTransform() as we want to use the the transform relative to our
> parent.

Yes in most cases we do. But when we are a 3D context leaf we need to combine our local transform with all of our parent layers that extend the 3D context. The 3D context leaf is drawn before it's parents because of SortChildrenBy3DZOrder, so it won't reside in it's parent's webrender stacking context.

I put the code to handle both those cases inside ComputeEffectiveTransforms. So usually EffectiveTransform is the same as GetTransform.

There could be a better way to do that, or it could be renamed.
I'm not sure we want to be using SortChildrenBy3DZOrder with Webrender. My understanding is that this sorting should be happening on the webrender side instead of on the gecko side. Does that make any sense?
Flags: needinfo?(rhunt)
(Reporter)

Comment 5

2 years ago
Yes you're right this would be better done on the webrender side. SortChildrenBy3DZOrder was in use already, and I didn't think about where it should be implemented. 

I don't see any code related to extending a 3D context in webrender, so I'm guessing it will need to be added. I can look into that.
Flags: needinfo?(rhunt)
I've filed this as https://github.com/servo/webrender/issues/739 It's currently blocked on some coordinate space reworks.

Given that we're going to push preserve-3d handling into webrender does it make sense to just use GetTransform() now?
Flags: needinfo?(rhunt)
(Reporter)

Comment 7

2 years ago
Yes that makes sense to me.
Flags: needinfo?(rhunt)
(Reporter)

Comment 8

a year ago
We pass GetTransform() into WebRender now, so it has access to 3D transforms.

Closing this, as the work will be done on the WebRender side.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.