Struggling to "clear" a CGLayer -- can it even be done?

Posted by Joe Blow on Stack Overflow See other posts from Stack Overflow or by Joe Blow
Published on 2011-01-04T13:51:12Z Indexed on 2011/01/04 13:54 UTC
Read the original article Hit count: 161

Filed under:
|
|

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?!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa