On Mon, Feb 18, 2013 at 6:07 PM, Kyle Sluder <k...@ksluder.com> wrote:

> On Sun, Feb 17, 2013, at 05:12 PM, iain wrote:
> >
> > Does anyone have any hints of something I may have missed, or something
> > I'm
> > going about the wrong way?
>
> Unless there's something you haven't told us, you shouldn't need to keep
> track of your visible rect at all.
>

It sounds like you're trying to be really smart and only cache the
> drawing necessary for your visible rect rather than the more naive
> approach of drawing a cache for your entire view whenever its bounds
> change.


Yup, that's exactly what I'm trying to do.


> Is this really a performance boost for you? You say that the
> drawing is complicated; if by this you mean that you spend a lot of time
> doing things other than blitting pixels, you are doing yourself a
> disservice by drawing minimally. It would be faster for you to cache the
> entire view at once.
>

I'm trying to draw a sample waveform so for some of the audio files I have
which come in around 30minutes long, even drawing to a reduction of 8192
frames/pixel you're looking at views of 10,000pixels wide (at 44100hz).
Drawing 1frame per pixel would be a view 80million pixels wide. Admittedly
that's the extreme case but drawing only the visible area is a good
performance boost, especially when I need to draw things on top of the
waveform. I do have the data points cached at certain zoom levels as well
but it's all a memory/speed trade off. I can't cache the data points at all
zoom levels, so I need to loop through the (cached) data to redraw, but
equally I can't have a pixmap backing store at each zoom level, so only
caching a pixmap of the visible area is a trade off I'm happy with.


> If it really is an advantage for you to cache only the pixels that are
> going to be in your visible rect, you can override -viewWillDraw to call
> -getRectsBeingDrawn:… and be super-smart about your caching.
>
> But I suggest you do some profiling and see whether you gain time by
> overriding -setFrameSize: to set a flag that you pick up in an override
> of -viewWillDraw to render a cache for the entire bounds of your view.


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.

iain holmes
_______________________________________________

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