This reverts commit 74662ab695238af0e7402f41c4bf9ad862bd37d2.
This should land after https://github.com/flutter/engine/pull/6442
* Add pragma vm:entry-point
Otherwise, an object may be both null and an instance of EnginieLayer at
the same time in Dart.
* Revert "Revert "Allow raster caching any layer subtree (#6442)" (#6506)"
This reverts commit c6e6da512a54c1bb33a584b117bcf300ce71b166.
* Use raw pointer for RasterCacheKey
So we won't depend on whether it's a std::unique_ptr or std::shared_ptr.
We first test this with OpacityLayer. This test alone (without retained rendering) should have ~30% speedup as we'll have fewer render target switches by snapshoting in the Preroll instead of saveLayer in the Paint.
In my local flutter_gallery transition perf tests, the average frame time drops from ~16ms to ~12ms.
https://github.com/flutter/flutter/issues/21756
To make the PR minimal, we currently only share the engine layer when `pushPhysicalShape` (for Fuchsia) or `pushOffset` (for `RepaintBoundary` and `Opacity`) are called. They should be sufficient for our short-term perf goal. In the future, we can incrementally share more engine layers with the framework.
https://github.com/flutter/flutter/issues/21756
This essentially reverts https://github.com/flutter/engine/pull/4197/
as no one is (or soon will be) implementing an alternative LayerBuilder.
Let's just put everything in SceneBuilder to reduce the YAGNI
(you aren't gonna need it) smell. This will also make retained rendering
API changes much easier.
Cache a SkSurface with previously drawn shapes so that we do not need to draw them again in future frames.
On Nexus 5X test device, old render time for just the overlay was 1.3ms-3.0ms and this version improves to 0.9ms-1.3ms running flutter gallery in profile mode.
It turns out that Skia is much slower at drawing paint inside a clipped
path than directly drawing that path. (Average frame time of 22ms vs
18ms in flutter_galary transition test.)
If we want to avoid the bleeding edge artifact (flutter/flutter#18057 (comment)) using saveLayer, we have to call drawPaint instead of drawPath as anti-aliased drawPath will always have such artifacts.
This is discovered when I try to add golden tests for such bleeding artifacts using our new Clip enum. Here's the updated golden files: flutter/goldens@cb1fa8a?short_path=57b30ce#diff-57b30cea9b10b7ca689009854e12d70e
1. Mark perf overlay path as volatile
2. Set sample_margin_width = 0 to get a bar graph instead of saw-tooth.
Previously, the perf overlay itself could be a significant performance
hit and that makes it difficult to profile flutter app.
Although we do have a save before this SkAutoCanvasRestore so we
can theoretically send in doSave = false, it's safer to set doSave
to true to prevent future breakage.
As discussed with mtklein@google.com and reed@google.com, saving
canvas is very cheap in Skia so this should have no performance
impact. Skia is also considering remove doSave argument from
SkAutoCanvasRestore and always save the canvas.
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 fixesflutter/flutter#13736 .
We probably still need some work in the opacity layer to squize
all the performance improvements.