« 2005-06-14 Update | Main | <svg:foreignObject> disabled »

June 15, 2005

Win32 Backend Renderer

I'm considering switching the renderer that Mozilla SVG uses on win32 to cairo from GDI+. The reasons for this:

There is one missing chunk of functionality in the existing cairo 0.5.0 win32 backend, the ability to convert text to paths. I've implemented this and have asked the cairo people for review.

One problem we're currently seeing with cairo is incorrect blending results when compiling with Visual C 6.0 optimized and on OS-X (bug 293353).

Some timing results of cairo vs. GDI+ for Hixie's simple SVG performance tests - time in seconds:

cairo gdi+
test1 25.8 15.7
test2 25.5 15.9
test3 5.3 5.3
test4 126.3 6.5

As you can see, the numbers aren't that bad except for test4, where cairo is about nineteen times slower than GDI+. This test renders a large number of <svg:image>s. While I haven't been able to get a profile on Win32 (any Quantify experts, please speak up), this test runs equally slow on linux and a profile there shows the majority of the time is spent here:

samples  %        symbol name
1996617  57.9397  PictureTransformPoint
961417   27.8993  __divdi3
474326   13.7644  miPointInRegion

PictureTranformPoint is shared code with libpixman (called pixman_transform_point), called by the general compositing function. Talking to the cairo people, there have been some changes in the freedesktop.org xserver tree to speed this up, which haven't made it back to libpixman yet.

Posted by tor at June 15, 2005 12:04 AM

Comments

When did cairo-win32 become good enough to consider using it on Windows (especially for 1.8)? Last I'd heard, it was lagging behind enough that you were seriously considering waiting to see how well it kept up before jumping from gfx/plat backends to a Cairo-based single set of interfaces for everywhere (and this was in the 1.9 timeframe, which was/is a ways off).

Posted by: Jeff Walden at June 15, 2005 5:47 AM

I'd also question this, since the GDI+ implementation is actually already quite slower than competing SVG implementations out there (especially with gradients it seems, see http://www.codedread.com/yastframe.html). Yes it would be nice to commonize but not at the cost of slowing down the SVG rendering even further and (if I understood your post) breaking a few features that currently work on GDI+.

Is the message here that the SVG implementation in Firefox will mostly be for static displays of basic images and could be viewed as a preview of more advanced features (like DOM scripting of SVG, gradients, text, etc) that will only become realistically usable once cairo is optimized?

I'm not trying to criticize here, but as a developer, I'm of course eager to see improved SVG support all the way around. Anyway, keep up the good work.

Posted by: Jeff Schiller at June 15, 2005 6:22 PM

Features lost moving from GDI+ would be dashed curves and text selection. In return you'd gain the <textPath> implementation and gradients that behave like the specification says they should.

If you have additional performance testcases wrapped in the manner of Hixie's, I'd be happy to test them to get a more complete picture of the performance differential.

Posted by: tor at June 15, 2005 11:13 PM

basicly i think its a good idea to switch to cairo, mainly because of the improved consistency across plattforms !
but there are still some questions:
how likely is a speed improvement for later versions of cairo? do you expect cairo to be faster than gdi+ at some point ? will there be a glitz port for windows ? what is the expected timeframe to get back the droped features(dashed cures , textselection) ?

Posted by: Holger WIll at June 16, 2005 12:38 PM

There is potential for cairo to be faster than GDI+, since as far as we can tell GDI+ is purely a software library. I don't know what plans the cairo people might have towards speeding up the win32 backend or using glitz and/or d3d.

Dashed curves are a shortcoming of the cairo library. There was some discussion of them on the development list a couple weeks ago, so someone might be working on them. If another cairo snapshot with this feature is released before Firefox 1.1 that we're comfortable with, we'll probably switch to that. Otherwise this feature will need to wait until the next major release of Firefox, likely a year or so away.

I don't plan on implementing text selection drawing in the 1.1 timeframe, so that won't be back until the next major release.

Posted by: tor at June 16, 2005 5:49 PM

While switching to cairo on all platforms is definitely something we need to do, I'm not convinced that now is the best time. The GDI+ renderer behaves much better for my application than cairo does, particularly for any kind of dynamic SVG.

On the other hand, as we move forward with various features (textPath, patterns, etc.) it may be that the GDI+ renderer will become increasingly less functional. That may drive us to a switch before we have performance parity. I would suggest waiting until the functionality differential is a little greater.

Posted by: Scooter Morris at June 17, 2005 5:13 PM

What about leaving GDI+ for Firefox 1.1 and then immediately after that making the move to Cairo?
This way, those who need fast svg with current featureset can use the official 1.1 and all others can experiment with trunk + Cairo.
Gains us some time to optimize Cairo until 1.5 and makes development easyer after 1.1
Would it be possible/allowed to switch to Cairo as early as for 1.1 anyway?

Posted by: Stebs at June 19, 2005 5:34 AM

We know that Mozilla's SVG implementation isn't going to be winning any speed contests in its current state, so I'd rather provide maximum functionality for people to use/experiment with and provide feedback.

Switching to cairo for 1.1 is just a matter of changing a configuration option.

Posted by: tor at June 20, 2005 4:51 PM

Ah, didn't know it is that easy to switch.
I think for the normal, just interested user (like me) it doesn't really matter anyway since the few real-life Pages with Svg mostly dont work because they ask for a plugin (probably that from Adobe).

So, if there are not too much complaints from devs. like Scooter Morris, go ahead :)

Posted by: Stebs at June 20, 2005 8:38 PM

Tim, just curious what the status is here, have you come to any decision? After all is said and done, I wouldn't miss dashed curves and text selection is currently broken in GDI+...

Posted by: Jeff Schiller at July 11, 2005 5:06 PM

oh, and textpath would be nice...

Posted by: Jeff Schiller at July 11, 2005 5:07 PM