Closed
Bug 1437492
Opened 7 years ago
Closed 7 years ago
Add matrix class optimized for simple matrices
Categories
(Core :: Graphics, enhancement, P3)
Core
Graphics
Tracking
()
RESOLVED
FIXED
mozilla60
Tracking | Status | |
---|---|---|
firefox60 | --- | fixed |
People
(Reporter: bas.schouten, Assigned: bas.schouten)
Details
Attachments
(2 files)
Transformations are showing up a significant amount in profiles, both in display list building and frame layer builder. The vast amount of the time we are dealing with simple transforms, identity or 2D. We can optimize away a lot under those circumstances.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 3•7 years ago
|
||
mozreview-review |
Comment on attachment 8950200 [details]
Bug 1437492 - Part 1: Add a Matrix class with optimizations for simple matrices.
https://reviewboard.mozilla.org/r/219466/#review225826
::: gfx/2d/Matrix.h:2028
(Diff revision 1)
> + }
> +
> + template <typename NewTargetUnits>
> + Matrix4x4TypedFlagged<SourceUnits, NewTargetUnits> operator*(const Matrix4x4Typed<TargetUnits, NewTargetUnits> &aMatrix) const
> + {
> + if (mType == MatrixType::Identity) {
Don't we want to check the reverse case here too?
Attachment #8950200 -
Flags: review?(matt.woodrow) → review+
Comment 4•7 years ago
|
||
mozreview-review |
Comment on attachment 8950201 [details]
Bug 1437492 - Part 2: Based on profile data, use the simple-matrix optimized matrix class in some places.
https://reviewboard.mozilla.org/r/219468/#review225830
::: layout/base/nsLayoutUtils.cpp:2753
(Diff revision 1)
> }
> return ctm;
> }
>
> +Matrix4x4Flagged
> +nsLayoutUtils::GetTransformToAncestorFlagged(nsIFrame *aFrame,
This function is pretty complex, and duplicating the logic is a bit sad.
It looks like the only different with the Flagged version is the implicit type conversion in the return statement, so could we just make it wrapper function?
Alternatively, make the Flagged version the real one, and have the normal one be a wrapper around it that calls GetMatrix() on the result.
nsIFrame::GetTransformMatrix primarily initializes its matrices using Matrix4x4::Translation, so we could generate flagged matrices without needing an analyze call, and then callers that don't care can drop back to the unflagged version.
::: layout/base/nsLayoutUtils.cpp:2772
(Diff revision 1)
> + !parent->IsStackingContext() &&
> + !FrameHasDisplayPort(parent)))) {
> + if (!parent->Extend3DContext()) {
> + ctm.ProjectTo2D();
> + }
> + ctm = ctm * parent->GetTransformMatrix(aAncestor, &parent, aFlags);
Retained-dl calls this function a lot, and the matrices are almost always just translations.
Optimizing the * operator for translations might be a win.
Attachment #8950201 -
Flags: review?(matt.woodrow) → review+
Assignee | ||
Comment 5•7 years ago
|
||
(In reply to Matt Woodrow (:mattwoodrow) from comment #3)
> Comment on attachment 8950200 [details]
> Bug 1437492 - Part 1: Add a Matrix class with optimizations for simple
> matrices.
>
> https://reviewboard.mozilla.org/r/219466/#review225826
>
> ::: gfx/2d/Matrix.h:2028
> (Diff revision 1)
> > + }
> > +
> > + template <typename NewTargetUnits>
> > + Matrix4x4TypedFlagged<SourceUnits, NewTargetUnits> operator*(const Matrix4x4Typed<TargetUnits, NewTargetUnits> &aMatrix) const
> > + {
> > + if (mType == MatrixType::Identity) {
>
> Don't we want to check the reverse case here too?
aMatrix is not a flagged matrix here :). We could make an optimized case for that but we're not currently using it anywhere so let's add it once we are chaining that way.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 8•7 years ago
|
||
Comment on attachment 8950200 [details]
Bug 1437492 - Part 1: Add a Matrix class with optimizations for simple matrices.
Patch changed extensively, please re-review.
Attachment #8950200 -
Flags: review+ → review?(matt.woodrow)
Assignee | ||
Comment 9•7 years ago
|
||
Comment on attachment 8950201 [details]
Bug 1437492 - Part 2: Based on profile data, use the simple-matrix optimized matrix class in some places.
Significant changes as I implemented your suggestions, please re-review.
Attachment #8950201 -
Flags: review+ → review?(matt.woodrow)
Comment 10•7 years ago
|
||
mozreview-review |
Comment on attachment 8950200 [details]
Bug 1437492 - Part 1: Add a Matrix class with optimizations for simple matrices.
https://reviewboard.mozilla.org/r/219466/#review226302
::: gfx/2d/Matrix.h:2021
(Diff revision 2)
> +
> + if (mType == MatrixType::Simple) {
> + TargetPoint point = TransformPointSimple(aPoint);
> + return Point4DTyped<TargetUnits, F>(point.x, point.y, 0, 1);
> + }
> +
Trailing whitespace, here and a few other places.
Attachment #8950200 -
Flags: review?(matt.woodrow) → review+
Comment 11•7 years ago
|
||
mozreview-review |
Comment on attachment 8950201 [details]
Bug 1437492 - Part 2: Based on profile data, use the simple-matrix optimized matrix class in some places.
https://reviewboard.mozilla.org/r/219468/#review226304
Attachment #8950201 -
Flags: review?(matt.woodrow) → review+
Updated•7 years ago
|
Priority: -- → P3
Comment 12•7 years ago
|
||
Pushed by bschouten@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b618a66fc348
Part 1: Add a Matrix class with optimizations for simple matrices. r=mattwoodrow
https://hg.mozilla.org/integration/mozilla-inbound/rev/19d0b0f36cce
Part 2: Based on profile data, use the simple-matrix optimized matrix class in some places. r=mattwoodrow
Comment 13•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b618a66fc348
https://hg.mozilla.org/mozilla-central/rev/19d0b0f36cce
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in
before you can comment on or make changes to this bug.
Description
•