Re: Quickest Drawing Method
Re: Quickest Drawing Method
- Subject: Re: Quickest Drawing Method
- From: spiderlama <email@hidden>
- Date: Wed, 25 Jul 2007 21:51:33 +1000
On 25/07/2007, at 6:53 PM, Uli Kusterer wrote:
I hope you're doing this conditionally? There's no reason to change
the window's frame rect repeatedly, not to mention to a value that
is probably the same rect each time.
I've checked this out. It looks like if I call setFrame on a window,
and the frame is the same as the current frame, nothing happens.
Therefore I am only redrawing when the Dock moves. The activity
monitor shows the process at 0% when the Dock doesn't move. I know
this is similar to a spin lock, but I can't think of any other method.
Also, I don't see why you would want to do this in a timer. You
must have some place where you fill out the "rect" instance
variable with the dock's current rect. So, what you should do is
resize the window from there, and *only* when its size has changed.
For sake of modularity, I have a function that returns the size of
the dock: (NSRect)getDockRect. And remembering resize:
- (void)resize {
static NSRect rect;
rect = [self getDockRect];
[window setFrame:rect
display:YES
animate:NO];
if (rect.size.width == 0) // NSZeroRect
dock = connectToDock();
}
What your code is doing right now is needlessly burning cycles by
telling the window to constantly recreate and re-render its whole
back buffer, even when nothing is happening. Why?
I'm pretty sure it doesn't re-render. I checked this with Quartz Debug.
Is there a callback I can place into the run loop?
AND... how can I find out when the application closed, so I can
release some CGImageRef's?
Cheers,
Matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden