As an aide to tiny swapless systems write the rarely used bytes that
define type42 fonts into a deleted file and mmap them back into our
address space.
csi_string_new() duplicated the bytes which was not what was desired, so
implement a csi_string_new_for_bytes() to take ownership and prevent the
leak that was occuring, for example, every time we create a new font face.
Seeing unexpected time inside pixman composite is quite disturbing when
trying to track down the apparent slowness in some benchmarks. Remove one
source of this artefact by simply memcpy'ing pixel data when trivial.
Objects like cairo_scaled_font_t may return a reference to a previously
defined scaled-font instead of creating a new token each time. This caused
cairo-trace to overflow its operand stack by pushing a new instance of the
old token every time. Modify the tracer such that a font token can only
appear once on the stack -- for font-faces we remove the old operand and
for scaled-fonts we simply pop, chosen to reflect expected usage.
Applications such as swfdec have a strictly correct use of mark-dirty and
so we need an option to re-enable mark-dirty tracing in conjunction with
--profile.
When using fonts circular references are established between the holdover
font caches and the interpreter which need manual intervention via
cairo_script_interpreter_finish() to break.
To save typing when creating macro-benchmarks --profile disables
mark-dirty and caller-info and compresses the trace using LZMA. Not for
computers short on memory!
The glyph advance cache was only enabled for glyph indices < 256,
causing a large number of misses for non-ASCII text. Improve this by
simply applying the modulus of the index to select the cache slot - which
may cause some glyph advances to be overwritten and re-queried, but
improves the hit rate.
Record the current working directory and pass that along to cairo-trace so
that the trace output is local to the user and not the application. This
is vital if the application is called via a script that changes directory.
Applications like firefox have a very conservative approach and mark
surfaces dirty before every render. As we record the image data every
time, firefox traces can grow very large with redundant data - so allow
the user to disable mark dirty tracing.
At Behdad's request, convert the array of allocators into a simple hash
table (large static number of buckets + chaining) in order to speed up
malloc profiling.
In order to have locale-independent output of decimal values, we need to
manually transform such numbers into strings. As this is a solved problem
for cairo, we adopt _cairo_output_stream_printf() and in particular the
_cairo_dtostr() routine for our own printf processing.
This interferes with the application being traced. It is not clear from
printf(3) whether "%.f" is locale dependent or not - but until we have a
failure do not break applications unnecessarily!
Handle the case of tracing an application that spawns it own graphical
children but using the autonaming facility within cairo-trace. Currently
the traced process tree would all attempt to write to the same file,
creating a broken trace. This means sacrificing the display of the output
name, but allows use for a wider range of applications.
Bah, the compiler failed to do its IPA correctly and wrongly complained
about potential use of uninitialised out-params guarded by the return
value. Silence them!