[cairo] Extending Cairo API to support reusable paths
Bill Spitzak
spitzak at gmail.com
Wed Mar 31 14:18:36 PDT 2010
Matt Woodrow wrote:
> Hi All
>
> As part of my internship at Mozilla, I'm working on extending the Cairo
> API to allow caching of reusable path objects.
>
> On the default backend, these will directly wrap the current
> cairo_path_t objects, and their related functions.
> However on Quartz we can include a copy of the CGPath object and on
> direct2d a copy of the ID2D1Geometry to hopefully increase redraw
> performance on these platform.
They could also store bitmaps in the font glyph cache on X. They would
be created when a path consisting of exactly one of these is filled or
stroked. If the same action is performed again (except for an integer
difference in the current transform) the saved image can be reused.
Perhaps some rounding of different non-integer translations to a small
set of fractional positions, like for fonts, can be done. This could
speed up the case where the same path is drawn repeatedly at different
positions.
I think even the device-specific ones are going to have to contain all
the info in a cairo_path_t. This is probably the only reliable way to
add them to a different device than the one they are on.
Possibly these could *be* the cairo_path_t structure. It would have it's
device-independent part and a device dependent part. I am unsure if the
cairo api will allow devices to allocate the cairo_path_t and add extra
information to the end however. One possible solution is to tack on a
hash id that devices can use to look up if they have encountered this
same cairo_path_t before and then get their cached versions.
More information about the cairo
mailing list