• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Quickest Drawing Method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quickest Drawing Method


  • Subject: Re: Quickest Drawing Method
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 25 Jul 2007 10:53:18 +0200

On 25.07.2007, at 02:33, spiderlama wrote:
- (void)applicationDidFinishLaunching:(NSNotification*) theNotification {
...
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(resize) userInfo:nil repeats:YES];
}


- (void)resize {
[window setFrame:rect display:YES animate:NO]; // window contains our view subclass
}

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.


 What you should do at the least is

-(void) resize: (NSTimer*)myTimer
{
NSRect currWinRect = [window frame];
if( currWinRect.origin.x != rect.origin.x || currWinRect.origin.y != rect.origin.y
|| currWinRect.size.width != rect.size.width || currWinRect.size.height != rect.size.height )
{
[window setFrame:rect display:YES animate:NO];
}
}


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.

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?

Cheers,
-- M. Uli Kusterer
http://www.zathras.de



_______________________________________________

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


  • Follow-Ups:
    • Re: Quickest Drawing Method
      • From: spiderlama <email@hidden>
References: 
 >Re: Quickest Drawing Method (From: spiderlama <email@hidden>)

  • Prev by Date: Enabling menu items?
  • Next by Date: Re: Capturing STDOUT from unit test
  • Previous by thread: Re: Quickest Drawing Method
  • Next by thread: Re: Quickest Drawing Method
  • Index(es):
    • Date
    • Thread