-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] add support for superellipse. #54562
Conversation
|
||
Point center_; | ||
// 4 is a rectellipse | ||
int degree_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a scalar. Thats how you'd get stuff like astroids in https://en.wikipedia.org/wiki/Superellipse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. We can work with this. Have some nits and the todos already mentioned. But we can land and keep tinkering on this.
// quadrants. | ||
std::vector<Point> points; | ||
points.reserve(41); | ||
for (int i = 0; i < 41; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I prefer <= 40
in a case like this where 40 is an inclusive target as opposed to for loops < count
which are an exclusive target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Scalar n = degree_; | ||
|
||
// TODO(jonahwilliams): determine parameter values based on scaling factor. | ||
Scalar step = kPi / 80; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this part in the Tessellator would allow it to leverage the "GetTrigsForDivisions" caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this out for now so its stays separate before we decide how to ship it, but I agree it should eventually live in the tessellator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call if it isolates it until we figure out its future. It will matter a little for benchmarks, but not for testing its usefulness.
For folks trying to run the playground: Build engine. et build -c host_debug_unopt_arm64 Run test. ./out/host_debug_unopt_arm64/impeller_unittests --gtest_filter="*DrawSuperEllipse/Metal" --timeout=0 --enable_playground Superellipse.mov |
Scalar x = a * pow(abs(cos(t)), 2 / n); | ||
Scalar y = b * pow(abs(sin(t)), 2 / n); | ||
points.emplace_back(x, y); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: final points are always computed from points[i] * radius
, so just bake radius into the point here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
geometry.reserve(1 + 4 * points.size()); | ||
geometry.push_back(center_); | ||
for (auto i = 0u; i < points.size(); i++) { | ||
geometry.push_back(center_ + ((reflection[0] * points[i]) * radius_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does OOO matter for these equations? ((ref * pt) * rad) vs (ref * (pt * rad)) vs just (ref * pt * rad)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Relates to my comment above about just multiplying by radius in the points array...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, removed
If this is just for testing, can the new Entity/Geometry classes be just inlined in the test file for now? They're pretty small. |
I think its OK as it is ... and I really don't want to update the license script again 😢 |
…153533) flutter/engine@65fd6ca...68938ab 2024-08-15 jonahwilliams@google.com [Impeller] add support for superellipse. (flutter/engine#54562) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#153533) flutter/engine@65fd6ca...68938ab 2024-08-15 jonahwilliams@google.com [Impeller] add support for superellipse. (flutter/engine#54562) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#153533) flutter/engine@65fd6ca...68938ab 2024-08-15 jonahwilliams@google.com [Impeller] add support for superellipse. (flutter/engine#54562) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This is an entity testing only implementation of a superellipse. rectellipse is a special case where degree = 4.
Part of flutter/flutter#139321