Commit graph

383 commits

Author SHA1 Message Date
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
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
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
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
90156f6ab7 Fix visibility issues found by make check 2011-03-21 09:58:29 +01:00
Andrea Canciani
ab8c108b88 Do not warn when ignoring the return value of _cairo_rectangle_intersect()
gcc complains that

cairo-surface-wrapper.c:647: warning: ignoring return value of
‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result

It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
2011-03-19 12:24:14 +01:00
Andrea Canciani
f2eb3f2178 Improve cairo_rectangle_list_t error handling
Unify the _cairo_rectangle_list_create_in_error() functions, keeping
the best features from both (the one in cairo-clip.c statically
allocates the most common cases, the one in cairo.c throws a NO_MEMORY
error when it cannot malloc() instead of rethrowing the same error).

The same function can be used to return an error-list in
_cairo_gstate_copy_clip_rectangle_list() when _cairo_clip_rectangle()
fails (for example becaouse of an OOM).
2011-03-18 17:54:54 +01:00
Andrea Canciani
fd1fca8010 Make cairo_set_font_size() a wrapper of cairo_set_font_matrix()
cairo_set_font_size() should be equivalent to setting the font matrix
to an appropriate scale matrix.

Implementing it this way saves some code and makes sure that the same
code path is used whenever the font matrix is changed.
2011-03-18 11:43:42 +01:00
Benjamin Otte
94612bc032 arc: Remove erroneous return statement
Introduced in e46dc9e17a.
2011-02-19 10:40:01 +01:00
Benjamin Otte
e46dc9e17a arc: Handle radius == 0 the same no matter the arc direction
Commit a0ea0b63fd fixed cairo_arc() but
did not apply the same patch to cairo_arc_negative(). This patch fixes
that oversight.
2011-02-18 19:51:44 +01:00
Andrea Canciani
5d95ae924e gstate: Set an error status when restoring a push_group
cairo_push_group (cr) followed by cairo_restore (cr) should put cr in
an error status of CAIRO_STATUS_INVALID_RESTORE.

Fixes group-state.
2011-01-22 11:59:38 +01:00
Maarten Bosmans
a351807147 doc: Fix some broken references and gtk-doc warnings
The gtk-doc comments contain some typos and are missing some escaping.
2011-01-16 18:40:49 +01:00
Andrea Canciani
4314a86aa7 arc: Avoid infinite loop
Adding/subtracting 2 * M_PI to a huge floating point number doesn't
change it (because of rounding) and for smaller numbers it still
requires a lot of cycles before the angle is in the desired range.

The same computation can be performed using fmod, which should provide
more accurate results and only requires O(1) time.
2010-12-09 17:33:12 +01:00
Andrea Canciani
0655198301 Fix degenerate arcs
Make sure that degenerate arcs become a move_to-line_to sequence
instead of just a move_to.

Fixes get-path-extents.
2010-10-29 17:31:23 +02:00
Andrea Canciani
e8e614db92 path: Rename fill optimization flags
Rename fill optimization flags making fill_ their common prefix.
2010-10-29 17:31:23 +02:00
Andrea Canciani
e48cb95493 path: Add stroke_is_rectilinear flag
Stroke and fill rectilinearity cannot be represented by a single flag
without missing the opportunity of considering some strokes
rectilinear.
2010-10-29 17:31:22 +02:00
Andrea Canciani
166453c1ab path: New path construction logic
Now move_to's are actually added to the path when followed by a
drawing operation (line_to, curve_to or close_path).

This is implemented by updating the current_point and setting the
needs_move_to when a move_to operation is requested.

Whenever a drawing operation is requested and the needs_move_to flag
is set, a move_to is added before the drawing operation.
2010-10-29 17:31:22 +02:00
Tim Janik
75e2b7c7b5 cairo: docu fix for cairo_set_source_surface 2010-09-23 15:12:06 +02:00
Chris Wilson
8e9c4ea589 Mark the context as invalid on the final cairo_destroy()
We initialise the context to a non-error state upon creation, but after
destroy there is a window of opportunity where the object is kept alive
inside the context pool and the user could mistakenly keep on passing
the zombie context into cairo functions. As all entry points need to
check error status, flagging the context as an error object upon the
final unreference prevents such misuse (until such as time as the
context is reallocated).
2010-08-11 12:18:53 +01:00
Benjamin Otte
b870cc030d doc: Move tmpl/ docs to inline docs
I did this manually so I could review the docs at the same time.
If anyone finds typos or other mistakes I did, please complain to me (or
better: fix them).
2010-07-08 14:27:16 +02:00
Benjamin Otte
1373675ef7 pop-group: Translate existing path properly
This fixes the reverse case of the push_group case fixed a few commits
ago.
2010-06-25 14:10:12 +02:00
Benjamin Otte
2e8571d95c push-group: Fix path translation when pushing a group with device offsets
With the previous code, the parent's device offset wasn't undone before
applying the new device offset.
Tested by push-group-path-offset test.
2010-06-25 13:48:07 +02:00
Chris Wilson
9b7cc7641b cairo: Create error objects for cairo_t
Perform an early check for error status and prevent creation of a full
object. This means that we do not pass down error objects to the
initialisation routines and so can survive without paranoia inside the
library. It also has brings consistency that like the other
constructors, no object is created in error and we can skip the
cairo_destroy() if we choose (and we don't waste one of the precious
zero-alloc context slots.

Fixes crash in test/a8-mask introduced by 1a544361e8.
2010-06-12 10:41:09 +01:00
Andrea Canciani
baaf312e04 pattern: remove content field from solid patterns
The content field in solid patterns had ill-defined semantic (or no
semantic at all), thus it can be removed.
2010-06-10 16:07:41 +02:00
Benjamin Otte
8aa50b5a78 cairo_paint_with_alpha(cr, 0.0) is only a noop when bounded by mask 2010-05-13 12:11:09 +02:00
Chris Wilson
81f4dd65a3 cairo: Special case cairo_t with NULL_POINTER
Avoid allocation for the potential user error of attempting to use
cairo_create(NULL).
2010-05-07 22:35:18 +01:00
Chris Wilson
506636e19e cairo: stash a number of contexts for use with NO_MUTEX
The implementation is the same as the atomic one (bar the use of atomic
primitives to manipulate the occupancy!).

Patch based on the original by Jeff Muizelaar.
2010-05-06 17:21:59 +01:00
Andrea Canciani
d66b1ca1cf atomic: Separate bool and old-value compare-and-exchange
Some implementations only offer one version of compare-and-exchange,
thus we expose both through cairo-atomic, implementing what is missing
through appropriate fallbacks.
*_cmpxchg() now return a boolean (this unbreaks _cairo_atomic_uint_cmpxchg)
*_cmpxchg_return_old() return the old value
Code is updated everywhere to reflect this, by using *_cmpxchg()
wherever the returned value was only tested to check if the exchange
had really taken place.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-04-29 10:52:47 +02:00
Andrea Canciani
b8a7f8621a Update FSF address
I updated the Free Software Foundation address using the following script.

for i in $(git grep Temple | cut -d: -f1 )
do
  sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
2010-04-27 11:13:38 +02:00
Chris Wilson
c63e3490a5 cairo: Handle the all-clipped state in cairo_push_group()
Yet another bug reported by Jeff Muizelaar, thanks!

Fixes: test/clip-empty-group
2010-04-23 14:47:59 +01:00
Chris Wilson
4438cc6a49 cairo: Use explicit device flushing.
Now with the concept of a cairo_device_t and the ability to flush it,
we now longer require the heuristic of automatically flushing on behalf
of the user at the end of every context.
2010-04-23 14:39:21 +01:00
Chris Wilson
6b77567b6e path: Compute coarse bounds upon construction.
Frequently we only need the coarse path bounds, so avoid walking over
the list of points once more as we can cheaply track the extents during
construction.
2010-01-22 23:01:52 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00
Chris Wilson
a0ea0b63fd arc: Just emit a line-to if radius is zero.
In order to be consistent with the semantics of cairo_arc() using a
radius of 0 should simply degenerate into a line-to.

Reported-by: Benjamin Berg
2009-12-30 16:21:50 +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
Chris Wilson
ef9286751d [atomic] Fallback to libatomic-ops-dev
Use libatomic-ops-dev in preference to mutex-based atomics, if we do not
have the builtin atomic intrinsics available.
2009-10-15 13:05:46 +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
73f8019fd2 [path] Use cairo_list_t instead of open-coding its own
Use the cairo_list_t and its style of iterators to improve the readability
of the cairo_path_buf_t management. Note the complications that arise from
the embedding of the initial buf -- however the macros do help make the
unusual manipulations more identifiable.
2009-07-05 15:01:03 +01:00
Chris Wilson
1645352bfb [path] Evaluate is_box && is_region during construction
Whilst constructing the path, if the operations continue to be
axis-aligned lines, allow the is_box and is_region flags to persist. These
are set to false as soon as a curve-to is added, a diagonal or in the case
of is_region a non-integer point.
2009-07-05 09:30:02 +01:00
Chris Wilson
2b1ec7a4d8 [cairo] Report true error via pattern from cairo_pop_group()
Report the correct error via the returned pattern->status rather than
simply returning the NO_MEMORY nil object.
2009-06-27 22:48:19 +01:00
Chris Wilson
5c3be3ece2 [cairo] Mark cr->status guard as unlikely
For correct operation, the context should never be in error, so mark the
error context as being unlikely to optimize the common path.
2009-06-27 22:40:15 +01:00
Chris Wilson
f8a2665840 [cairo] Trivial code tidy 2009-06-27 16:32:51 +01:00
Chris Wilson
62dc0ae46c [cairo] Offset the current path when pushing/popping groups.
We need to translate the path in order to compensate for the device offset
applied to the group surface when pushing and popping. (The path is
transformed to device space on creation, and so needs recomputing for the
new device.)
2009-06-19 19:08:34 +01:00
Chris Wilson
116c93cb7f [cairo] Remove instance of 'return free()'
Gah! This is a GCC-ism, so therefore it has to go.
2009-06-16 11:36:36 +01:00
Chris Wilson
7d8a0a1cdd [cairo] Keep a small stash of cairo contexts
A cairo context is meant to be extremely cheap to create such that it can
be used in transient expose events. Thus these are allocated reasonably
frequently and show up malloc profiles.
2009-06-07 19:48:59 +01:00
Chris Wilson
132f44dce1 valgrindify init/fini routines
Annotate object init/fini routines to detect use-after-free for
on-stack/embedded objects.
2009-06-04 14:17:43 +01:00
Chris Wilson
c988dc3719 [cairo] Doc typo.
Fix conflicting sentence as pointed out by
https://bugs.freedesktop.org/show_bug.cgi?id=20183
2009-06-03 10:51:23 +01:00
Chris Wilson
8d39dee8e2 [cairo] Update documentation for bug 20154
Several typographical errors were pointed out in
https://bugs.freedesktop.org/show_bug.cgi?id=20154
2009-06-03 10:40:38 +01:00