Re: Smooth fast scrolling programatically
Re: Smooth fast scrolling programatically
- Subject: Re: Smooth fast scrolling programatically
- From: Rolf <email@hidden>
- Date: Wed, 28 May 2003 15:14:02 +0200
Very interesting. Thanks :-) I'll try it out.
I wonder why Apple hasn't provided a better performace Cocoa timer. What kind of timer resources does Quicktime and other graphics-intensive applications use ?
/Rolf
28.05.2003 00:26:47, skrev Joseph Jones <email@hidden>:
>
There is a hack on any BSD Socket implementation that will allow you to
>
get microsecond resolution timers. You can use select, passing 0/null
>
for the first four parameters and a timeval pointer as the fourth. You
>
use the timeval to set your timer resolution. You can find an example
>
in the Steven's "Unix Network Programming" book. Since you won't have
>
an NSTimer to work with, you'll have to cut your own NSThread that
>
loops over a function that does nothing more than run loops over this
>
select statement and then calls back into your code in a thread safe
>
manner.
>
>
Here is some sample code (Typed in on the fly, so do not trust it right
>
off):
>
...
>
#import <sys\types.h>
>
#import <sys\time.h>
>
...
>
>
- (void) highResolutionTimer: (id) arg
>
{
>
struct timeval timeout;
>
>
memset (&timeout, 0, sizeof(timeout) );
>
timeout.tv_usec = 1000; //Set 1000 micro second timer
>
>
while ( true ) //You'd want to wait on some thread exit parameter
>
here, such as something to do with arg
>
{
>
select ( 0, (fd_set*)null, (fd_set*)null, (fd_set*)null, &timeout);
>
//This will block till timeout expires in 1000 micro secondds
>
//Do your thread safe call back here!
>
}
>
}
>
>
...
>
>
- (void) myCreateThreadFunc
>
{
>
//The best bet would be to pass something in for the argument object
>
and use that to trigger termination
>
//of the loop.
>
[NSThread detachNewThreadSelector:@selector(highResolutionTimer:)
>
toTarget:self withObject:null];
>
}
>
>
>
Thanx,
>
joe
>
>
On Monday, May 26, 2003, at 10:46 PM, Andrew Garber wrote:
>
>
> From Apple's Cocoa Documentation on timers:
>
>
>
> "Because of the various input sources a typical run loop manages, the
>
> effective resolution of the time interval for an NSTimer is limited to
>
> on the order of 50-100 milliseconds."
>
>
>
> http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/
>
> ProgrammingTopics/Timers/index.html#//apple_ref/doc/uid/10000061i
>
>
>
>
>
> Andrew
>
>
>
>
>
> On Monday, May 26, 2003, at 06:02 AM, Rolf wrote:
>
>
>
>> Thanks. I have checked - its not being redrawn completely. I think
>
>> the problem is NSTimer which is not accurate enough for this use with
>
>> the interval being so small. Maybe I'll have to resort to a busy-wait
>
>> loop inside a seperate thread ?
>
>>
>
>> /Rolf
>
>>
>
>> 26.05.2003 12:32:23, skrev John Hvrnkvist
>
>> <email@hidden>:
>
>>
>
>>>
>
>>> On Monday, May 26, 2003, at 12:17 Europe/Stockholm, Rolf wrote:
>
>>>
>
>>>> My app has a panel with a (wide) NSIMageView inside a (narrow)
>
>>>> NSScrollView. The NSImageView is supposed to scroll smoothly and
>
>>>> quickly inside the NSScrollView from one end to the other
>
>>>> (horizontally). The range is around 300 pixels. The problem is that
>
>>>> the scrolling is not as smooth
>
>>>> as I'd like - its actually quite jerky (on a G4 667 MHz). The app is
>
>>>> performing no other tasks while the scrolling is going on. What can
>
>>>> be
>
>>>> done to create a perfectly smooth (& quick) scrolling ?
>
>>>
>
>>> Have you used QuartzDebug to check that the scroll view isn't being
>
>>> redrawn completely for each scroll "step"?
>
>>>
>
>>> /John
>
>> _______________________________________________
>
>> 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.
>
_______________________________________________
>
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.