Title Rewrite of Cairo's 2D Rendering Library
Student Eric Michael Hielscher
Mentor Stuart Parmenter
Abstract
Cairo is a 2D graphics library that supports rendering to multiple different hardware devices. Firefox uses Cairo as its default renderer, and in fact after the 1.5 release only Cairo will continue to be supported. Cairo uses a library called Pixman for compositing and other generic pixel region operations. Pixman's code was written without much thought given to optimization and its structure doesn't lend itself to easy maintainence. The project described in this proposal is to write an highly optimized 2D compositing library that can be plugged into Cairo as a backend and replace Pixman.

The deliverables of this project are to be as follows:

-A clean, maintainable codebase with a well-designed API
-Exploitation of MMX/SSE extensions, and if time permits AltiVec, with demonstration of performance gains
-Full documentation of the new codebase as well as a writeup of the development process

The code is to remain cross-platform as well, with standard C code to be written for when such extensions are unavailable. Part of the Pixman codebase was taken from X.org, and thus any improvements realized should be of interest to that project as well. Thus, attention to making the code portable to the X.org codebase will be important.

The main function of the library would be to provide Porter-Duff image compositing operations. Porter-Duff is the standard algebra implemented to provide for the compositing of images and consists of 12 simple binary operations to be performed between images. The details of these operations lend them to being perfect candidates for SIMD optimization. In addition, these operations are use often and repetitively and there could be significant performance improvements from their being thus optimized.

MMX and SSE are the SIMD ISAs provided on newer x86-compatible processors. These instructions allow the same operation to be performed on vectors of variables all at once, allowing for significant speedup on workloads that perform repetitive operations on large data sets. AltiVec is the SIMD extension provided on PowerPC architectures and offers similar capabilities.

My rough implementation plan is as follows:

-Develop, with the help of my mentor, a design document which outlines the API and required functionality in detail
-Develop an API skeleton and complete a simple implementation of the Porter-Duff and other operations
-Plug this implementation into Cairo
-Write SSE and possibly AltiVec optimized implementations of the above-mentioned code

I would like to keep up to date on documentation throughout the project, but I imagine a big finalization of the documentation would occur at the end of the summer.