Skip to content

Commit 949ece5

Browse files
authored
Remove unnecessary saveLayer (flutter-team-archive/engine#5420)
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.
1 parent a6df376 commit 949ece5

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎engine/src/flutter/flow/layers/clip_path_layer.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ClipPathLayer::Paint(PaintContext& context) const {
4848
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");
4949
FXL_DCHECK(needs_painting());
5050

51-
Layer::AutoSaveLayer save(context, paint_bounds(), nullptr);
51+
SkAutoCanvasRestore save(&context.canvas, true);
5252
context.canvas.clipPath(clip_path_, true);
5353
PaintChildren(context);
5454
}

‎engine/src/flutter/flow/layers/clip_rrect_layer.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void ClipRRectLayer::Paint(PaintContext& context) const {
4646
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
4747
FXL_DCHECK(needs_painting());
4848

49-
Layer::AutoSaveLayer save(context, paint_bounds(), nullptr);
49+
SkAutoCanvasRestore save(&context.canvas, true);
5050
context.canvas.clipRRect(clip_rrect_, true);
5151
PaintChildren(context);
5252
}

‎engine/src/flutter/flow/layers/physical_shape_layer.cc‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
9191
context.canvas.drawPath(path_, paint);
9292

9393
SkAutoCanvasRestore save(&context.canvas, false);
94-
if (isRect_) {
95-
context.canvas.save();
96-
} else {
97-
context.canvas.saveLayer(path_.getBounds(), nullptr);
98-
}
94+
context.canvas.save();
9995
context.canvas.clipPath(path_, true);
10096
PaintChildren(context);
10197
if (context.checkerboard_offscreen_layers && !isRect_)

0 commit comments

Comments
 (0)