The cairo project is glad to be participating in Google Summer of Code 2008. See the cairo announcement for an overview of the process to be followed by students, then come back here for a list of potential project ideas.
Why cairo is cool
Cairo has a great community of users and developers. We use a single mailing list for both user questions and development discussions. This has proved to be a very effective way of helping users become developers gradually. It all starts by submitting that small first patch. The same thing applies to our IRC channel. Please feel free to join and watch for a few days, to get the hang of it. We never say "this is not the right list/channel for this question/discussion". Mailing list and IRC information can be found on the cairo contact page.
Overview of the library
Cairo is a library written in the C programming language. Its main external dependency is a library called pixman that does the software rendering for cairo. Most of the ideas below do not touch on Pixman though. See cairo download for instructions on how to obtain the cairo source code.
Cairo has a very clean code base that is a pleasure to read. We believe that source code should be written with a primary goal to make it easy to be read by humans. The file names are very clean and instantly give an easily understandable map of the code base. For example, the cairo xlib surface backend is implemented in src/cairo-xlib-surface.c. All the other xlib-specific code is under src/cairo-xlib-*.c names too. The code itself is fairly well documented with comments and documentation blocks for all public symbols. The best way to start seeing how things work, after you have checked the documentation and know how to use cairo, is to start skimming through src/cairo.c and checking out other source files from there.
Summer of Code Project Ideas
Each idea below is given a difficulty estimate, (Easy, Medium, or Hard), determined by one of the potential mentors. Please use these ratings to help choose an appropriate project. If a project description uses terms you've never heard of and is also rated Hard, then you can know that that's a project that will provide plenty of learning experiences for you. If a project is rated as Easy, then maybe it won't keep your interest and give you the intellectual challenge you're looking for.
[Medium] Implement a faster lookup-table-based rasterizer
Cairo's software rasterization currently does a complete walk of a regular 15x17 sampling grid for ever pixel in order to compute coverage. This is quite slow. It would be great to have something much faster.
With the recent change from 16 bits of sub-pixel precision to only 8 bits, (and perhaps even throwing some of those away), there's perhaps something easy to do. One approach would be to generate a lookup table based on all possible input and output positions of a trapezoid edge to a pixel. Then rasterization can become nothing more than 1 to 4 table lookups for each pixel.
[Hard] A significant improvement to pixman compositing code
We know that we want something that is more dynamic than the current approach of hand-writing optimized MMX/SSE2 functions for special cases. We have a proof-of-concept of dynamic code-generation for pixman in the jitblit library, but nothing that's in a form suitable to ship, (due to unfinished parts of the compilation framework that jitblit uses).
One possible approach would be to instead base a new framework on LLVM Søren also has some ideas about doing something somewhat dynamic, but much less aggressive than the kind of approach taken with jitblit.
[Medium] Merge XLib and XCB backend similarly to what was done recently to PDF and PS
Currently there are separate XLib and XCB cairo surface backends. The problem is, the XCB backend is not maintained and does not get the same treatment (bug fixes, improvements, ...) that the XLib backend does. The two also duplicate a lot of code. The idea is to merge the duplicate code, possibly using a similar approach used to make the Postscript and PDF backends share code, namely, cairo-pdf-operators.c.
[Medium] Implement
cairo_stroke_to_path()This API function provides a new path that the outline that would be formed by computing a stroke of the current path. The current stroking algorithm does compute this path, but the path has some undesired self-intersecting regions in it. These self-intersections need to be detected and eliminated. The intersection-finding code at the core of cairo's tessellation implementation should provide all the primitive operations necessary for this.
[Hard] Improve software polygon compositing by doing it in a single scanline pass rather than tessellating, rasterizing, then compositing the entire polygon.
[Medium] Fix cairo so that a degenerate matrix draws nothing rather than triggering an error state. That is:
cairo_scale (cr, 0, 0);should not cause an error, (though maybe it shouldn't actually draw nothing for painting an infinite source pattern---compute the average color for a surface-based source pattern perhaps?).[Hard] Add appropriate color-management support to cairo.
Cairo needs the ability to allow for color management. By this project it will become possible to work in different color spaces, convert automatically to blend different content and tag graphics objects to tell backends about the color spaces involved. The color space information will follow the ICC standard.
In this project you will learn about the constraints at different OS'es and handle API abstraction. During the programming work you will design and implement the corresponding means covering frontside API's and backend specific code due to file formats and other specific requirements. A small application, showing the new capabilities, will help in spotting problems and can later be used for demonstrations. A unit test and documentation is required for maintainablility and further easy deployment.
Some relevant threads from various mailing lists:
- Color, Cairo and Cups
- PDF, CMYK and cairo
- Creating CMYK and spot colors using Postscript backend
- Tessellating complex figures with Render contains a subthread on color spaces.
[Medium] Add HDR image surface type to cairo/pixman (
CAIRO_FORMAT_ARGB64).The new image format will implement the scRGB colorspace. This involves either extending the pixman library to support the new format, or write code for Porter-Duff compositing on the new format and make cairo use them for ARGB64.
[Easy] Add a performance/conformance suite for the vector backends.
One goal would be to aim to make the output file size competitive to other generators (e.g. gs). Conformance could be checked by running the test output through various validators: SVG validator.
[Hard] Add support for PDF/PostScript Type 6 (Coons patch mesh) and/or Type 7 (Tensor-Product patch mesh) shading functions to the image backend
The Type 6 shading is a special case of the Type 7 shading so only implementing Type 7 may be all that is required.
One possible solution would be to create a triangle mesh (similar to Type 4 shadings) from the Type 7 patch mesh and shade the triangles using Gouraud shading.
The Poppler source may be used to get an idea how Poppler renders these gradients . However the approach Poppler uses of recursively breaking each patch into smaller patches then filling the tiny patches with a solid color is not appropriate for cairo due to the visible seams between patches due to antialising.
The algorithm for Gouraud shading is in many books on computer graphics.
Useful references:
[Hard ?] Implement path operations like combine/intersect/overlay
A robust "intersection finder" is at the heart of all of this (that's the hardest part). It would start with robust primitives for polygons, intersecting two paths would do a polygonal approximation of the curves, do the intersection, and return a path that has no curves in it. And then could be potentially extended to have curves in the output. An example of direct 'visible impact' could be an ability to extend cairo's clipping functions with something like
cairo_clip_exclude(cr)andcairo_clip_invert(cr).
Website improvements
Cairo's website is run using ikiwiki. See here for more details about how to get the website source code.
[Easy] Integrate subset of old cairo-demo programs into the wiki proper
[Easy] Integrate existing reference manual into the wiki proper
Ideally the rest of the wiki would be able to write
cairo_create()and have that automatically link to the entry forcairo_create()in the reference manual. A unified look and feel of the reference manual would be a plus.
