Rasterizing dragons

I've been working on a new rasterizer to replace the Freetype rasterizer for aliased painting in the raster paint engine, which is used on Windows and when rendering to a QImage. The new rasterizer is scheduled to be part of Qt 4.4, and is already available in the snapshots.

The performance of rasterizing various paths with QRasterizer compared to the Freetype rasterizer can bee seen in the following figure:

Freetype rasterizer vs QRasterizer

And the same results in table form:

Freetype QRasterizer Improvement
A - Plain rectangle 25773.2 37174.72 1.44
B - Rotated rectangle 1 23201.86 27247.96 1.17
C - Rotated rectangle 2 23041.47 28735.63 1.25
D - Rect dash stroke 276.24 1754.39 6.35
E - Rect dot stroke 87.95 826.45 9.4
F - Ellipse 3558.72 6944.44 1.95
G - Ellipse dash stroke 141.64 1282.05 9.05
H - Ellipse dot stroke 83.54 800 9.58
I - Short text path 14285.71 17241.38 1.21
J - Long text path 1683.5 1930.5 1.15
K - Random path size 5 24523.81 30294.12 1.24
L - Random path size 50 778.15 1098.13 1.41
M - Random rects (5) 25750 39615.38 1.54
N - Random rects (50) 324.81 753.21 2.32

Note: the numbers are for generating spans only, not filling. The benchmark used to measure these results can be downloaded from here: rasterizerbench.tar.gz

These numbers are already quite impressive, but where the new rasterizer really shines is for rasterizing complex paths with a lot of elements and potentially many self intersections. I've created an example which generates a path representing the Dragon Curve fractal. A screenshot from the application is shown below:

Dragon Curve (fractal) rendered using QRasterizer

At the highest detail setting the path (which is a round-cap/round-join stroke of the dragon curve) contains 507913 path elements. In this specific case the frame rate is approximately 36 times higher with the new rasterizer (filling included) :)

The example is available for download from here: dragoncurve.tar.gz

Note: the new rasterizer only affects primitive rendering (polygons, paths, ellipses, strokes, etc), and does not replace the Freetype rasterizer for plain font rendering.

Blog Topics: