Commit graph

5881 commits

Author SHA1 Message Date
Uli Schlachter
508990af8d xcb: Don't use xcb surfaces as snapshots
Eventually someone might try to paint to the xcb surface again. However,
_cairo_surface_begin_modification doesn't like that:

cairo-surface.c:385: _cairo_surface_begin_modification: Assertion
`surface->snapshot_of == ((void *)0)' failed.

There was only a single place in the xcb backend where a cairo_xcb_surface_t
could be used as a snapshot, so the _cairo_surface_has_snapshot that checked for
such a surface can be removed, too.

This does *not* remove all snapshots from the xcb backend, but all the remaining
snapshots are instances of cairo_xcb_picture_t. These surfaces are only ever
created internally and thus can't be modified by users directly.

Fixes: xcb-snapshot-assert

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
4153de4689 xcb: Track cairo_xcb_picture_t surfaces
When e.g. using an image surface as the source for a xcb surface, a
cairo_xcb_picture_t is created and attached to that image surface as a snapshot.
This contains the Picture that was created on the X11 server.

However, as soon as the cairo_xcb_picture_t's cairo_xcb_screen_t is finished and
destroyed, this picture can't be used anymore. This commit now makes sure all
these Pictures are freed when the screen is finished.

This was found because my X server's memory usage grew quite large. Every time
the app was done drawing, it destroyed its last surface which also destroyed the
last reference to the cairo_xcb_screen_t. This meant that the existing Picture
snapshots couldn't be used anymore, but they were still kept around and used up
memory until there wasn't any free memory left.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
e775db35d9 xcb: Move cairo_xcb_picture_t to cairo-xcb-private.h
The next commit will make cairo-xcb-screen.c use this struct and add new
members. Splitting off the move into its own commits makes that easier to
understand.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Uli Schlachter
5b9205cc52 xlib-xcb: Register a XCloseDisplay hook
This commits makes the xlib-xcb backend produce its own cairo_device_t. This
per-Display* device is used to manage the registration of a XCloseDisplay hook
via XAddExtension/XESetCloseDisplay in the same way that the xlib backend does
this. The device is necessary to see if we already registered an extension.

This fixes weird errors when running cairo-test-suite with -a -s. They were
caused because the backend didn't see the XCloseDisplay and the next
XOpenDisplay happened to create a xcb_connection_t with the same address as the
last display. This caused the xcb backend to assume lots of wrongness.

This commit makes use of _cairo_xlib_display_mutex which is otherwise compiled
in but not used anywhere when xlib-xcb is enabled.

Patch v2: Fixed the xcb_device == NULL case and made sure the xcb_device is only
finished on XCloseDisplay, not when all xlib-xcb surfaces are destroyed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-09 09:42:22 +02:00
Andrea Canciani
05a0b24ecb device: Fix documentation of device types
The documentation of device types incorrectly talks about surfaces and
lacks the new INVALID type.
2011-07-08 11:26:45 +02:00
Andrea Canciani
02a331de13 device: Define the CAIRO_DEVICE_TYPE_INVALID device type
Define a new device type to indicate that the device is not valid.
The -1 value is along the same line as CAIRO_FORMAT_INVALID (and is
likely to have the same issues).
2011-07-08 11:26:45 +02:00
Andrea Canciani
35d8d20635 device: Add CAIRO_STATUS_DEVICE_FINISHED
Instead of abusing CAIRO_STATUS_SURFACE_FINISHED to indicate the use
of a finished device, define and use the new error status
CAIRO_STATUS_DEVICE_FINISHED.
2011-07-08 11:26:45 +02:00
Andrea Canciani
780534cd31 gstate: Remove useless code
gstate->source has been initialized as the static black pattern, so
its status is success.
2011-07-08 11:26:38 +02:00
Andrea Canciani
4679b28e21 color: Remove unused functions
_cairo_color_init() and _cairo_color_init_rgb() are basically unused
(except in some experimantal code, which is trivial to fix).
2011-07-08 11:14:16 +02:00
Andrea Canciani
9374cf0a97 pattern: Implement _rgb functions as wrappers over _rgba functions
cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb()
implement the same logic as cairo_pattern_create_rgba() and
cairo_pattern_add_color_stop_rgba() with an alpha == 1.0.

Instead of duplicating the code, they can simply call into the more
general functions.
2011-07-08 11:14:16 +02:00
Andrea Canciani
d7cc30eb01 Make error contexts static
Dynamically creating error contexts requires locking and failure
handling. The code logic can be simplified by statically defining all
the possible error contexts.
2011-07-05 10:00:14 +02:00
Andrea Canciani
ef659649d3 Clean up context_pool upon static data reset
In commit f46ba56d5b the static context
stash was replaced by a dynamic freed pool, which needs to be cleared
upon resets.

Fixes:
cairo.c:181: warning: ‘context_pool’ defined but not used

Reported-by: Uli Schlachter <psychon@znc.in>
2011-07-05 10:00:14 +02:00
Andrea Canciani
fe3ca9c36f Remove conditional compilation of freed-pools
Conditional compilation was needed to avoid warnings:
cairo-clip.c:51: warning: ‘clip_path_pool’ defined but not used
cairo.c:181: warning: ‘context_pool’ defined but not used

They can be avoided by making sure that _freed_pool_reset(ptr)
actually consumes its argument. This has the pleasant side-effect that
forgetting to properly reset a freed-pool now results in a warning if
atomic ops are disabled/not available.
2011-07-05 10:00:13 +02:00
Uli Schlachter
eea31cc4ee xlib-xcb: Don't call directly into the xcb backend
Instead, this now uses the surface wrapper functions for this job.
These functions make sure that e.g. snapshots are detached and that is_clear is
reset correctly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 23:11:48 +02:00
Uli Schlachter
9e4c73a40d xlib-xcb: Fix some use-after-free
Also, this now sets surface->xcb to NULL after the dereference. Segfaults are
way more prominent anyway. :-)

All the backend callbacks shouldn't need any checks since the public entry point
already checks for finished surfaces. Only the public functions in xlib-xcb need
to do checks for finished surfaces.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 23:00:24 +02:00
Uli Schlachter
880566e14b xcb: Remove an unused function argument
Since commit f1d313e0, the 'force' argument to _copy_to_picture() isn't used
anymore. Said commit should have removed it. Whoops.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-02 17:40:36 +02:00
Uli Schlachter
7e1a9f1db0 xlib-xcb: Fix cairo_surface_flush()
This function called directly into the xcb's surface flush function. This means
that snapshots for that surface weren't detached since that's normally done in
cairo_surface_flush() before calling into the backend.

Fix this by using surface_flush() instead of calling into the backend directly.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=31931

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 21:58:42 +02:00
Uli Schlachter
26ee41435b xlib-xcb: Verify we really have an xcb surface
If the X11 server doesn't have the RENDER extension, the xcb backend falls back
to the image backend in some cases (e.g. create_similar). xlib-xcb didn't handle
this properly which means it used the result like a xcb surface.

Found while debugging https://bugs.freedesktop.org/show_bug.cgi?id=31931,
firefox died from a BadDrawable error when it tried to use the (bogous) result
from cairo_xlib_surface_get_drawable().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 18:53:18 +02:00
Uli Schlachter
59fadcf7d9 xlib-xcb: Fix api-special-cases test
The functions cairo_xlib_surface_set_size and cairo_xlib_surface_set_drawable
didn't set the expected error when called with a finished surface.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 10:26:28 +02:00
Uli Schlachter
4495e08e9e xlib-xcb: Use slim_hidden_proto correctly
There are debug functions for setting the precision on a xlib device, so
xlib-xcb must redirect that to the xcb backend, too. However this means that
these public functions now are also called internally, thus we have to make them
go through the slim_hidden_* macros.

This commit fixes the following error from "make check":

Checking .libs/libcairo.so for local PLT entries
00000000002bb6d8  000001e300000007 R_X86_64_JUMP_SLOT     000000000006d8a0 cairo_xcb_device_debug_set_precision + 0
00000000002bb750  0000025e00000007 R_X86_64_JUMP_SLOT     000000000006d8b0 cairo_xcb_device_debug_get_precision + 0
FAIL: check-plt.sh

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-07-01 10:15:46 +02:00
Søren Sandmann Pedersen
ea645913ba Include pixman.h in cairo-xlib-private.h
Otherwise "make cairo-perf-trace" fails. Reported by Matt Turner on
IRC.
2011-06-27 23:12:51 -04:00
Chris Wilson
8996287d94 xlib: Create an exact match for the image surface if possible using Xrender
In order to defer the pixel conversion till as late in the pipeline as
possible, we want to try and preserve the pixman image format whilst
uploading the pixel data. To do this, we want to create an XRender
surface with a matching PictFormat to the source image. Then we need to
make sure we take the quick path through _draw_image_surface for none
and direct conversions.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-06-25 20:15:18 +01:00
Andrea Canciani
f46ba56d5b Do not open-code freed-pool
Reuse the freed-pool system to reduce allocation pressure of context
creation/destruction.

As a side effect, this removes the use of ffs() on Win32, cleaning up
some MSVC-specific code and fixing a mingw-related build issue.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=30277
2011-06-25 15:35:48 +02:00
Andrea Canciani
a468489270 win32: Fallback upon PDF blend operators
GDI does not support PDF blend modes, so they are implemented by
falling back.

Fixes extended-blend-solid, extended-blend-solid-alpha.

Bug pointed out by Peter Frentrup <peter_frentrup@gmx.de> in
http://lists.cairographics.org/archives/cairo/2011-April/021908.html
2011-06-25 10:19:36 +02:00
Andrea Canciani
a447e94979 clip: Fix boxes extents computation in intersect_with_boxes
The extents of the boxes were being computed by taking into account
just the first box instead of all of them.

Based on a patch by James Cloos.

Fixes clip-disjoint, clip-stroke-unbounded, clip-fill-nz-unbounded,
clip-fill-eo-unbounded, clip-fill, clip-stroke, trap-clip.

See https://bugs.freedesktop.org/show_bug.cgi?id=38641

Reviewed-by: James Cloos <cloos@jhcloos.com>
Tested-by: James Cloos <cloos@jhcloos.com>
2011-06-25 10:19:36 +02:00
Nis Martensen
1a4e9f1e91 Fix typos
Reported in
http://lists.cairographics.org/archives/cairo/2011-May/021921.html
2011-06-25 10:19:23 +02:00
Uli Schlachter
77b6563c21 xcb: Use defines instead of magic numbers
render.h gives us nice descriptive names for the precise/imprecise poly modes.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-24 15:59:08 +02:00
Uli Schlachter
144c912860 xcb: Initialize the new precision fields
In 63bdae27a8, new fields were added to cairo_xcb_connection_t and
cairo_xcb_surface_t. The same change was done in the xlib backend.

However, in the xlib backend these new fields were properly initialized. This
was forgotten in the xcb backend.

Hopefully-Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=38482

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-24 15:52:59 +02:00
Uli Schlachter
d246d97592 xcb: Prettify some code
Instead of having each case do the same thing, this code will now fall through
to the default case.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-24 15:24:09 +02:00
Uli Schlachter
cb3d91201c xcb: Don't hardcode the RENDER version number
This now uses the macros XCB_RENDER_{MAJOR,MINOR}_VERSION which xcb defines.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-24 15:24:09 +02:00
Uli Schlachter
d938e74446 xcb,xlib,surface: Check for too small sizes
This adds checks for negative sizes in cairo_surface_create_similar() and for
non-positive sizes in all public surface-creation functions in the xcb and xlib
backends.

X11 doesn't allow 0 as width/height, so if anyone claims to have a drawable of
that size, he can't be right. However, cairo allows such sizes which is why
create_similar doesn't reject 0.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-24 15:24:09 +02:00
Andrea Canciani
f21ac5b13b error: Do not define _cairo_error twice
cairo-perf-trace uses cairo-hash.c, which calls _cairo_error.

Instead of redefining it in cairo-perf-trace.c it can be abstracted in
a separate source which is directly included in the build of
cairo-perf-trace.

This avoids visibility issues when compiling cairo-perf-trace with a
statically linked cairo library on architectures which do not support
hidden visibility (example: win32).
2011-06-24 11:57:22 +02:00
Andrea Canciani
0740c8e4f3 Hide private symbols on MacOSX
gcc provides the hidden visibility attribute on Darwin, which can be
used to deny access to private cairo symbols.
2011-06-24 11:57:07 +02:00
Taekyun Kim
441f9c5037 Fix intersect_with_boxes() to produce tight clip extents
Previous code was intersecting extents with infinitely large rectangle.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-06-21 09:59:30 +01:00
Andrea Canciani
b6d593dc71 build: Clean up environment variables and flags for the win32 build
Avoid ovverriding LINK, as it has a special meaning for the MSVC build
tools.
2011-06-20 10:24:21 +02:00
Andrea Canciani
101fab7cd8 win32-font: Improve static data reset function
The hashtable is guaranteed to only contain font faces which are
currently referenced, hence there is no need to remove any font face
when it is reset (just like for toy-font).

This makes the function simpler and fixes the assertion

Assertion failed: predicate != NULL, file cairo-hash.c, line 373

hit by multiple tests (the first one being "clear").

See https://bugs.freedesktop.org/show_bug.cgi?id=38049
2011-06-20 10:24:21 +02:00
Andrea Canciani
94bc20da50 win32-font: Implement destroy function
Win32 font faces can be removed from the hashtable upon destruction.
Based on the toy-font destruction code.

See https://bugs.freedesktop.org/show_bug.cgi?id=38049
2011-06-20 10:24:20 +02:00
Andrea Canciani
94b14c929d win32-font: Do not return font in error status
If the hashtable cointains a font matching the font being created,
only reuse it if it is not in an error status. Otherwise, remove it
from teh hashtable and create a new one.
2011-06-20 10:24:20 +02:00
Andrea Canciani
b9d9ca281c Avoid deprecated functions on win32
Some POSIX functions are deprecated in MSVC and should instead be used
with an alternative name beginning with '_'.
2011-06-20 10:24:20 +02:00
Andrea Canciani
cbf11fa261 toy-font: Do not open-code cairo_font_face_reference ()
Since 03be41151d, it is safe to use
cairo_font_face_reference () to increment the reference count of a
font taken from the hashtable, because no mutex is being locked twice.
2011-06-20 10:24:20 +02:00
Andrea Canciani
5a79e9f536 script: Return status when flushing device
Since 92d7b1eee9 the flush vfunction
should return a cairo_status_t.

Silences the warning:

cairo-script-surface.c: At top level:
cairo-script-surface.c:3528:5: warning: initialization from
incompatible pointer type [enabled by default]
cairo-script-surface.c:3528:5: warning: (near initialization for
'_cairo_script_device_backend.flush') [enabled by default]
2011-06-20 09:44:49 +02:00
Andrea Canciani
ced061124d xlib-xcb: Implement cairo_xlib_device_debug_{g,s}et_precision
63bdae27a8 introduced a new public API
cairo_xlib_device_debug_set_precision(), exported by cairo-xlib.
cairo-xlib-xcb must implement it as well, because it must provide the
same public API.

Fixes the compilation of cairo-sphinx with --enable-tee
--enable-xlib-xcb --enable-script.

Reported-by: James Cloos <cloos@jhcloos.com>
2011-06-16 18:31:14 +02:00
Andrea Canciani
f409f74dec xlib: Fix build of xlib-xcb
45665c0d48 breaks the build of
cairo-xlib-xcb because it does not disable the compilation of
cairo-xlib implementation files when cairo-xlib-xcb is enable. This
results in collisions when linking.

Reported-by: James Cloos <cloos@jhcloos.com>
2011-06-16 15:11:24 +02:00
Andrea Canciani
a2cd83a986 toy-font-face: Do not assume hash != 0
The assumption that no font face will hash to 0 is not correct.
Moreover, no special value is needed to mark fonts in error status, as
they can simply be detected upon lookup and destruction.
2011-06-16 12:17:33 +02:00
Andrea Canciani
a06668fabe path-stroke: Avoid mixing cap and join values
Silence the warning:

cairo-path-stroke.c: In function '_cairo_stroker_add_caps':
cairo-path-stroke.c:861:29: warning: comparison between
'cairo_line_cap_t' and 'enum _cairo_line_join' [-Wenum-compare]

CAIRO_LINE_JOIN_ROUND and CAIRO_LINE_CAP_ROUND have the same value,
hence this defect went unnoticed so far.
2011-06-16 09:48:30 +02:00
Taekyun Kim
8e7589abcc tessellator: Fixed to produce an output box with x1 <= x2 for single box input
Winding of a box is toggled by swapping x1, x2 coordinates. So
we have to swap those coordinate rather than just copying.

Many routines assume that boxes are left-top to right-bottom
convention. So tessellator should produce such output boxes.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-06-15 16:13:15 +01:00
Andrea Canciani
45665c0d48 Remove if's from Makefile.sources
make on win32 complains that:

make[1]: Entering directory `/home/ranma42/Code/fdo/cairo/src'
../src/Makefile.sources:220: *** missing separator.  Stop.

Makefile.sources should not contain if's, which are aoutomake-only
conditionals.  The correct way to conditionally include files is to
enable/disable them using C preprocessor macros.
2011-06-14 15:25:08 +02:00
Uli Schlachter
9d256b7db9 xcb: Fallback to image surface for create similar
We can't use an X11 surface in create_similar if the specified coordinates are
too small/large. However, we can still use SHM-backed memory for the image
surface which will be used instead.

Thanks to Chris Wilson for the hint.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-12 15:42:01 +02:00
Uli Schlachter
fb0a40fc10 XCB: Implement PDF blend operators natively
The PDF blend operators, as offered by cairo, where added in RENDER 0.11. This
commit makes the XCB backend use them, if they are available.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-11 21:32:29 +02:00
Uli Schlachter
ad01d571dd Revert "xcb: Never return NULL from create_similar"
This reverts commit f6e6891b59.

Returning NULL in these cases is actually the right thing to do, because the
caller expects and handles this case.

cairo_surface_create_similar() won't return NULL due to this, because
_cairo_surface_create_similar_solid() will fall back to an image surface.

I think I missed that part when I wrote the bad commit.

This was found via the test suite's "zero-mask" test.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-06-11 20:18:27 +02:00