Commit graph

46 commits

Author SHA1 Message Date
Carl Worth
d6d81c92b5 Eliminate a potential infinite loop in spline stroking
Sometimes > rather than >= can make a bug difference. The infinite loop
was noticed here:

	Infinite loop when scaling very small values using 24.8
	http://bugs.freedesktop.org/show_bug.cgi?id=14280

Note that that particular test case only exposes the infinite
loop when using 24.8 instead of 16.16 fixed-point values by
setting CAIRO_FIXED_FRAC_BITS to 8.
2008-02-20 04:04:04 -08:00
Carl Worth
770b058c9e Remove _cairo_slope_[counter_]clockwise
These two functions were hiding away some important details
about strictness of inequalities. Also, the callers differ
on the strictness they need. Everything is cleaner and more
flexible by making the callers just call _cairo_slope_compare
directly.
2008-02-20 04:04:04 -08:00
Behdad Esfahbod
b790c5a6bc [doc] Replace 'NOTE' by 'Note' and add it to test 2008-01-28 21:53:44 -05:00
Carl Worth
448c931425 Fix degenerate-pen test case by removing the triggering assertion
Instead we choose either the first or last pen vertex as
appropriate.

This makes the degenerate-pen pass stop failing on an
assertion, and passes for most backends. It's still failing
for the PDF backend, but that looks like a new, PDF-specific
bug.
2007-10-30 17:17:38 -07:00
Chris Wilson
bed8239f03 [cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
    return _cairo_error (CAIRO_STATUS_INVALID_DASH);

This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
2007-10-04 13:31:44 +01:00
Chris Wilson
e49bcde27f [malloc] Check for integer overflow when realloc'ing.
Perform similar sanity checks to Vlad's _cairo_malloc_ab() but on the
arguments to realloc instead.
2007-10-04 00:42:29 +01:00
Chris Wilson
e767c8b50a [cairo-pen] Add _cairo_error().
Markup a couple of originating error sites with _cairo_error().
2007-10-04 00:42:29 +01:00
Chris Wilson
4e39e30d83 [cairo-pen] Remove status from _cairo_pen_find_active_vertex_*()
This pair of functions unconditionally return SUCCESS, so remove the
status return and supporting tests from their callers.
2007-08-16 15:20:25 +01:00
Chris Wilson
b72b06cc22 [cairo-pen] Remove hard-coded CAIRO_STATUS_SUCCESS from _stroke_spline_half()
Remove the status return and update callers as
_cairo_pen_stroke_spline_half() unconditionally returned SUCCESS.
2007-08-16 15:20:06 +01:00
Vladimir Vukicevic
5c7d2d14d7 [fix] Avoid int overflow when allocating large buffers
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them.  The macros
return NULL if int overflow would occur during the allocation.  See
CODING_STYLE for more information.
2007-06-29 09:46:08 -07:00
Carl Worth
b1086caf3b Add a status field to cairo_polygon_t
Now, the functions to add new data to a polygon all become void,
and there's a new _cairo_polygon_status call to query the status
at the end of a sequence of operations.

With this change, we fix many callerswhich were previously not
checking the return values of _cairo_polygon functions by adding
only a single call to _cairo_polygon_status rathern than several
new checks.
2007-04-10 10:45:15 -07:00
Carl Worth
d5b35d7d76 Make _cairo_pen_init_empty void
Yet another function that cannot fail under any circumstances.
2007-04-09 17:12:11 -07:00
Chris Wilson
14ac5dd78b Return the correct status from _cairo_pen_stroke_spline().
The return value is shared before the normal cleanup and error paths,
so do not simply return a hard-coded CAIRO_STATUS_SUCCESS.
2007-04-09 16:23:36 -07:00
Chris Wilson
4b195779a4 cairo-pen - trivial propagation of error status
Add a couple of missing checks for error statuses and correct the
error path cleanup for _cairo_pen_stroke_spline().
2007-04-09 15:05:58 +01:00
Carl Worth
4cd871b6f3 Switch from old tessellator to new tessellator 2006-11-22 16:56:51 -08:00
Carl Worth
10cd23d51f Fix infinite-join test case (bug #8379)
The trick for this was to carefully ensure that the pen always has
at least 4 vertices. There was a previous attempt at this in the
code already but the test case had a combination of matrix and radius
that resulted in a value that was just able to sneak past the previous
check.
2006-10-18 15:02:12 -07:00
Carl Worth
5492a7c761 Add assert statement so the infinite-join test simply exits rather than looping infinitely. 2006-09-21 15:15:02 -07:00
Carl Worth
5278de0997 Remove all remaining trailing whitespace.
This patch was produced with the following (GNU) sed script:

	sed -i -r -e 's/[ \t]+$//'

run on all *.[ch] files within cairo.

Note that the above script would have also created all the changes
from the previous commits to remove trailing whitespace.
2006-06-06 15:41:31 -07:00
Carl Worth
4670366ede Remove trailing whitespace from lines that look like comments.
This patch was produced with the following (GNU) sed script:

	sed -i -r -e '/^[ \t]*\/?\*/ s/[ \t]+$//'

run on all *.[ch] files within cairo, (though I manually excluded
src/cairo-atsui-font.c which has a code line that appears as a comment
to this script).
2006-06-06 15:35:48 -07:00
Carl Worth
80b8deb1e4 Remove extraneous whitespace from "blank" lines.
This patch was produced with the following (GNU) sed script:

	sed -i -r -e 's/^[ \t]+$//'

run on all *.[ch] files within cairo.
2006-06-06 15:25:49 -07:00
Carl Worth
a7228cc37a Originally 2005-10-28 Keith Packard <keithp@keithp.com>:
Remove pen_regular field from the gstate.
Move stroke fallback from gstate to surface where it belongs.
Eliminate dependence on cairo_gstate_t object.
Fix to include just cairo-clip-private.h rather than cairo-gstate.private.h.
2005-10-31 16:55:21 +00:00
Bertram Felgenhauer
c0905759b0 use new function. strip comment of derivation for major axis length.
use _cairo_matrix_get_affine to retrieve matrix entries.
new function split out of cairo-pen.c. UTF8-ify the comment that explains the calculation.
2005-08-22 16:48:28 +00:00
Bertram Felgenhauer
c7a35fbd31 use correctly transposed version of the matrix and fix up the comments above to use row vector notation. 2005-08-22 16:29:56 +00:00
Carl Worth
d135938efd Rework the cairo_matrix_t interface in several ways. Expose a struct for cairo_matrix_t.
Add new function to return current matrix: cairo_get_matrix
Deprecate the following functions (in documentation): cairo_matrix_create cairo_matrix_destroy cairo_matrix_get_affine
Rename: cairo_matrix_set_affine -> cairo_matrix_init cairo_matrix_set_identity -> cairo_matrix_init_identity
Add other new matrix initialization functions: cairo_matrix_init_translate cairo_matrix_init_scale cairo_matrix_init_rotate
Change return type of almost all cairo_matrix functions from cairo_status_t to void.
Track changes to cairo_matrix_t interface.
Add a test case showing the same path drawn under various transforms, (including skews set directly by initializing a cairo_matrix_t).
2005-04-07 10:01:49 +00:00
Carl Worth
cb5bbd0aa7 Begin the process of breaking up cairoint.h, moving structure definitions of cairo_t, cairo_gstate_t, and cairo_path_real_t into their own header files.
Track changes to header files, reaching into the new private headers where necessary.
2005-03-23 13:50:51 +00:00
Carl Worth
dcfb0d8a2b Switch from broken cworth@isi.edu address to canonical cworth@cworth.org address. 2005-02-22 11:35:03 +00:00
Carl Worth
bf8374dba2 Convert all files to utf-8. Add copyright information to cairo_png_surface.c. 2004-10-21 18:40:50 +00:00
Carl Worth
047ce33600 Fix a few typos in pen vertex math description. 2004-10-12 14:09:37 +00:00
Keith Packard
cc890b9cf4 Adapt function from Walter Brisken to compute pen ellipse major axis length and use that to compute the required number of pen vertices.
reviewed by: Carl Worth <cworth@cworth.org>
2004-10-12 12:29:29 +00:00
Carl Worth
0f3ce6a240 Add the MPL as a new license option, in addition to the LGPL. 2004-09-04 06:38:34 +00:00
Carl Worth
e5afa03605 Fix to explicitly refer to GNU Lesser Public License 2.1 rather than the Library Public License version 2 or 'any later version' 2004-08-02 17:04:00 +00:00
Carl Worth
d5e92dd1c8 Change from MIT license to LGPL. 2004-08-02 13:13:28 +00:00
Carl Worth
08553e75b7 Clean up cairo_path_callbacks to have move_to, line_to, curve_to, abd close_path instead of add_edge, add_spline, and done_sub_path. Much, much nicer.
Provide cairo_polygon_move_to and cairo_polygon_line_to instead of cairo_polygon_add_point.
Track change in cairo_polygon interface.
2003-12-08 13:38:26 +00:00
Carl Worth
f27af5d98d Remove infinite looping when stroking with a line width at or close to 0.0. Thanks to Rob Buis <buis@kde.org> and Noah Levitt <nlevitt@columbia.edu> for providing in-the-wild examples of SVG files with stroke-width:0 that demonstrated the problem, (cowboy.svg and albania.svg).
Do nothing if the pen is a degenerate, single point. This happens when the line width is a very small, non-zero value.
Do nothing when asked to stroke a path with a line_width of 0.0. Previously, this would lead to an infinite loop.
Force negative line width to 0.0.
Updated TODO list.
2003-11-17 07:04:15 +00:00
Carl Worth
7262e1554f Add comment pondering memory management semantics of cairo_current_target_surface.
NULL out pen->vertices after free.
NULL out durface->data after free.
2003-11-06 12:53:39 +00:00
Carl Worth
2c9d1913cc Fixed copyright attribution to refer to "University of Southern California 2003-10-23 07:47:29 +00:00
Carl Worth
61726a88f2 Generate convex hull of pen before stroking. 2003-10-04 14:34:42 +00:00
Carl Worth
a249bd717c Remove abbreviation of "point" as "pt". Fix cairo_destrot, cairo_set_target_surface, and cairo_set_target_image to act appropriately in the face of non-zero status. 2003-10-04 09:06:15 +00:00
Carl Worth
60d541ee6a Fixed some internal enums that had been mistakenly converted to lowercase at some point. 2003-09-27 05:00:47 +00:00
Carl Worth
5b5c172803 Preliminary support for running Cairo with X servers without the Render extension. This is still horribly slow. Removed many uses of X-specific macros, (eg. XDoubleToFixed) 2003-09-05 15:29:49 +00:00
Keith Packard
7e9a0f9cf3 comment face computations, check for reflecting transformation to select correct face orientations
check for reflecting transform when computing pen to ensure consistent pen orientation
2003-09-05 13:25:46 +00:00
Carl Worth
4d399b9aca Added missing underscores to several internal functions. 2003-08-26 07:40:17 +00:00
Carl Worth
e97cfd5eae Made all changes necessary to abandon the Xc library, (sucking the functionality up into cairo_surface_t instead). Eliminated most of the remaining X datatypes (XFixed, XPointFixed, XLineFixed, XTrapezoid). Fixed some numerical problems relating to pen initialization and intersection calculation. 2003-07-30 08:30:50 +00:00
Carl Worth
ee146c4740 Introduced cairo_fixed_*_t types. Converted several functions from floating to fixed point. 2003-07-23 21:20:24 +00:00
Carl Worth
84ed2d465f Fixed some inconsistent tag/typedef names I missed the first time. 2003-07-18 12:42:49 +00:00
Carl Worth
dc1e96ae35 Renamed everything from Xr* to cairo_* 2003-07-18 11:34:19 +00:00