• 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
Re: Speed of Quartz (was: optimizing compilers)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Speed of Quartz (was: optimizing compilers)


  • Subject: Re: Speed of Quartz (was: optimizing compilers)
  • From: "John C. Randolph" <email@hidden>
  • Date: Mon, 4 Feb 2002 15:34:24 -0800

On Monday, February 4, 2002, at 02:34 PM, Max Horn wrote:

> At 14:01 Uhr -0800 04.02.2002, John C. Randolph wrote:
>> On Monday, February 4, 2002, at 11:14 AM, Erik M. Buck wrote:
>>>
>>> // define a new bezier path for every two points, set
>>> attributes, and
>>> stroke
>>> for(i = 1; i < MYNUM_POINTS; i++)
>>> {
>>> tempPath = [[NSBezierPath alloc] init];
>>> [tempPath moveToPoint:_myPoints[i - 1]];
>>> [tempPath lineToPoint:_myPoints[i]];
>>> [tempPath setLineWidth:1.0];
>>> [tempPath setLineCapStyle:NSRoundLineCapStyle];
>>> [tempPath setLineJoinStyle:NSRoundLineJoinStyle];
>>> [tempPath setMiterLimit:4.0];
>>> [tempPath stroke];
>>> [tempPath release];
>>> }
>>
>> This is just a guess, but I think that what's killing you here
>> is memory allocation.
>
> John,
>
> just to clarify this: what you quote is the 10 times FASTER version!

Sorry, I picked out the wrong example.

So, here's the straight dope: the cost of rendering a path
(whether directly in CoreGraphics, or using NSBezierPath to talk
to CG for you) is a function of the number of line joins and
intersections in the path.

Someone on the CG team just explained to me that ...

"Drawing 1000 individual moveto/lineto segments is essentially
equivalent to drawing 1000 independent thin rectangles of
various lengths at various orientations. Drawing a 1000 segment
connected/stroked path with round linejoins involves parallel
curve formation (including arc line joins), flattening the
curves, feeding the entire beast to the scan converter as a
huge self-intersecting polygon, resolving the self-intersections
to get the antialiasing right, etc...."

So, when you have a bunch of lines to draw, keep in mind that
intersections and line joins add up. BTW, it would appear that
round line caps/joints are somewhat more expensive than mitered
or square caps.

Hope this helps..

-jcr


John C. Randolph <email@hidden> (408) 974-8819
Sr. Software Engineer, Cocoa Evangelism
Apple Worldwide Developer Relations


  • Follow-Ups:
    • Re: Speed of Quartz (was: optimizing compilers)
      • From: Marcel Weiher <email@hidden>
    • Re: Speed of Quartz (was: optimizing compilers)
      • From: "Todd Heberlein" <email@hidden>
References: 
 >Re: Speed of Quartz (was: optimizing compilers) (From: Max Horn <email@hidden>)

  • Prev by Date: Re: Speed of Quartz (was: optimizing compilers)
  • Next by Date: Re: Transparent Button
  • Previous by thread: Re: Speed of Quartz (was: optimizing compilers)
  • Next by thread: Re: Speed of Quartz (was: optimizing compilers)
  • Index(es):
    • Date
    • Thread