Performance or saving previous context


I was playing with this example and noticed that I can pretty easily degrade performance by drawing a bunch of lines. I imagine this is because on ever draw it has to make all the finished lines each time.

That led me down the path of trying to figure out how to save a rasterized (composited / flattened) version of the finished lines before drawing the active lines.

I’ve tried using CGContextRef to restore the state before drawing, draw the finished lines and empty the array, save the state and then draw the active lines, but it doesn’t look like Quartz drawing and UIBezierPath are in the same world.

I’d love to hear a way to do this, or an explanation of how Quartz and Bezier paths work together. Maybe also a quick explanation of how you’d do a drawing app in the real world.