On 16 Jun 2014, at 16:05, Sanjay Arora <saar...@quark.com> wrote:
> My app uses NSScrollView to render a document having complex algorithms to 
> render images. The image rendering operation is quite cpu intensive and takes 
> time. 
> 
> When I scroll the document having multiple pages, using scroll pad or mouse 
> scroll, there happens some jerks in scrolling while rendering the images and 
> scrolling skips some pages in between.
> 
> Any idea, why would NSScrollView skips the pages?

 Your drawing is CPU intensive? Are you doing all your work in -drawRect: and 
methods called from it, on the main thread? Then that's your problem. If 
NSScrollView doesn't get enough CPU, it will "drop frames" to at least somehow 
approximate what the user is doing.

 Instead, schedule the drawing operations on another thread and draw into an 
NSImage, then send that NSImage to the main thread using 
performSelectorOnMainThread:... (and while you don't have the real image, draw 
a placeholder image, e.g. a checkerboard pattern like Maps.app and Photoshop 
do).

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to