[cairo] Extending Cairo API to support reusable paths

Matt Woodrow matt.woodrow at gmail.com
Mon Apr 19 20:58:14 PDT 2010


Hi

Just as a follow up to this, I've more or less finished the cairo 
changes including a backend implementation for quartz.

Currently I'm getting around a 5% speed increase on Quartz (which 
doesn't appear to do any optimization of the stored path object)
and hoping for considerably more on the D2D backend once it's completed.

Probably the biggest thing of interest would be the following additions 
to cairo_surface_backend_t:

     /*
      * Retained Path Operations
      */

     /*
      * Creates a backend specific path object from the current path data
      */
     const void *
     (*build_path_object)    (cairo_path_fixed_t     *path,
                  cairo_gstate_t         *gstate);
     /*
      * Converts the current backend specific path object into cairo path
      * data and appends it to the cairo fixed path.
      *
      * Frees and clears the current retained path object from the path.
      */
     void
     (*path_object_extract_data) (cairo_path_fixed_t     *path,
                  cairo_gstate_t         *gstate);

     /*
      * Releases the backend specific path object's memory or
      * reduces its reference count.
      */
     void
     (*free_path_object)     (const void         *object);

     /*
      * Creates an identical copy of a backend specific path
      * object. Since path objects are immutable this can be
      * implemented as a reference count increase.
      */
     const void *
     (*copy_path_object)     (const void         *object);

Once again, full details of everything are available in the mozilla bug 
report:

https://bugzilla.mozilla.org/show_bug.cgi?id=555877


Would love to hear any suggestions regarding this.

Thanks again

Matt Woodrow

On 31/03/10 8:28 PM, Benjamin Otte wrote:
> Hey, cool to see someone working on this again.
> I've wanted to have something like this since I started hacking on
> Swfdec a few years ago - it always seemed so wasteful to retesselate on
> every draw operation.
> It just turned out to be really hard to get this machinery right and a
> lot of people had different ideas, so it never moved anywhere.
>
> Also, my idea has always been to call this cairo_shape_t instead of your
> cairo_retained_path_t. Does that make sense?
>
>
> Some questions: What's the scope of this retained path object? Is it
> supposed to be bound to a cairo_t or even a specific matrix or can I use
> the same object in multiple different places?
>
> Which leads to the question if there should be constructors like
> cairo_shape_t *cairo_shape_create (cairo_path_t *path);
>
> Also, what use cases do you guys have in mind for this API? I suspect
> you want to use it as an object to represent SVG paths? Do you intend to
> use it for custom font handling, too? Anything else?
>
> I'm really excited to see this moving again.
>
> Benjamin
>
>
> On Wed, 2010-03-31 at 09:50 +1300, 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.
>>
>> The API changes I am proposing are:
>>
>> /* New cairo API */
>> typedef struct _cairo_retained_path cairo_retained_path_t;
>>
>> cairo_public cairo_retained_path_t *
>> cairo_copy_retained_path(cairo_t *cr);
>>
>> cairo_public void
>> cairo_append_retained_path(cairo_t *cr, cairo_retained_path_t *path);
>>
>> cairo_public void
>> cairo_retained_path_destroy(cairo_retained_path_t *path);
>>
>>
>> Does anyone have any thoughts, questions or suggestions on this?
>>
>> The Mozilla bug for this is at
>> https://bugzilla.mozilla.org/show_bug.cgi?id=555877
>>
>> Thanks
>>
>> Matt Woodrow
>> --
>> cairo mailing list
>> cairo at cairographics.org
>> http://lists.cairographics.org/mailman/listinfo/cairo
>>      
>
>
>    


More information about the cairo mailing list