It is easier on the eye to use
'1 index set-source exch pop'
rather than
'dup /p0 exch def p0 set-source /p0 undef'
(as patterns are expected to be temporary so we strive to avoid naming
them).
After opening a specific file or fd for ourselves, reset the
CAIRO_TRACE_FD to point to an invalid fd in order to prevent any child
processes (who inherit our environment) from attempting to trace cairo
calls. If we allow them to continue, then the two traces will intermix
and be unreplayable.
Embed the pixels for images less than 32*32 as this catches most icons
which are frequently uploaded, but is still an unlikely size for a
destination image surface.
Using a null surface is a convenient method to measure the overhead of the
performance testing framework, so export it although as a test-surface so
that it will only be available in development builds and not pollute
distributed libraries.
python lazily loads libcairo.so and so it is not available via RTLD_NEXT,
and we need to dlopen cairo ourselves. Similarly the linker is not able to
resolve any naked function references and so we need to ensure that all of
our own calls into the library are wrapped with DLCALL.
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 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.
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.
Reparsing the dwarf info for every lookup is very slow, so cache the
symbol lookups. This initial implementation is unbounded in the simple
belief that the actual number of unique lookups during a program's
lifetime should be fairly small. (Extending to a bounded MRU list is left
as an exercise for the reader.)
A limitation of the current API was that the destroy notifier was called
on the mime-data block. This prevents the user from passing in a pointer
to a managed block, for example a mime-data block belonging to a
ref-counted object. We can overcome this by allowing the user to specify
the closure to be used with the destroy notifier.
set_font_face was not consuming it's operand but blithely placing an
undefined font_face onto the operand stack, whereas set_source was
performing invalid exchanges on the stack.
Use the surface user-data array allow to store an arbitrary set of
alternate image representations keyed by an interned string (which
ensures that it has a unique key in the user-visible namespace).
Update the API to mirror that of cairo_surface_set_user_data() [i.e.
return a status indicator] and switch internal users of the mime-data to
the public functions.
This tool can be used to trace all the cairo function calls made by an
applications. This is useful for either extracting a test case triggering
a bug from an application, or simply to get a general idea of how an
application is using cairo.
After make install, cairo-trace program arguments, will print out all the
cairo calls to the terminal and also capture theme in ./program.$pid.trace
The format of the output is CairoScript, watch this space for more
cairo-script tools!