Pure Quartz vs. Cocoa-Objects ... why is Quartz slower?
Pure Quartz vs. Cocoa-Objects ... why is Quartz slower?
- Subject: Pure Quartz vs. Cocoa-Objects ... why is Quartz slower?
- From: Michael Becker <email@hidden>
- Date: Fri, 11 Feb 2005 02:06:19 +0100
Hi!
I must admit, I am totally new to Quartz 2D, but I am trying to use it
to speed up my application (basically the iPhoto-like multi-thumbnail
view). In my views drawRect: method, I traverse an array of images and
draw them one by one.
I did this at first with the simple NSBitmapImageRep's drawInRect:
method. Now I was trying to replace that with direct Quartz calls.
However, my Quartz-version is noticeably slower than the Cocoa one.
Here is the Cocoa version:
for (i=startingIndex; i<endingIndex; i++) {
. . .
NSBitmapImageRep *currentImage = [images objectAtIndex:i];
[ (NSBitmapImageRep *) currentImage
drawInRect:NSMakeRect(x,y,newImageSize.width,newImageSize.height)];
. . .
}
I turned that into this Quartz2D-version:
CGContextRef context = [[NSGraphicsContext currentContext]
graphicsPort];
for (i=startingIndex; i<endingIndex; i++) {
. . .
CGImageRef image = (CGImageRef)[ images objectAtIndex:i];
// NSRectToCGRect is just a #define to convert the one into the other
CGRect myContextRect = NSRectToCGRect( NSMakeRect(x, y,
newImageSize.width, newImageSize.height) );
CGContextDrawImage (context, myContextRect, image);
. . .
}
Why is the second one so much slower than the first one? Am I missing a
basic fact? Do I need to enable stuff like caching etc. on my own? I
thought that most of Cocoa's Imaging Classes were just wrappers for the
Quartz ones...
Any help greatly appreciated!
Regards,
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden