I'm using a CGLayer as an offscreen buffer; drawing opaque sprites onto a translucent background, then copying the entire layer to the onscreen context via CGContextDrawLayerAtPoint.
The problem is, every drawRect: calls CGContextDrawLayerAtPoint, that function takes longer and longer. The only reason I can think of is that since the background is translucent there is some kind of compositing going on which takes longer the more times the translucent background is drawn to the screen.
Anyone know how I avoid this?
My code is currently:
The problem is, every drawRect: calls CGContextDrawLayerAtPoint, that function takes longer and longer. The only reason I can think of is that since the background is translucent there is some kind of compositing going on which takes longer the more times the translucent background is drawn to the screen.
Anyone know how I avoid this?
My code is currently:
Code:
- (void)drawRect:(CGRect)rect
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextRef backContext = CGLayerGetContext(offscreenLayer);
CGContextClearRect(backContext, rect);
CGContextSetRGBFillColor(backContext, 0.0, 0.0, 0.0, 0.3);
CGContextFillRect(backContext, rect);
// Draw sprites in backContext here......
CGContextDrawLayerAtPoint(currentContext, CGPointZero, offscreenLayer);
}