As discussed, overloading the cairo_surface_t semantics to include
sources (i.e. read-only surfaces) was duplicating the definition of
cairo_pattern_t. So rather than introduce a new surface type with
pattern semantics, start along the thorny road of extensible pattern
types.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
The existing API only described the method to be used for performing
rasterisation and unlike other API provided no opportunity for the user
to give a hint as to how to trade off performance against speed. So in
order to no be overly prescriptive, we extend the NONE/GRAY/SUBPIXEL
methods with FAST/GOOD/BEST hints and leave the backend to decide how
best to achieve those goals.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
The mime surface is a user-callback surface designed for interfacing
cairo with an opaque data source. For instance, in a web browser, the
incoming page may be laid out and rendered to a recording surface before
all the image data has finished being downloaded. In this circumstance
we need to pass a place holder to cairo and to supply the image data
later upon demand.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
It is convenient if the user can simply enable the use of the commented
write-to-png operation just by removing the preceding '%'. However, to
do so we need to make sure that the line is stack-neutral and so need to
pop the surface that we place onto the stack after writing the png.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This patch has been generated by the following Coccinelle semantic patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it
@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free(E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
- free (E);
- }
Currently we only emit the format, but if you want to later convert
the images to a normal surface for replay it is handy to have the
content.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
A common requirement is the fast upload of pixel data. In order to
allocate the most appropriate image buffer, we need knowledge of the
destination. The most obvious example is that we could use a
shared-memory region for the image to avoid the transfer cost of
uploading the pixels to the X server. Similarly, gl, win32, quartz...
The other side of the equation is that for manual modification of a
remote surface, it would be more efficient if we can create a similar
image to reduce the transfer costs. This strategy is already followed
for the destination fallbacks and this merely exposes the same
capability for the application fallbacks.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
During replay we want to handle recording surfaces specially, and not
redirect the creation of those to the target surface. This is similar to
the need to keep image surfaces as images during replay.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
cairo-xcb's acquire_source_image implementation will attach the image it returns
as a snapshot to the xcb surface. cairo_surface_mark_dirty_rectangle asserts
that the surface doesn't have any snapshots attached. cairo-trace will emit the
surface to the trace when it was marked dirty by drawing it to an image surface.
The combination of these three things caused a failed assertion when cairo-trace
was used on something which uses xcb/Xlib and which uses mark_dirty.
I found this with firefox and xlib-xcb.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Fixes all warnings that looked like this:
warning: enumeration value 'CAIRO_STATUS_DEVICE_FINISHED' not handled in switch
Signed-off-by: Uli Schlachter <psychon@znc.in>
This is a common format used by framebuffers to drive 10bpc displays
and is often hardware accelerated by XRender with underlying support
from pixman's x2r10g10b10 format (which provides coercion paths for
fallbacks).
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
By emitting an empty function name when it it impossible to perform
the lookup, we can get rid of the warning:
trace.c:3714: warning: unused variable ‘symbol’
Additionally, this makes the syntax (or, rather, the parameter count)
for write-to-png-stream the same on every configuration.
Compiler warning saves the day!
trace.c: In function ‘_emit_font_options’:
trace.c:2973:20: warning: comparison between ‘cairo_hint_style_t’ and
‘enum _cairo_hint_metrics’
A genuine bug, thanks gcc!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Add the mesh pattern type and an error status to be used to report an
incorrect construction of the pattern.
Update the backends to make them ready to handle the new pattern type,
even if it cannot be created yet.
Use two levels of pthread support: a minimal level used to
build cairo itself, and a full level to build threaded apps
which want to use cairo. The minimal level tries to use
pthread stubs from libc if possible, but falls back to the
full level if that's not possible. We use CFLAGS=-D_REENTRANT
LIBS=-lpthread to find a real pthread library since that seems
to work on every unix-like test box we can get our hands on.
What we want to use is size_t, but we don't want the implied POSIX
dependency. However, POSIX does say that size_t is an unsigned integer
that is no longer than a long, so it would appear safe to use an
unsigned long as a replacement. Safer at least than unsigned int.
After a renewed discussion, it was pointed out that the API in Cairo was
not restrictive and by using doubles we would be consisted with the rest
of the API. Thus prompting the name change to
cairo_surface_create_for_rectangle()
similar to cairo_rectangle().
And document the public API.
trace.c:1154: warning: ‘_has_font_face_id’ defined but not used
trace.c:1196: warning: ‘_get_pattern_id’ defined but not used
trace.c:1870: warning: ‘_emit_font_face’ defined but not used
trace.c:1882: warning: ‘_emit_scaled_font’ defined but not used
Trace files were using host-endian to represent the length of
compressed data, making the trace format not portable.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
We were exposing the actual value of CAIRO_FORMAT_INVALID
through API functions already, so it makes sense to just
go ahead and put it in the cairo_format_t enum.
The device is a generic method for accessing the underlying interface
with the native graphics subsystem, typically the X connection or
perhaps the GL context. By exposing a cairo_device_t on a surface and
its various methods we enable finer control over interoperability with
external interactions of the device by applications. The use case in
mind is, for example, a multi-threaded gstreamer which needs to serialise
its own direct access to the device along with Cairo's across many
threads.
Secondly, the cairo_device_t is a unifying API for the mismash of
backend specific methods for controlling creation of surfaces with
explicit devices and a convenient hook for debugging and introspection.
The principal components of the API are the memory management of:
cairo_device_reference(),
cairo_device_finish() and
cairo_device_destroy();
along with a pair of routines for serialising interaction:
cairo_device_acquire() and
cairo_device_release()
and a method to flush any outstanding accesses:
cairo_device_flush().
The device for a particular surface may be retrieved using:
cairo_surface_get_device().
The device returned is owned by the surface.
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.
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.
On OpenBSD the convention is to not use symlinks from
unversioned library names to versioned library names.
This breaks cairo-trace because it looks for cairo-trace.so
explicitly, but on OpenBSD only cairo-trace.so.0.0 is
installed.
The right thing to do is probably to source the cairo-trace.la
file and look for a file name there somehow. Instead this commit
just looks for a likely looking file or symlink in the install
directory.
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.
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.
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.
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.