Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] add support for superellipse. #54562

Merged
merged 11 commits into from
Aug 15, 2024

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Aug 14, 2024

This is an entity testing only implementation of a superellipse. rectellipse is a special case where degree = 4.

Part of flutter/flutter#139321

@jonahwilliams jonahwilliams changed the title [Impeller] add support for rectellipse. [Impeller] add support for superellipse. Aug 15, 2024

Point center_;
// 4 is a rectellipse
int degree_;
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@chinmaygarde chinmaygarde left a 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.

@jonahwilliams jonahwilliams requested a review from flar August 15, 2024 18:17
// quadrants.
std::vector<Point> points;
points.reserve(41);
for (int i = 0; i < 41; i++) {
Copy link
Contributor

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.

Copy link
Member Author

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;
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

@chinmaygarde
Copy link
Member

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);
}
Copy link
Contributor

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.

Copy link
Member Author

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_));
Copy link
Contributor

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)?

Copy link
Contributor

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...)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, removed

@jonahwilliams jonahwilliams removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 15, 2024
@flar
Copy link
Contributor

flar commented Aug 15, 2024

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.

@jonahwilliams
Copy link
Member Author

I think its OK as it is ... and I really don't want to update the license script again 😢

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 15, 2024
@auto-submit auto-submit bot merged commit 68938ab into flutter:main Aug 15, 2024
31 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 16, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 16, 2024
…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
DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
…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
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants