Skip navigation.
 
mlSmooth Scrolling / Animation with Cocoa
FROM : Mike Solomon
DATE : Fri Nov 19 20:32:36 2004

Let me lay out the facts - hopefully someone will be able to fill in
the missing piece. There has been some discussion about this sort of
thing on this list over the past couple of years, but none of the
suggestions have resolved my particular problem.

I have a custom view that scrolls a cached NSBitmapImageRep
horizontally.  An NSTimer calls a method which in turn calls
setNeedsDisplay:YES on my custom view.  When my drawRect: routine gets
called, I compute the distance I need to scroll (quick math) and call
drawAtPoint: on the image rep.

The timer fires approximately 30 times per second and my scroll
velocity is 30 pps (pixels per second).

The scrolling is smooth and looks quite good for a short period of time
(3-4 seconds) but then I get tearing (I think I mean tearing, but it
could be shearing.)  Basically some portion of the image draws at a
different horizontal offset from the rest of the image. This usually
only affects one or two frames before it corrects itself, but it is
visually very distracting.

I have tried a few things to improve the drawing:
1. higher refresh rate (60, 90 Hz), no effect
2. very high refresh rate with culling (high frequency timer, skip
drawing calls to emulate 30 frames per second, sort of a wall clock
technique), no effect
3. wrote a sample using a programmatic NSClipView to scroll the items,
no effect
4. renice the process to real time priority (renice -20 -p <pid>), no
effect

It basically looks like the window isn't double buffered, but I but it
is, based on the default NSWindow implementation and the options I've
given it.  There is no way that I have seen to update the image during
the "vertical blank" (which I don't think exists on an LCD screen).

Anyway, I'm all out of good ideas at this point.  I was hoping someone
might have some suggestions about what could be causing the tearing and
how to fix it up.  I've hunted through the video game dev forums and
various other places, but I haven't had the eureka moment yet.

I'm running this under Mac OS X 10.3.6 on a 15" AlBook 1.25GHz.

Thanks.

-Mike

Related mailsAuthorDate
mlSmooth Scrolling / Animation with Cocoa Mike Solomon Nov 19, 20:32
mlRe: Smooth Scrolling / Animation with Cocoa M. Uli Kusterer Nov 22, 09:03