New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unnecessary saveLayer #5420
Conversation
saveLayer is slow so we should avoid it as much as possible. If there are artifacts without saveLayer, then we should report that to Skia for the fix instead of slowing the performance with saveLayer. This PQ makes average rasterizer time drop from 25ms to 18ms in flutter_gallery transitions perf test on a Nexus 5X.
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: Typo in commit message.
Awesome! Looking forward to the benchmark of the next roll. |
@@ -48,7 +48,7 @@ void ClipPathLayer::Paint(PaintContext& context) const { | |||
TRACE_EVENT0("flutter", "ClipPathLayer::Paint"); | |||
FXL_DCHECK(needs_painting()); | |||
|
|||
Layer::AutoSaveLayer save(context, paint_bounds(), nullptr); | |||
SkAutoCanvasRestore save(&context.canvas, true); |
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 won't work. It will cause artifacts.
See this article for a discussion of why: https://master-docs-flutter-io.firebaseapp.com/flutter/dart-ui/Canvas/saveLayer.html
There will definitely be artifacts. For example, if a clip region contains a red rectangle with a white rectangle on top of it, then at the edge of the clip region, this will result in red-tinted pixels, but they should be white. |
Interestingly, I just tried this on the beta channel and I get the red outlines already, so while I don't think this PR is correct, it seems something else had already broken this before. |
Filed flutter/flutter#18057 to track this. I marked in "regression" because I'm sure this used to work. |
saveLayer is slow so we should avoid it as much as possible. If there are artifacts without saveLayer, then we should report that to Skia for the fix instead of slowing the performance with saveLayer. This PQ makes average rasterizer time drop from 25ms to 18ms in flutter_gallery transitions perf test on a Nexus 5X. This partially fixes flutter/flutter#13736 . We probably still need some work in the opacity layer to squize all the performance improvements.
This is a follow up on flutter/engine#5420 and flutter#18057 As you can see from the diff, we also mistakenly saveLayer before the clip at some places previously.
This is a follow up on flutter/engine#5420 and #18057 As you can see from the diff, we also mistakenly saveLayer before the clip at some places previously.
saveLayer is slow so we should avoid it as much as possible. If there are artifacts without saveLayer, then we should report that to Skia for the fix instead of slowing the performance with saveLayer. This PQ makes average rasterizer time drop from 25ms to 18ms in flutter_gallery transitions perf test on a Nexus 5X. This partially fixes flutter/flutter#13736 . We probably still need some work in the opacity layer to squize all the performance improvements.
saveLayer is slow so we should avoid it as much as possible. If
there are artifacts without saveLayer, then we should report that
to Skia for the fix instead of slowing the performance with
saveLayer.
This PQ makes average rasterizer time drop from 25ms to 18ms in
flutter_gallery transitions perf test on a Nexus 5X.
This partially fixes flutter/flutter#13736 .
We probably still need some work in the opacity layer to squize
all the performance improvements.