• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cheap replacement for bezierPathWithOvalInRect fill?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cheap replacement for bezierPathWithOvalInRect fill?


  • Subject: Cheap replacement for bezierPathWithOvalInRect fill?
  • From: Scott Ellsworth <email@hidden>
  • Date: Wed, 19 Apr 2006 17:43:01 -0700

Hi, all.

Shark tells me that a third of my execution is coming from two uses of [[NSBezierPath bezierPathWithOvalInRect: <rect>] fill], which draw something like 3000 circles on the screen. These are all the same size, but are drawn in different colors.

Tiger only APIs are fine.

Snippets from the code:

[[NSColor blackColor] set];
for (int x=0; x<ledsWide; x++){
for (int y=0; y<ledsHigh; y++){
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(viewPaddingWidth +x*totalWidth+paddingWidth,viewPaddingHeight+y*totalHeight +paddingHeight,ledDiameter+borderWidth,ledDiameter+borderHeight)] fill];
}
}


[...]
for (int x=0; x<ledsWide; x++){
for (int y=0; y<ledsHigh; y++){
NSColor * color = [self getColorForX:x andY:y];
[color set];
[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(viewPaddingWidth +x*totalWidth+paddingWidth+borderWidth,viewPaddingHeight+y*totalHeight +paddingHeight+borderHeight,ledDiameter,ledDiameter)] fill];
}
}


I experimented with caching the bezier paths, and with changing the bezier path curve control points, and neither of these turned out to the bottleneck. My bottleneck is the fill command on the circles.

It appears my best options are either using Quartz directly, or creating an image and blitting that. Is there a third option I missed, and does anyone have any strong opinions on which is likely to be straightforward and performant? (I know, I know - choose only one.)

(NB - I did read the docs, which is what convinced me to try moving the control points. I also did some list archive searches, and got inconclusive results for which would work best.)

Scott
_______________________________________________
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


  • Follow-Ups:
    • Re: Cheap replacement for bezierPathWithOvalInRect fill?
      • From: Scott Thompson <email@hidden>
  • Prev by Date: Re: Any tricks to dragging an NSTableView?
  • Next by Date: Re: AsyncSockets connection timeout
  • Previous by thread: Re: AsyncSockets connection timeout
  • Next by thread: Re: Cheap replacement for bezierPathWithOvalInRect fill?
  • Index(es):
    • Date
    • Thread