Re: Drawing many different strings quickly

2015-10-01 Thread Jens Alfke
> On Oct 1, 2015, at 12:02 AM, Ben wrote: > > Using NSString's drawInRect:withAttributes: wants a Swift dictionary of > attributes. Instruments showed a lot of time spend accessing the elements of > this dictionary and converting back to Objective-C land. > Converting the string to be drawn t

Re: Drawing many different strings quickly

2015-10-01 Thread Ben
> On 28 Sep 2015, at 18:42, Alex Kac wrote: > > We had the same question and I asked it at WWDC. A few things I was told: > > 1. El Capitan improves string drawing performance tremendously. That may > solve your problem. > 2. They recommended in our case actually using NSTextFields for each s

Re: Drawing many different strings quickly

2015-09-29 Thread Jens Alfke
> On Sep 28, 2015, at 6:07 PM, dangerwillrobinsondan...@gmail.com wrote: > > If not, NSImage has a nice API for drawing to the image context. Then you > just have an NSImage. Let AppKit do the work. It will cache the drawing of > that image until you change it. That would be trading CPU for R

Re: Drawing many different strings quickly

2015-09-28 Thread dangerwillrobinsondanger
Are you trying to have selectable text? If not, NSImage has a nice API for drawing to the image context. Then you just have an NSImage. Let AppKit do the work. It will cache the drawing of that image until you change it. You can assign that to a layer or use one for each string. + (NSImage *)i

Re: Drawing many different strings quickly

2015-09-28 Thread Graham Cox
> On 28 Sep 2015, at 6:41 pm, Ben wrote: > > The control is only drawing the areas requested by the dirtyRect parameter. > Typically this is an area of (I think - going by memory) 256px square at a > time. When looking at the result of getRectsBeingDrawn, there is only one > rect the same as

Re: Drawing many different strings quickly

2015-09-28 Thread Ben
> On 28 Sep 2015, at 17:08, Jens Alfke wrote: > > >> On Sep 28, 2015, at 1:41 AM, Ben > > wrote: >> >> When scrolling vertically, there could be up to 100,000 strings to be drawn, >> horizontally, much fewer, less than 10,000. I'm assuming a maximum grid

Re: Drawing many different strings quickly

2015-09-28 Thread Quincey Morris
On Sep 28, 2015, at 01:41 , Ben wrote: > > Unfortunately NSTableView doesn't offer the type of interactions I want. I > have filed a radar requesting enhancements. What about a hybrid approach? Use a NSTableView to draw the strings as a background “layer” of your scroll view, and put a sibling

Re: Drawing many different strings quickly

2015-09-28 Thread Jens Alfke
> On Sep 28, 2015, at 1:41 AM, Ben wrote: > > When scrolling vertically, there could be up to 100,000 strings to be drawn, > horizontally, much fewer, less than 10,000. I'm assuming a maximum grid size > of 100 columns and 10k rows. This should be a worst-case assumption. As various people ha

Re: Drawing many different strings quickly

2015-09-28 Thread Aandi Inston
I'd like to suggest a different approach if things cannot be tuned to have far fewer draw calls. Font caching etc. is very fast, but not as fast as it could be given the choices it has to support. I think you said you had one font, one size. I'm guessing you also have no more than 256 different cha

Re: Drawing many different strings quickly

2015-09-28 Thread Ben
> On 27 Sep 2015, at 19:26, Quincey Morris > wrote: > > On Sep 27, 2015, at 10:42 , Ben > wrote: >> >> - Not all strings to be drawn at once, a scroll view is being used and I am >> using responsive scrolling to pre-draw areas. The problem occurs when

Re: Drawing many different strings quickly

2015-09-27 Thread Jens Alfke
Use an NSTableView. It knows how to manage unlimited numbers of rows efficiently. --Jens ___ 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-ad

Re: Drawing many different strings quickly

2015-09-27 Thread Graham Cox
Hi Ben, You may find that responsive scrolling is actually making things worse in this case, because many more strings than you can see are being drawn, and string drawing is expensive. Have you tried opting out of responsive scroling? Apart from that, usual advice applies - draw the very minim

Re: Drawing many different strings quickly

2015-09-27 Thread Quincey Morris
On Sep 27, 2015, at 10:42 , Ben wrote: > > - Not all strings to be drawn at once, a scroll view is being used and I am > using responsive scrolling to pre-draw areas. The problem occurs when quickly > scrolling a large distance I think your answer is in this statement. Assuming you’re drawing

Drawing many different strings quickly

2015-09-27 Thread Ben
Hi list, I'm needing to draw somewhere in the order of 1,000,000 different strings in a scrollable grid view and am struggling to get performance that I am happy with. After profiling, most of my time is spent in drawing text into the view. My first attempt was simply to use NSString's drawInRe