Closed
Bug 1391499
Opened 8 years ago
Closed 8 years ago
Apply correct scale transform with nested transform divs
Categories
(Core :: Graphics: WebRender, defect)
Core
Graphics: WebRender
Tracking
()
RESOLVED
FIXED
mozilla57
| Tracking | Status | |
|---|---|---|
| firefox57 | --- | fixed |
People
(Reporter: pchang, Assigned: pchang)
References
Details
Attachments
(1 file)
With nested transform divs, layers-free mode got the wrong result from the following test case.
layout/reftests/transform/compound-1-ref.html
[Test case]
<div style="left:0px; top:200px;">
<div style="-moz-transform: translate(100px);">
<div style="-moz-transform:">
<div style="-moz-transform: scale(2) rotate(90deg);">
<div class="testr">
</div>
</div>
</div>
</div>
</div>
| Assignee | ||
Comment 1•8 years ago
|
||
We need to apply inherited scale from parent to get correct transform in layers-free mode.
| Comment hidden (mozreview-request) |
Comment 3•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8898787 [details]
Bug 1391499 - Apply the inherited scale from ancestors,
https://reviewboard.mozilla.org/r/170180/#review175460
Overall looks reasonable but there's enough nits/fixes that I'd like to see an updated version. Thanks!
::: gfx/layers/wr/StackingContextHelper.h:91
(Diff revision 1)
> private:
> wr::DisplayListBuilder* mBuilder;
> LayerPoint mOrigin;
> gfx::Matrix4x4 mTransform;
> +
> + float mXScale, mYScale;
One declaration per line please
::: gfx/layers/wr/StackingContextHelper.cpp:16
(Diff revision 1)
> - : mBuilder(nullptr)
> + : mBuilder(nullptr),
> + mXScale(1.0),
> + mYScale(1.0)
Please line up the commas with the colon
: mBuilder(nullptr)
, mXScale(1.0)
, mYScale(1.0)
::: gfx/layers/wr/StackingContextHelper.cpp:28
(Diff revision 1)
> : mBuilder(&aBuilder)
> {
You should initialize mXScale and mYScale in all four constructors (and definitely in the one you're modifying, because right now there are codepaths where it can be left as uninitialized and then can be later read).
::: gfx/layers/wr/StackingContextHelper.cpp:91
(Diff revision 1)
> + aTransformPtr->PostScale(aParentSC.mXScale, aParentSC.mYScale, 1.0);
> + aTransformPtr->NudgeToIntegersFixedEpsilon();
I don't really like that you're modifying the passed-in argument as a side-effect here. Since this function later makes a copy of *aTransformPtr into mTransform anyway, can we move that earlier, and then make these changes on mTransform? That way it won't unexpectedly modify the caller's Matrix.
::: gfx/layers/wr/StackingContextHelper.cpp:94
(Diff revision 1)
> +
> + // Apply the inherited scale from parent
> + aTransformPtr->PostScale(aParentSC.mXScale, aParentSC.mYScale, 1.0);
> + aTransformPtr->NudgeToIntegersFixedEpsilon();
> +
> + gfxSize scale = ThebesMatrix(aTransformPtr->As2D()).ScaleFactors(true);
ThebesMatrix is now just a typedef for MatrixDouble, so please use that directly. Likewise s/gfxSize/SizeDouble/
::: gfx/layers/wr/StackingContextHelper.cpp:95
(Diff revision 1)
> + if (fabs(scale.width) < 1e-8 || fabs(scale.height) < 1e-8) {
> + scale = gfxSize(1.0, 1.0);
It's not clear to me why this is needed. Is a scale of 0 not valid here? If so please add a comment why. Also instead of hard-coding 1e-8 here I'd prefer if you used one of the existing FuzzyEquals methods in the codebase, for example the FuzzyEqualsAdditive in MFBT.
Attachment #8898787 -
Flags: review?(bugmail) → review-
Comment 4•8 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #3)
> ThebesMatrix is now just a typedef for MatrixDouble, so please use that
> directly.
Oh, sorry, I didn't realize ThebesMatrix was the function to convert from Matrix to MatrixDouble. Using that is ok.
| Assignee | ||
Comment 5•8 years ago
|
||
Now I couldn't reproduce the try failures with latest nightly, I will check which bug fixed this problem later.
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 8•8 years ago
|
||
| mozreview-review | ||
Comment on attachment 8898787 [details]
Bug 1391499 - Apply the inherited scale from ancestors,
https://reviewboard.mozilla.org/r/170180/#review177952
Much better, thanks. I'm kind of wondering if this is a bug in webrender though, it seems like if stacking contexts are nested the semantics should be that the scale gets inherited down automatically. It seems odd that we need to do this manually on our side.
Attachment #8898787 -
Flags: review?(bugmail) → review+
Comment 9•8 years ago
|
||
We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again.
hg error in cmd: hg rebase -s 342ee7d2072c -d f06ff175be4f: rebasing 416228:342ee7d2072c "Bug 1391499 - Apply the inherited scale from ancestors, r=kats" (tip)
merging gfx/layers/wr/StackingContextHelper.cpp
merging gfx/layers/wr/StackingContextHelper.h
warning: conflicts while merging gfx/layers/wr/StackingContextHelper.cpp! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
| Comment hidden (mozreview-request) |
Comment 11•8 years ago
|
||
Pushed by pchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/22d7763100aa
Apply the inherited scale from ancestors, r=kats
Comment 12•8 years ago
|
||
Backed out for build bustage on Windows at gfx/layers/wr/StackingContextHelper.cpp(105): 'Size': undeclared identifier:
https://hg.mozilla.org/integration/autoland/rev/c137b3d03017b8449ae19bfc58752aa688888ab8
Push with bustage: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=22d7763100aad8ac76f9c36b84e67f6349371fac&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=retry&filter-resultStatus=usercancel&filter-resultStatus=runnable
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=126387680&repo=autoland
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2065: 'Size': undeclared identifier
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2146: syntax error: missing ';' before identifier 'scale'
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(105): error C2065: 'scale': undeclared identifier
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): error C2065: 'scale': undeclared identifier
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): error C2228: left of '.width' must have class/struct/union
10:20:20 INFO - z:/build/build/src/gfx/layers/wr/StackingContextHelper.cpp(108): note: type is 'unknown-type'
etc.
Flags: needinfo?(howareyou322)
| Comment hidden (mozreview-request) |
Comment 14•8 years ago
|
||
Pushed by pchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a36884ff708d
Apply the inherited scale from ancestors, r=kats
| Assignee | ||
Comment 15•8 years ago
|
||
I just fixed the build failure on windows in comment 13.
| Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(howareyou322)
Comment 16•8 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Comment 17•8 years ago
|
||
So I backed out 4 patches locally: the ones from bug 1399050, bug 1394308, and bug 1391499, and ran the reftest layout/reftests/transform/compound-1a.html in layers-free WR. What I see is that the reference image is shifted over to the right by around 200px but other than looks fine. Is this the same as what you were seeing when you wrote comment 0?
I'm wondering if there's a better way to go about fixing this, because extracting the scale here and then manually applying it to everything is turning out to be quite complicated (e.g. in bug 1399043).
Flags: needinfo?(howareyou322)
Updated•8 years ago
|
Comment 18•8 years ago
|
||
(Clearing needinfo here, let's keep the discussion in bug 1400034)
Flags: needinfo?(howareyou322)
See Also: → 1400034
You need to log in
before you can comment on or make changes to this bug.
Description
•