| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
The drawRect method of my custom view draws many elements (100's to
100,000) and each element has a stroke method. Drawing these elements
is twice as slow in Cocoa app then in prior version of the app in
Carbon. But it is much worse --- most of the graphics time in Cocoa is
taken by filling a rectangle with a color and that graphics call
(NSRectFill()) is TEN times slower than the comparable Carbon
FillRect(). Is there any way to speed up graphics in Cocoa?
Here is the central, slow method in Cocoa app
- (void)stroke:(id)sender
{
float radius=[sender radius];
NSRect ptRect;
[color set]; // color for element
ptRect=NSMakeRect((float)pt.x-radius,(float)pt.y-radius, 2.*radius,
2.*radius);
NSRectFill(ptRect);
}
The Carbon code that is 10 times faster (despite needing extra
calculation - a conversion to pixel coordinates) is:
| References: | |
| >Cocoa graphics speed (From: John Nairn <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.