Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Drawing performance?

Drawing performance?
Thread Tools
arcticmac
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Dec 14, 2007, 08:12 AM
 
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?
     
Catfish_Man
Mac Elite
Join Date: Aug 2001
Status: Offline
Reply With Quote
Dec 16, 2007, 10:27 PM
 
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?
     
arcticmac  (op)
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Dec 16, 2007, 10:33 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:06 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,