Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Apr 29, 2025
@github-actions github-actions bot added the a: text input Entering text in a text field or keyboard related problems label May 22, 2025
jonahwilliams added 2 commits May 22, 2025 11:59
Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math still not right

const Matrix& transform) const {
return TRect::MakeOriginSize(
GetOrigin() + TPoint<float>(transform.m[12], transform.m[13]), //
GetSize().Scale(transform.m[0], transform.m[5]) //
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. You have to scale all 4 points.

Also, if there is a negative scale it can mess things up - your rect will be upside down.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the unit tests with lots of cases of rects at origin or not at origin, various sizes, and various scales and translates and make sure the answer is the same as the full transform.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

matrix_ = matrix_ * DlMatrix::MakeSkew(skx, sky);
}
void rotate(DlRadians angle) {
is_translate_scale_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

90 degree rotations might be common and they can be optimized as well, but it isn't as simple as the new method. Also, unfortunately, rotate(radians) is hard to detect a quadrant rotation because the quadrant angles are all transcendental by being related to pi.

return false;
impeller::Rect dl_intersected = dl_mapped.FastIntersection(cull_rect_);
*mapped = dl_intersected;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return not IsEmpty

*mapped = dl_intersected;
return true;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You leave the mapped value undefined here. Set it to empty.

@flar
Copy link
Contributor

flar commented May 22, 2025

The SkMatrix class has a classifier field that tells them if it is just a scale/translate so they can do more optimal work. I originally developed a similar DlTransform class (see below) that also classified its state for the same purpose, but ditched that in favor of just working on the Impeller classes. Unfortunately, when I looked at the performance of the impeller::Matrix class it seemed as if it could do the work of the "case-optimized" transform classes faster by not checking and just letting the compiler do its magic, but it's been a while since I've worked on that.

See https://github.com/flar/engine/blob/dl-geometry-classes/display_list/geometry/dl_transform.h and https://github.com/flar/engine/blob/dl-geometry-classes/display_list/geometry/dl_transform.cc

@jonahwilliams jonahwilliams changed the title [WIP] Faster paint passing Faster display list recording / paint passing. May 22, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 17, 2025
Split off of #168019

Worst case allocation performance for dl is fairly bad as we end up
copying the data many more times than something like an STL vector
would. At the cost of more memory usage, we can improve the case where
the display list grows quite large.
chunhtai pushed a commit to chunhtai/flutter that referenced this pull request Jun 17, 2025
Split off of flutter#168019

Worst case allocation performance for dl is fairly bad as we end up
copying the data many more times than something like an STL vector
would. At the cost of more memory usage, we can improve the case where
the display list grows quite large.
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
Split off of flutter#168019

Worst case allocation performance for dl is fairly bad as we end up
copying the data many more times than something like an STL vector
would. At the cost of more memory usage, we can improve the case where
the display list grows quite large.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants