Struggling to "clear" a CGLayer -- can it even be done?
- by Joe Blow
So I'm doing this repetitively - making a CGLayer, doing some processing, and then releasing it. This happens a lot in real time -- so surely there is a lot of overhead in making a whole new CGLayer each time?
Surely it would be better to just keep lair around, and start fresh each time?
However, I do not know any way, at all, to "erase" or "start from blank" a CGLayer?? Can anyone help on this?
There is a function CGContextBeginPath(cc) but it's confusing: it seems to only clear out "that" path, it does not erase all of the CGLayer back to a blank canvas.
how to return a CGLayer to a blank canvas????? Does anyone know?
CGLayerRef lair = CGLayerCreateWithContext(
UIGraphicsGetCurrentContext(),
CGSizeMake(1024,768), NULL);
CGContextRef cc = CGLayerGetContext(ether);
// various processing here
CGContextAddPath(cc, somePath);
// various processing here
CGLayerRelease(lair);
Any ideas?!