Skip to content

Commit

Permalink
Remove unnecessary saveLayer (flutter#5420)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
liyuqian authored and najeira committed Jul 17, 2018
1 parent 5a7ca95 commit 200bd06
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion flow/layers/clip_path_layer.cc
Expand Up @@ -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);
context.canvas.clipPath(clip_path_, true);
PaintChildren(context);
}
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_rrect_layer.cc
Expand Up @@ -46,7 +46,7 @@ void ClipRRectLayer::Paint(PaintContext& context) const {
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");
FXL_DCHECK(needs_painting());

Layer::AutoSaveLayer save(context, paint_bounds(), nullptr);
SkAutoCanvasRestore save(&context.canvas, true);
context.canvas.clipRRect(clip_rrect_, true);
PaintChildren(context);
}
Expand Down
6 changes: 1 addition & 5 deletions flow/layers/physical_shape_layer.cc
Expand Up @@ -91,11 +91,7 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
context.canvas.drawPath(path_, paint);

SkAutoCanvasRestore save(&context.canvas, false);
if (isRect_) {
context.canvas.save();
} else {
context.canvas.saveLayer(path_.getBounds(), nullptr);
}
context.canvas.save();
context.canvas.clipPath(path_, true);
PaintChildren(context);
if (context.checkerboard_offscreen_layers && !isRect_)
Expand Down

0 comments on commit 200bd06

Please sign in to comment.