On 01/09/2009, at 10:47 PM, Dave Keck wrote:

Probably wherever you do the -setNeedsDisplay: for the view would be about right... ;-)

Unfortunately that's not a good place either - the window's shadow
needs to be invalidated after the drawing actually occurs, not just
when the dirty flag is set.

Instead of -setNeedsDisplay:, I think your best bet is:

   [[cView window] display];
   [[cView window] invalidateShadow];

Or if you can target Snow Leopard, I remember seeing some 'NSView did
draw' delegate methods...

I see that the end of drawRect: is indeed a bad place to do it. The app's CPU % use jumps from ~1% to 2%~3%. I'll have a play/think about where to do
it.  Maybe in the custom window class or the app delegate.

I don't think you're going to be able to avoid the increased CPU
usage. Invalidating the window's shadow forces it to redraw, which
inevitably will cost some CPU cycles - there's no way around that; it
doesn't matter where you actually tell it to invalidate the shadow.

After five minutes of experimentation I think I can say two things: my first observation about using extra CPU was wrong. I was looking at it when the window was large, so, of course it uses more grunt to run. Resizing it smaller showed that it still, with -invalidateShadow at the end of -drawRect:, only uses about 1.5% of CPU. Secondly, I don't think it matters, as Dave noted, where one calls - invalidateShadow _as long as it works_.

So, in the real (though still just a toy) app, I've put the call at the end of -drawRect: in the bottom most view. So far, everything seems OK. The extra CPU usage is negligible.

Ron

_______________________________________________

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