[cairo] _cairo_pattern_create_copy()

Chris Wilson chris at chris-wilson.co.uk
Thu May 1 06:45:21 PDT 2008

A few months ago, Adrian Johnson committed this patch:
commit b4e0864b960887fd71de85d514cb3e855c276080
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Jan 7 20:42:15 2008 +1030

    Use _cairo_pattern_create_copy() in cairo-surface.c
    Use _cairo_pattern_create_copy()/cairo_pattern_destroy() instead of
    _cairo_pattern_init_copy()/_cairo_pattern_fini() so the PDF backend
    can reference the patterns and destroy them later.

Profiling memory allocations for firefox3 whilst loading and scrolling
through the sites listed on http://wiki.mozilla.org/Mozilla2:Trender, we
Allocator					Count	Bytes
_cairo_pattern_create_copy			583303	80412256
_cairo_skip_list_insert *			566032	12425880
_cairo_freelist_alloc *				341702	2788704
_cairo_gstate_clone				275247	99088920
_cairo_array_grow_by				248526	1988208
_cairo_region_get_boxes				197682	4867120
_cairo_xlib_surface_create_internal		174801	68521992
_cairo_bo_event_queue_init *			149475	90881712
cairo_create					139520	126126080
_cairo_pen_init_copy				112085	22154640
* tessellator

I would like to push the _cairo_pattern_create_copy() down into the PDF
backend - I hesitate in case I've missed some subtlety in the
interactions of the various paginated/meta/pdf layers that requires a
reference rather than a copy. (And someone needs to review the use of
cairo_pattern_reference within the Quartz backend.) Whilst discussing
the pattern copy, can we eliminate the copy entirely (other than when a
snapshot is required) by tracking the pattern transform separately? If
we can reuse the same pattern multiple times, then it becomes
interesting to see what we can cache, or what resources we can minimise.
Chris Wilson

More information about the cairo mailing list