Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

Pulled out of #168019 which is stale.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Jun 11, 2025
@jonahwilliams jonahwilliams requested a review from flar June 13, 2025 16:48
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.

LGTM, some nits that I think bear thinking about in the tests...

state.transform2DAffine(2, 0, 10, 0, 2, 10);
EXPECT_TRUE(state.IsTranslateScale());

state.transform2DAffine(1, 0.5, 0.5, 1, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I've done something similar myself in other tests, but looking at this from a reviewer's perspective, I think it would be better if each of these blocks starts with either setIdentity or EXPECT_TRUE(IsTranslateScale()) so that if anyone ever adds new code they can't disrupt the carry-over state from one mini-test to the other...? Something so that each block can be deleted, moved, or a new one added and the flow of the state won't break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test for FastIntersection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this code

std::optional<impeller::Rect> dl_intersected =
dl_mapped.Intersection(cull_rect_);
if (!dl_intersected.has_value()) {
*mapped = dl_intersected.value();
Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. value_or or Rect::IntersectionOrEmpty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

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.

LGTM, just some foods for thoughts


template <class T, class U>
bool NotEquals(std::shared_ptr<const T> a, const U* b) {
bool NotEquals(std::shared_ptr<const T>& a, const U* b) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll file an issue to do the others unless you want to just go through them.

Scalar t = GetTop() * sy + ty;
Scalar b = GetBottom() * sy + ty;

return TRect<float>::MakeLTRB(std::min(l, r), //
Copy link
Contributor

Choose a reason for hiding this comment

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

Impl idea - another way to do this would be something like:

Scalar l,r,t,b;
if (sx > 0) {
  l = left_ * sx + tx;
  r = right_ * sx + tx;
} else {
  l = right_ * sx + tx;
  r = left_ * sx + tx;
}
if (sy < 0) {
...
}

not sure if it is any faster.

Modifiers std::enable_if_t<std::is_floating_point_v<U>, Return>
#define ONLY_ON_FLOAT(Return) DL_ONLY_ON_FLOAT_M(, Return)

#define CHECK_INTERSECT(al, at, ar, ab, bl, bt, br, bb) \
Copy link
Contributor

Choose a reason for hiding this comment

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

multi-line macros are scary, but this is effective, so ... eek?

@jonahwilliams
Copy link
Contributor Author

hmm, looks like we have some different behavior with nan. let me double check that...

@flar
Copy link
Contributor

flar commented Jun 18, 2025

Also, should the tr/sc transform method FML_DCHECK on the matrix actually being tr/sc?

And, we could stand to add some new cases to display_list/benchmarking/dl_transform_benchmarks.cc for the new transform methods. Feel free to file an issue and I'll take care of that.

@chinmaygarde
Copy link
Member

@jonahwilliams Are you still planning on completing this :) Feel free to close if not.

@jonahwilliams
Copy link
Contributor Author

Someone else will need to carry the torch :)

github-merge-queue bot pushed a commit that referenced this pull request Sep 25, 2025
Taken partially from #170446 with
only the changes to add a ScaleTranslate rectangle transform method
brought over. Unlike the original PR, this PR will apply that optimized
method for any caller who transforms a rectangle rather than just the
matrix/clip tracker for the engine layer tree code.

A benchmark for the new methods is also provided to verify their
improved performance.
github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2025
Taken partially from #170446 with
only the changes to add a ScaleTranslate rectangle transform method
brought over. Unlike the original PR, this PR will apply that optimized
method for any caller who transforms a rectangle rather than just the
matrix/clip tracker for the engine layer tree code.

A benchmark for the new methods is also provided to verify their
improved performance.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
)

Taken partially from flutter#170446 with
only the changes to add a ScaleTranslate rectangle transform method
brought over. Unlike the original PR, this PR will apply that optimized
method for any caller who transforms a rectangle rather than just the
matrix/clip tracker for the engine layer tree code.

A benchmark for the new methods is also provided to verify their
improved performance.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
)

Taken partially from flutter#170446 with
only the changes to add a ScaleTranslate rectangle transform method
brought over. Unlike the original PR, this PR will apply that optimized
method for any caller who transforms a rectangle rather than just the
matrix/clip tracker for the engine layer tree code.

A benchmark for the new methods is also provided to verify their
improved performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants