Commit graph

80 commits

Author SHA1 Message Date
Andrea Canciani
21560b3ec6 [trace] Fix compilation when FreeType is disabled
cairo-trace needs some headers which are missing if freetype is
not enabled. Adding them explicitly fixes compilation.
2009-12-30 14:08:38 +01:00
Andrea Canciani
1ce096657b Fix compilation on MacOS X
Enable "ld_preload" (DYLD_INSERT_LIBRARIES + DYLD_FORCE_FLAT_NAMESPACE)
and build cairo-trace as a library instead of a module to make it
work also on MacOS X.
2009-11-09 16:59:31 +00:00
M Joonas Pihlaja
43a775f60d [meta] Rename cairo_meta_surface_t to cairo_recording_surface_t.
The new name is more descriptive than the rather opaque meta surface.
Discussed with vigour on the mailing list and #cairo:

http://lists.cairographics.org/archives/cairo/2009-July/017571.html
2009-10-22 02:29:47 +03:00
Benjamin Otte
6809e12161 [API] Make _cairo_meta_surface_replay() private again
Replaying a meta surface can be achieved by using it as a source for a
cairo_paint() so exporting a separate API is unnecesary and confusing.
So after consulting Chris and Carl, we decided to remove the function
again.
2009-09-30 08:58:19 +02:00
M Joonas Pihlaja
4152cd90e2 [autoconf] Comment on the SIZEOF_VOID__ -> SIZEOF_VOID_P workaround.
Explain where the weird SIZEOF_VOID__ comes from.
2009-09-14 14:29:01 +03:00
M Joonas Pihlaja
a343c8c42d [trace] Don't use pthread_key_delete.
On OpenBSD libc doesn't provide pthread stubs like glibc on Linux
or newer libcs from FreeBSD.  However libX11 does provide a stubs
for a subset of the pthread functions (formerly in libXThrStub,
now moved into libX11 proper), but pthread_key_delete() is not
one of the stubbed ones.  So, on OpenBSD cairo's non-linking of
libpthread accidentally works as long as the xlib-surface is enabled,
which is nearly always the case.

This patch makes trace.c stand at the same precipice as cairo itself
by reverting to only a subset of the pthreads functions stubbed by
libX11.
2009-09-14 13:32:18 +03:00
M Joonas Pihlaja
1c7ac6c47a [build] Work around autoconf void* -> VOID__ name conversion bug.
The autoconf shipping with OpenBSD 4.5 converts sizeof(void*)
to SIZEOF_VOID__ rather than SIZEOF_VOID_P.  Work around that
by defining SIZEOF_VOID_P if required.
2009-09-14 13:32:18 +03:00
M Joonas Pihlaja
ba21f21356 [trace] Don't trace internal cairo calls on Solaris.
On various configurations of Solaris cairo-trace likes to trace
internal calls to the API from within cairo and cairo-trace itself. On
Linux the slim_hidden_proto stuff avoids this by name mangling and
symbol alias magic, but on Solaris that doesn't work so we're left
with either no hidden symbols at all or using normal ELF hidden symbol
attributes, but neither of those prevent internal calls to cairo from
being traced of course.

This commit provides a per-thread entry/exit trace counter for use
when we can't use name mangling to hide internal API calls.  As a
side-effect it may hide actual client API calls from callback
functions called by cairo, but such use cases ought to be rare.
2009-09-13 20:33:33 +03:00
M Joonas Pihlaja
2fb59a69f4 [trace] Don't rely on the constructor attribute to initialise the tracer.
Use pthread_once() at cairo API entry points to initialise the library
if required.  This side steps the issues with the __constructor__
attribute vs _init()/_fini() on Solaris and different tracer/tracee
runtimes which result in the constructors not being run in
cairo-trace.so.
2009-09-13 20:30:04 +03:00
M Joonas Pihlaja
18a441984b [trace] Don't try and propagate a void result.
The pattern

	return <function returning void>( ... );

is a gccism not supported by Sun Studio.
2009-09-13 20:27:41 +03:00
M Joonas Pihlaja
fee5c58c6c [trace] Avoid warnings from assigning a void pointer to a function pointer.
The Sun Studio compiler complains a *lot* when assigning the result
of dlsym to a function pointer.  Cast the result to the proper
type first.:w
2009-09-13 20:27:41 +03:00
Chris Wilson
f8a8f297f2 [trace] Stray trailing ';' in bswap macros 2009-09-13 10:58:59 +01:00
Chris Wilson
f851009ec7 [trace] Compile without lookup-symbol
And check compilation with --disable-symbol-lookup
2009-09-13 10:57:42 +01:00
M Joonas Pihlaja
b509b548b1 [trace] Check for __builtin_return_address explicitly.
Some other compilers such as clang and icc support the
__builtin_return_address() intrinsic as well, so we don't
need to check for __GNUC__ >= 3 only.
2009-09-02 04:50:21 +01:00
M Joonas Pihlaja
2b0e070f6a [trace] Replace an open coded test for matrix identity.
The code has a _matrix_is_identity() function we can use
instead of open coding the same test.
2009-09-02 04:50:21 +01:00
M Joonas Pihlaja
70ea9e3ce1 [trace] Don't crash on unknown enums values.
If the tracer encounters an unknown enum value it
ought not to crash. Theis patch replaces the idiom
of looking up a name for an enumerated value directly
from a table by a switch statement. As a bonus we get
warnings from the compiler when the enums are updated
in cairo.
2009-09-02 04:50:20 +01:00
M Joonas Pihlaja
174c2620c8 [trace] Check for object stack underflow.
If the tracer's object stack underflows we want to
know about is as soon as possible. This patch adds
checks against the stack overflowing and aborts the
program with an object stack dump if it does.
2009-09-02 04:50:20 +01:00
M Joonas Pihlaja
c64f6f8a15 [trace] Get the tracee program name from the environment.
Support non-Linux systems which don't have a /proc/self/cmdline
by transferring the application name given to cairo-trace via
an environment variable CAIRO_TRACE_PROG_NAME.
2009-09-02 04:42:07 +01:00
M Joonas Pihlaja
9bb469c51c [trace] Use HAVE_FLOCKFILE/FUNLOCKFILE since configure test for them.
The trace source was using the flockfile() and funlockfile()
functions directly.
2009-08-31 16:06:50 +03:00
Chris Wilson
8d1bf830c0 Fix errors found by clang
Shadowed variables, unused writes and some dead code.
2009-08-29 08:08:39 +01:00
Chris Wilson
7306305cc8 [script] Emit surface content
Include the desired content with the creation info.
2009-08-29 08:08:37 +01:00
Chris Wilson
a9d997fecd [script] Introduce cairo_script_context_t
cairo_script_context_t is an encapsulation object for interfacing with the
output - multiple surfaces can share the same context, meaning that they
write to the same destination file/stream.
2009-08-29 08:08:36 +01:00
Chris Wilson
28887ac272 [trace] Fix emission of similar (track operands) 2009-08-29 08:08:36 +01:00
Chris Wilson
50c7d637f3 [trace] Emit an 'index' for an undefined surface
Larry Ewing hit a bug in cairo-trace whereby it tried to create a similar
surface referencing an undefined object. This fix checks whether the
object has yet to be defined, and if not issues an index in order to copy
the appropriate operand from the stack.
2009-08-29 08:08:36 +01:00
Chris Wilson
b7639a5f79 [trace] Close the dictionary before font
font expects the dictionary to be constructed on the stack for its use, so
close it. (I missed the closing '>>' when switching between dictionary
constructors.)
2009-08-06 10:55:18 +01:00
Chris Wilson
ee69f8aa5e [trace] Whitespace
A few gratuitous whitespace and increase the buffer size used whilst
reading in data files.
2009-08-06 10:30:52 +01:00
Chris Wilson
6d30021d65 [trace] Only write the 4 byte length to the stream
We were attempting to write out the whole length of the block when we were
just trying to write out the length value.
2009-08-06 10:29:49 +01:00
Chris Wilson
bed2701e1c Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)

In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.

Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:

ppc:
Speedups
========
image-rgba         evolution-20090607-0    1026085.22 0.18% -> 672972.07 0.77%:  1.52x speedup
▌
image-rgba         evolution-20090618-0    680579.98 0.12% -> 573237.66  0.16%:  1.19x speedup
▎
image-rgba      swfdec-fill-rate-4xaa-0    460296.92 0.36% -> 407464.63  0.42%:  1.13x speedup
▏
image-rgba      swfdec-fill-rate-2xaa-0    128431.95 0.47% -> 115051.86  0.42%:  1.12x speedup
▏
Slowdowns
=========
image-rgba     firefox-periodic-table-0    56837.61 0.78% -> 66055.17    3.20%:  1.09x slowdown
▏
2009-07-23 15:32:14 +01:00
Chris Wilson
52fa8760ae Add OpenVG backend.
Based on the work by Øyvind Kolås and Pierre Tardy -- many thanks to
Pierre for pushing this backend for inclusion as well as testing and
reviewing my initial patch. And many more thanks to pippin for writing the
backend in the first place!

Hacked and chopped by myself into a suitable basis for a backend. Quite a
few issues remain open, but would seem to be ready for testing on suitable
hardware.
2009-07-17 11:50:02 +01:00
Chris Wilson
710308c64e [script] Extended blend mode support. 2009-07-14 16:31:41 +01:00
Chris Wilson
ee8c50f2d6 Remove the defunct test-meta surface
Replace the internal test-meta surface will the freshly exported,
real meta-surface.
2009-07-04 22:00:09 +01:00
Chris Wilson
f4019be7bd [trace] Remove a few transient pattern def/undef
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).
2009-07-04 13:16:42 +01:00
Chris Wilson
963664727b [trace] Compile fix for --enable-script
Silly typo as pointed out by Hans Breuer <hans@breuer.org>.
2009-06-28 10:49:37 +01:00
M Joonas Pihlaja
1b6dbcbbeb [trace] Compile without fontconfig.
Use CAIRO_HAS_FC_FONT to decide whether to export
cairo_ft_font_face_create_for_pattern() or not.
2009-06-19 19:01:14 +03:00
Chris Wilson
84e587bbfa [trace] Prevent a child process from writing to the same file
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.
2009-06-19 14:41:39 +01:00
Chris Wilson
030ef4ca00 [trace] Change the threshold at which pixel data is immediately copied
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.
2009-06-19 11:56:14 +01:00
Chris Wilson
e5727e20f5 Expose _cairo_null_surface_create() via a test 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.
2009-06-15 12:03:37 +01:00
Chris Wilson
c52eed6680 [trace] Handle wrapping python
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.
2009-06-13 15:42:43 +01:00
Chris Wilson
015df191ba [trace] Prevent overflowing the operand stack when recreating objects
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.
2009-06-08 17:40:16 +01:00
Chris Wilson
a76e09ea65 [trace] Missing newlines in error messages. 2009-05-25 22:14:56 +01:00
Chris Wilson
9099c7e730 [trace] Disable mark dirty tracing.
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.
2009-03-04 09:26:17 +00:00
Chris Wilson
6b5d2bf1a7 [trace] Comment out the redundant wrapping of FT_Open_Face()
Remove the left-over debugging spew, but leave a comment to hopefully
clarify the situation with wrapping FT_Open_Face().
2009-01-29 10:10:40 +00:00
Carl Worth
faa004033c cairo-trace: Print name of trace file.
It's just a lot easier to use cairo-trace if it tells you
what file it just created.
2009-01-29 10:10:40 +00:00
Chris Wilson
a023104400 [trace] Adopt _cairo_dtostr
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.
2009-01-02 10:36:52 +00:00
Chris Wilson
ecb8dce27c [script] Recreate surface content.
Use the content recorded in the trace, defaulting to COLOR_ALPHA, to
determine the replayed surface type.
2009-01-02 09:53:24 +00:00
Chris Wilson
d21529b9ef [trace] Correct escaped characters in string literal.
Laziness caused the control character to be used instead of its
replacement in the escaped string!
2009-01-02 09:53:24 +00:00
Chris Wilson
ca39c4bf7f [trace] Correct a couple of typos.
A couple of minor typos in the escaped characters strings.
2009-01-02 09:53:24 +00:00
Chris Wilson
1f2fec7388 [trace] Fix OBO in emit_glyphs()
The largest index that will fit within 8 bits is 255 not 256!
2009-01-02 09:53:23 +00:00
Chris Wilson
7ebe9e6837 [trace] Minor tidy.
Improve scoping of variables.
2009-01-02 09:53:22 +00:00
Chris Wilson
9b46d13b6c [trace] Runtime version check.
Check that the application is using cairo >= 1.9 before attempting to
query the mime-data.
2008-12-18 10:40:13 +00:00