Nick,

I'm using [NSView setNeedsDisplayInRect: r] and [NSView drawRect: r], so I'm 
not explicitly flushing and that's not goofing things up.  Beam-sync is related 
to flushing, I think.  I don't know how to turn it on or off programmatically 
and it does not appear in QuartzDebug -- I think it was removed in Snow Leopard 
or the newest XCode.  It might be renamed to AutoFlush drawing.

However, I've found that I was not using the right CG function:  I was using 
CGContextDrawTiledImage() 
and should have been using CGContextDrawImage().  In my early testing I came to 
the mis-conclusion that CGContextDrawTiledImage() was faster.  It is actually 
about twice as slow.  I was jumping between machines and not being methodical 
about my testing.

I've redone speed tests and now if I don't stretch the window, the screen 
update is fine on my new iMac.  If I do stretch to full screen,  
CGContextDrawImage() takes about 80 ms and CGContextDrawTiledImage() takes 
about 140ms.  

Then I turned on QuartzGL (which I had never heard of until your email, thanks) 
with 
HIWindowSetBackingLocation(windowRef, kHIWindowBackingLocationVideoMemory).  

Now, CGContextDrawImage() takes 4ms or less to update the entire screen.  This 
is beautiful.

I still need to test on my Tiger, PPC mac.  I'm thinking screen updates with 
Quartz will be a problem there, but I don't know yet.  I might have to use a 
separate executable with QuickDraw.  I use copybits in my own dirty rectangle 
handling in Carbon code. [NSView drawRect: r] seems to coalesce all the dirty 
rectangles into one big rectangle that also contains a lot of area that is not 
dirty.  My old code has smaller, non-overlapping dirty rectangles updated with 
copybits which should be more efficient.

Conclusion:

* Quartz is actually sufficiently speedy to update the screen, at least on a 
new mac.
* QuartzGL is great, esp when stretching the image.
* Not sure about Tiger (no QuartzGL) or older machines yet.  Might need to stay 
with QuickDraw/copybits.

Thanks for your help.  I would have wasted a lot of time with CoreAnimation, 
which I don't need for this project.

Joel


On Feb 23, 2010, at 5:50 PM, Nick Zitzmann wrote:

> 
> On Feb 23, 2010, at 4:35 PM, Joel May wrote:
> 
>> Thanks for the info about drawing in a different thread.  I won't waste my 
>> time and sanity.  I guess I need to figure out how to speed up the drawing 
>> instead and keep it in the main thread.
> 
> How often does your app flush its changes? If it's more than 30 f/s, then 
> you're wasting redraws, and either need to disable beam sync, or cut back on 
> the animation. You can use Quartz Debug to find out, and control the beam 
> sync feature.
> 
> Did you also try QuartzGL? It didn't work correctly in Tiger, and it's off by 
> default in Leopard & Snow Leopard, but it ought to work on most Macs. Again, 
> you can experiment with this using Quartz Debug.
> 
> Nick Zitzmann
> <http://www.chronosnet.com/>
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to