[cairo] Cairo and ISO C++

Jeff Muizelaar jeff at infidigm.net
Mon Jan 20 23:17:54 PST 2014


On 1/20/2014, 7:16 PM, Michael McLaughlin wrote:
> Hi!
> I wanted to give everyone an update. Earlier today a proposal that 
> Herb, Jason, and I have been working on, N3888: A Proposal to Add 2D 
> Graphics Rendering and Display to C++, was published here: 
> http://isocpp.org/files/papers/N3888.pdf . The main focus of the 
> proposal is a series of rules that enable a mechanical transformation 
> from the cairo API to an API that is in the style of the C++ Standard 
> Library (the STL).
I've only quickly skimmed this proposal but one suggestion that 
immediately comes to mind is to drop the EXTEND_NONE mode. I've only 
ever seen this extend mode in cairo. It's not in CoreGraphics, Skia, or 
Direct2D and is not very efficiently implemented on GPUs.

It's also a bit of a user trap because the intuitive way to draw an 
image is with cairo_paint_surface() which works as long as the 
transformation matrix is the identity. As soon as it is not, you end up 
with fuzzy image borders. CoreGraphics, Skia and Direct2D all solve this 
problem by having api similar to HTML Canvas's drawImage() that 
effectively does set_extend(EXTEND_PAD); clip(imageBoundsRect()); 
paint(image);

The work we've done on the Moz2D API may also be of some interest to 
you. It aims to be an efficient C++ wrapper around cairo, CoreGraphics, 
Skia and Direct2D. The API is not as polished as cairo but it aims to 
expose a common subset of functionality. Because of this it has been 
much easier to support different backends than it has been in cairo. You 
can see it here: http://dxr.mozilla.org/mozilla-central/source/gfx/2d/2D.h

-Jeff


More information about the cairo mailing list