FROM : Jonathan Jackel
DATE : Sun Dec 12 16:55:22 2004
Presumably you are simply using [string drawAtPoint:withAttributes:] or
[string drawInRect:withAttributes:] or the equivalent methods in
NSAttributedString. The AppKit string drawing methods are not intended
for drawing and redrawing lots of strings. They are fine for a few
static labels, but not for a huge number of labels that have to be
redrawn a lot.
You should get much better performance out of the "glyph" methods in
NSBezierPath. If you want to understand how they work, I strongly
recommend getting a copy of "Cocoa Programming" by Anguish, Buck &
Yacktman and go straight to chapter 14.
Jonathan
On Dec 12, 2004, at 4:23 AM, <email_removed> wrote:
> Summary:
>
> I put an NSImageView inside an NSScrollView. It scrolls smoothly. I
> put a large number (300) of labels inside an NSScrollView. It scrolls
> slowly. Why is this happening, and what can I do to change it?
>
> Details:
>
> I have an application that needs to display a large number of labels
> on screen at once. These labels must be scrolled, so I decided to use
> an NSScrollView. I first tested the NSScrollView out with an image,
> out of curiousity. It worked fine; the scrolling was smooth and
> responsive. Then I tested it out with a large number of labels. The
> scrolling slowed down considerably. This suprised me, as I thought a
> large number of labels would scroll as fast as an image. After all, I
> could display an image with the text of the 300 labels, and it would
> look exactly the same to the user. Then I discovered that labels in
> Cocoa are actually non-editable NSTextViews. Could this be the cause
> of the problem? Either way, how would I go about speeding up the
> scrolling?
> Making each label into an NSImageView wouldn't work. I tried putting
> 300 NSImageViews onto the window in place of 300 labels, and it was
> even slower. I suspect that generating a new transparent image
> (containing the text of each label) to cover the entire window, upon
> each movement of the scrollbar, would be just as slow. Perhaps I would
> be able to override the NSTextField (or NSImageView) class to create a
> "lite" version that incurred less overhead? Any pointers on how to do
> this would be appreciated, as I am new to both Cocoa and Object
> Oriented Programming.
> One last thing - the 300 labels are scattered about the screen, and
> are not in orderly rows and columns.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
DATE : Sun Dec 12 16:55:22 2004
Presumably you are simply using [string drawAtPoint:withAttributes:] or
[string drawInRect:withAttributes:] or the equivalent methods in
NSAttributedString. The AppKit string drawing methods are not intended
for drawing and redrawing lots of strings. They are fine for a few
static labels, but not for a huge number of labels that have to be
redrawn a lot.
You should get much better performance out of the "glyph" methods in
NSBezierPath. If you want to understand how they work, I strongly
recommend getting a copy of "Cocoa Programming" by Anguish, Buck &
Yacktman and go straight to chapter 14.
Jonathan
On Dec 12, 2004, at 4:23 AM, <email_removed> wrote:
> Summary:
>
> I put an NSImageView inside an NSScrollView. It scrolls smoothly. I
> put a large number (300) of labels inside an NSScrollView. It scrolls
> slowly. Why is this happening, and what can I do to change it?
>
> Details:
>
> I have an application that needs to display a large number of labels
> on screen at once. These labels must be scrolled, so I decided to use
> an NSScrollView. I first tested the NSScrollView out with an image,
> out of curiousity. It worked fine; the scrolling was smooth and
> responsive. Then I tested it out with a large number of labels. The
> scrolling slowed down considerably. This suprised me, as I thought a
> large number of labels would scroll as fast as an image. After all, I
> could display an image with the text of the 300 labels, and it would
> look exactly the same to the user. Then I discovered that labels in
> Cocoa are actually non-editable NSTextViews. Could this be the cause
> of the problem? Either way, how would I go about speeding up the
> scrolling?
> Making each label into an NSImageView wouldn't work. I tried putting
> 300 NSImageViews onto the window in place of 300 labels, and it was
> even slower. I suspect that generating a new transparent image
> (containing the text of each label) to cover the entire window, upon
> each movement of the scrollbar, would be just as slow. Perhaps I would
> be able to override the NSTextField (or NSImageView) class to create a
> "lite" version that incurred less overhead? Any pointers on how to do
> this would be appreciated, as I am new to both Cocoa and Object
> Oriented Programming.
> One last thing - the 300 labels are scattered about the screen, and
> are not in orderly rows and columns.
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| vastudent | Dec 12, 10:23 | |
| Jonathan Jackel | Dec 12, 16:55 |






Cocoa mail archive

