-
Website
http://toxicsoftware.com/ -
Original page
http://toxicsoftware.com/discrete-nslevelindicatorcell-too-slow/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
schwa
20 comments · 2 points
-
Alexander Mikhalev
1 comment · 1 points
-
myxibrium
1 comment · 1 points
-
somegeekintn
1 comment · 1 points
-
Stewf
2 comments · 1 points
-
-
Popular Threads
Awesome treehouse(s) by the way.
I should make an exception for you though Chris… How about commercial - $1,000,000 per seat?
Try writing a subclass with this as its only implementation:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
[NSGraphicsContext saveGraphicsState];
NSRectClip(cellFrame);
[super drawWithFrame:cellFrame inView:controlView];
[NSGraphicsContext restoreGraphicsState];
}
The issue is with CG transparency layers (see CGContextBeginTransparencyLayer). They're a nice, clean way to a bunch of drawing, then put a shadow or a focus ring on the whole thing. Problem is, when you composite a transparency layer, it'll do calculations over the whole clip. It happens that when a cell is drawn in a tableview, the only clip is to the whole table.
That's, uh, bad.
I took out my code and replaced it with your simple clipping fix.
It certainly improved performance over the non-posed version but I think the caching version is still the fastest. Which is a shame, as your code is certainly cleaner and simpler.
You can compare all three versions here: http://toxic-public.googlecode.com//trunk/Misc/...