I am developing a CAD program in flutter. In the application we make extensive use of canvas.SaveLayer() and canvas.Restore() but it becomes intolerably slow (~300ms+ render times) after about 100 items are on in the screen. Anyone with better knowledge of the canvas stack know how to make this faster?
Offending code is here. This code draws an arc visually connecting two light fixtures and erases the part under the light fixtures. See images.
var eraser = Paint()..blendMode = BlendMode.clear;
var clipA = getClipGeometry(sideA);
var clipB = getClipGeometry(sideB);
canvas.saveLayer(Rect.largest, Paint());
canvas.drawArc(r, arc.thetaA, arc.sweep, false, paint);
canvas.drawPath(clipA, eraser);
canvas.drawPath(clipB, eraser);
canvas.restore();
If I just draw the arcs without erasing the ends, everything is blazing fast.
canvas.drawArc(r, arc.thetaA, arc.sweep, false, paint);
