-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] implement Canvas::DrawLine to tesselate lines directly #47846
[Impeller] implement Canvas::DrawLine to tesselate lines directly #47846
Conversation
Here are some benchmarks I ran on an iPhone 6s using the example below. All times are the raster time average ms/frame on a profile build with LTO measured with the Performance Overlay with 10,000 lines per frame. Running on Impeller now: 101 Test benchmark
|
As much of an improvement this is, Skia is still just so much better. I suspec what they're doing is some amount of batching either during cmd recording or playback? |
4094fe6
to
07cdfbd
Compare
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
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.
LGTM with nits
return coverage.has_value() ? coverage->Contains(rect) : false; | ||
} | ||
|
||
bool LineGeometry::IsAxisAlignedRect() const { |
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 think if you're drawing a line, its only an axis aligned rect if it is a square cap?
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.
square or butt, I'll include this in the issue for handling round caps...
} | ||
|
||
void Canvas::DrawLine(const Point& p0, const Point& p1, const Paint& paint) { | ||
if (paint.stroke_cap == Cap::kRound) { |
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: file an issue for round caps
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: flutter/flutter#138254
…138266) flutter/engine@9d8a112...00db306 2023-11-10 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Bump minSdk to 19 for Android tests" (flutter/engine#47935) 2023-11-10 [email protected] Roll Dart SDK from 91c4a92a64ea to 370145bbbd4f (1 revision) (flutter/engine#47930) 2023-11-10 [email protected] Roll Skia from 2c43bf002b7f to 96ce4d6f433d (3 revisions) (flutter/engine#47931) 2023-11-10 [email protected] [Impeller] implement Canvas::DrawLine to tesselate lines directly (flutter/engine#47846) 2023-11-10 [email protected] Roll Skia from d06840545bff to 2c43bf002b7f (1 revision) (flutter/engine#47928) 2023-11-10 [email protected] Bump minSdk to 19 for Android tests (flutter/engine#47686) 2023-11-10 [email protected] [Impeller] Reduce allocations for polyline generation (flutter/engine#47837) 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 [email protected],[email protected],[email protected] 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
Impeller implements the DrawLine primitive as DrawPath on a path containing a single line. Benchmarks show that this can cost 30% overhead on apps that use a lot of DrawLine primitives. This PR creates a more direct Entity that can tesselate the geometry of a line directly.
The reduced overhead should help with flutter/flutter#138004
The current code will back off to Path rendering for round caps. When the circle geometry work is finished (#47845) we can come back and implement round caps using the code refactored in that PR.