Re: Dealing with Very Slow NSViews
Re: Dealing with Very Slow NSViews
- Subject: Re: Dealing with Very Slow NSViews
- From: Greg Hulands <email@hidden>
- Date: Sat, 7 Sep 2002 11:17:37 +1000
Hi john,
I had this problem just last week - although not with 200,000 bezier
curvers. What i did to get phenomenal speed increase was to create an
NSImage the size of the view and draw into it.
eg.
In header
NSImage *_cachImg;
In implementation
(void)drawRect:(NSRect)rect
{
if (!_cacheImg)
[self recache];
[_cacheImg drawInRect:rect fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];
}
in all of the methods that affect the appearance of the view i would
call
[self recache];
In recache i would do this
- (void)recache
{
NSSize size = [self frame].size;
[_cacheImg release];
_cacheImg = [[NSImage alloc] initWithSize:size];
[_cacheImg lockFocus];
//draw stuff in here
[_cacheImg unlockFocus];
[self setNeedsDisplay:YES];
}
Hope this helps,
Greg
This was typed in mail so there is no doubt some problems
On Saturday, September 7, 2002, at 08:11 AM, John Nairn wrote:
My Cocoa application is great for interactive graphics when plotting
scientific results. Recently I did some large calculations. While I
can still plot them, the task is too demanding for things like live
scrolling, live window resizing, and continuous controls (for example,
one view had to create, draw, and fill about 200,000 bezier curves). I
am tying to think of ways to improve speed, but also I should
implement things to improve the interface when it must be slow. I had
trouble with my first ideas in Cocoa. Does any one know how to solve
such problems as:
1. I would like to turn off live window resizing. I can then drag to
new size and wait once for redisplay.
2. Similarly, I would like to turn of live scrolling. I can then drag
thumb to new location and let go for one redisplay.
3. Finally, I have a slider that selects from a set of results (each
of which is a large calculation). Currently the slider is continuous.
It is easy to make it not continuous, but I need it half and half. I
need it continuous to give text feedback on which result is about to
be selected, but when it is done I need one last message to actually
draw that plot.
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page: http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.