Unleashing the power of QPainterPath::addEllipse()

Published Wednesday October 13th, 2010
7 Comments on Unleashing the power of QPainterPath::addEllipse()
Posted in Performance, WebKit | Tags: , ,

Up until recently, WebKit used to draw SVG circles and ellipses by breaking them down into 100-segment paths. This was done to get consistent auto-test results across different platforms and rendering libraries. Unfortunately, it wasn’t very fast. With Qt 4.7’s WebKit, my machine reaches a meager 17 FPS on the SVG version of The Man in Blue’s benchmark which is pretty sad.

I spent some time digging into this issue and have finally landed a change upstream that makes WebKit take proper advantage of the underlying libraries – in our case by using QPainterPath::addEllipse() to compose the shapes instead of QPainterPath::lineTo(). This bumps our FPS on the aforementioned test to 51, three times faster!


New Ellipse vs. Old Ellipse. Dots mark the relevant path points.

For the specifically curious, here’s the webkit.org commit: r69517

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Performance, WebKit | Tags: , ,

7 comments

TheBootroo says:

How to say ? Just Great !!

Could you fix the border-radius aliasing pb too ?

Andreas Kling says:

@TheBootroo: Glad you like it πŸ™‚
Please see this page for information on how to report QtWebKit issues: http://trac.webkit.org/wiki/QtWebKitBugs

Shocked says:

Now, why was WebKit using lineTo in the first place? That sounds ridiculous, but hey, let’s celebrate the fix rather than looking back at old and stupid code πŸ™‚

natrium says:

But how well do these curves approximate ellilpses compared to the original set of lines? (I do not know what method the original used when generating the sequence of lines.)

Andreas Kling says:

@natrium: Quite well it seems. There are some slight differences in anti-aliasing but that’s to be expected. And if you zoom in, the new version obviously looks way better. πŸ™‚

jaded says:

@shocked

probably was done to satisfy testing needs instead of real world needs, tdd. having a fixed 100 point aproach is after all something you wouldn’t come up with too many other starting points for the design on how to draw a circle or a curve.

Commenting closed.

Get started today with Qt Download now