So, I'm working on a screensaver, which is intended to draw, of all things, snowflakes. I've loaded the flake image into a CGLayer, and then the drawing code looks something like this:
Code:
for (i=0; i<flakeCount; i++) {
CGContextClearRect((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort],
CGRectMake(snowflake[i].location.x-.5,snowflake[i].location.y,5,4));
/*...some code here related to moving snowflake around*/
CGContextDrawLayerAtPoint((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], snowflake[i].location, flakeImage);
}
And it works great. On one screen. And then you plug in a second screen, and it slows down. Not just like half as fast. Like, way down. Think being able to do 60fps to like 1fps. Shark tells me that it's spending 80% of it's time in a function call called argb32_sample_argb32 and another 15% in argb32_image_mark (which calls argb32_sample_argb32), both of which are called (at some point down the line) by CGContextDrawLayerAtPoint.
Any ideas as to what I should do to avoid the slowdown?