Resending to the list. On Feb 18, 2013, at 2:50 AM, iain <i...@sleepfive.com> wrote:
> > > On Mon, Feb 18, 2013 at 7:17 PM, Kyle Sluder <k...@ksluder.com> wrote: >> On Sun, Feb 17, 2013, at 11:46 PM, iain wrote: >> > I'll give this a go, does -setFrameSize just deal with the visible >> > portion >> > when inside an NSScrollView/NSClipView? If so, thank you, that's great. >> >> No. You're missing my point. >> >> You have -viewWillDraw, an override point at which you know your view >> will draw. You don't need to track your visible rect. You will only be >> asked to draw rects that intersect with your visible rect[1]. Just query >> -getRectsBeingDrawn:count: from within -drawRect, and render your >> waveform for those rects. > > Well, that's essentially what I'm doing, by only drawing in the dirtyRect > (yeah, I know that's just one big union of the results of getRectsBeingDrawn, > but "essentially"). Right, but you're missing the crucial step of caching this drawing. I'm obviously not being clear. Here's some pseudocode: - setFrameSize:(NSSize)size { [super setFrameSize:size]; [self discardEntireWaveformCache]; } - setNeedsDisplayInRect:(NSRect)rect { [super setNeedsDisplayInRect:rect]; [self invalidateWaveformCacheForReft:rect]; } - viewWillDraw { if ([self waveformCacheDiscarded]) { [self allocateWaveformCacheOfSize:self.bounds.size]; } for (NSRect rect in [self getRectsBeingDrawn]) { if (!([self waveformCacheIsValidForRect:rect])) { [self cacheWaveformForRect:rect]; } } } - drawRect:(NSRect)unused { for (NSRect rect in [self getRectsBeingDrawn]) { [self drawWaveformCacheForRect:rect]; } } Implementation of the waveform cache, as well as more sophisticated techniques like background rendering the waveform cache are left as exercises to the reader. --Kyle Sluder _______________________________________________ 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