Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whooleytoo

macrumors 604
Original poster
Aug 2, 2002
6,607
716
Cork, Ireland.
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:

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);
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.