|
|
Drawing performance?
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Aug 2001
Status:
Offline
|
|
Perhaps (grasping at straws here) it can't hardware accelerate two screens due to not having enough vram. Do you have two tiny screens you could plug in to try it on?
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
I don't think that's the case, but I'm not sure. The solution I've come up with for now is to make a single view that draws snow and covers all screens that are connected, which works alright. It slows down a little bit, but it's more in line with what I'd expect for doubling the size, and it doesn't up the CPU much, so I'm inclined to leave it for the time being and trust people not to have too many screens. probably I'll fix it sometime in the future - do it in OpenGL or something...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|