Remove unnecessary saveLayer (flutter/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.
This commit is contained in:
liyuqian
2018-05-30 12:50:12 -07:00
committed by GitHub
parent a6df376736
commit 949ece5d45
3 changed files with 3 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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_)