Commit graph

57 commits

Author SHA1 Message Date
John Lindgren
bb24f165ff Avoid indiscriminate use of VALGRIND_MAKE_MEM_NOACCESS.
Marking stack-allocated objects as no-access creates false positives,
which distract from finding real memory errors.

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

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-26 16:12:33 -07:00
Chris Wilson
ea16302e45 polygon: Avoid computing the unused intersection coordinates
If we only ignore the result of the computed boundary intersection,
because the edge is inside that boundary, then we can simply forgo the
calculation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-08 13:22:01 +00:00
Chris Wilson
8cfbdf2f02 polygon: Only rely on the computed boundary intersections for crossing edges
If we need to extrapolate the edge to the boundary, then we run the risk
of an overflow for an immaterial result. So if the edge does not cross
the boundary, we can simply use the corresponding end-point and not emit
the boundary segment.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60489
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-08 13:13:30 +00:00
Chris Wilson
291efa76de polygon: Tweak the y-coordinates of the edge so that it is inside the clip
As we evaluate the line first using y-for-x to find the clipped
vertical range and then rasterise the line using x-for-y, we can incur
severe rounding errors that cause us to draw beyond the clipped region.
The first simple attempt at a fix is to tweak the clipped vertical range
such that the evaluated extents of the line are contained.

Reported-by: Taekyun Kim <tkq.kim@samsung.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-06 14:49:27 +00:00
Chris Wilson
19dd6e7e53 polygon: Assert that we add edges that are wholly contained by the clip
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-06 14:44:57 +00:00
Chris Wilson
8f34fa033e spans: Refresh polygon limits after trimming the composite extents
Trimming the composite extents may result in the clip being
reconstructed, but we the polygon continued to hold a reference into the
freed clip's array of boxes. So if we intend to reuse the polygon limits
after performing the clip we need to refresh them.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-12 17:04:16 +01:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
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. :)
2011-09-12 08:29:48 +01:00
Chris Wilson
545f30856a stroke: Convert the outlines into contour and then into a polygon
In step 1 of speeding up stroking, we introduce contours as a means for
tracking the connected edges around the stroke. By keeping track of
these chains, we can analyse the edges as we proceed and eliminate
redundant vertices speeding up rasterisation.

Coincidentally fixes line-width-tolerance (looks like a combination of
using spline tangent vectors and tolerance).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-15 10:31:47 +01:00
Andrea Canciani
d7abdab931 polygon: Fix generic case of edge clipping
The edge clipper is more complicated than it should be and contains a
subtle bug: when an edge is almost horizontal, it is always considered
as having a positive slope.

Explain what should be done and do it in a simpler way.

Fixes horizontal-clip.
2011-07-28 18:11:27 +02:00
Andrea Canciani
6aa6b7daa8 polygon: Simplify code for edge clipping
Add some comments about what's going on and clean up the branches by
sharing common computations.
2011-07-28 18:11:27 +02:00
Chris Wilson
cac96c8083 polygon: Fix clipping of edges outside of their range
Uli Schlachter analysed the error behind the polygon reduction and
discovered that it was due to the clipping of a line which intersects
the clip box (p1, p2) but is range limited by (top, bottom) to be inside
the clip box.

Fixes hatching

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-27 17:32:42 +01:00
Chris Wilson
030de5144d polygon: Don't skip clipped horizontal edges
As Andrea Canciani pointed out even if it is horizontal within the clip
box, it may still have vertical extents outside of the clip box for
which we need to project onto the clip boundary  in order to maintain
the correct polygon winding.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-27 17:32:41 +01:00
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Andrea Canciani
85a489f0f2 polygon: Merge _cairo_polygon_init and _cairo_polygon_limit
_cairo_polygon_limit() had to be called immediately after
_cairo_polygon_init() (or never at all).

Merging the two calls is a simple way to enforce this rule.
2010-12-10 11:04:48 +01:00
Andrea Canciani
75f34b595a fill: Simplify path to polygon conversion
Using _cairo_path_fixed_interpret_flat() greatly simplifies the path
to polygon conversion (because it already converts curve_to's to
line_to's).

This commit also removes the optimization which merges two consecutive
lines if they have the same slope, because it's unlikely (since it
should already happen during path construction), it doesn't provide
better performance (at least not measurable with the currently
available cairo-traces) and bloats the code.
2010-12-10 11:04:47 +01:00
Chris Wilson
290749bdb5 polygon: Reorder conditionals based on likelihood.
The vast majority of edges will be unclipped, so process those first.
2010-06-11 10:59:17 +01: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
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
df067be863 [polygon] Compute the limit of the limits slightly more efficiently
Initialize the bbox to the first limit, as frequently there will only be a
single (or at least a small number) limit.
2009-09-03 10:07:34 +01:00
Chris Wilson
f1d284f997 [polygon] Fix discard with non-banded disjoint clip boxes
The early discard checked if the line was below the last clip-box, or if
above the first. However, the clip-boxes are only sorted on by the bottom
(not the strict XY-banded sort of the regions) and so this was erroneously
discarding lines.
2009-09-03 01:00:59 +01:00
Chris Wilson
30e5fa0ce0 [polygon] Return status from path ops
This tidies the common case which was to call, for example,
_cairo_polygon_line_to(); _cairo_polygon_status();
2009-08-29 08:08:33 +01:00
Chris Wilson
3fcac1ef21 [slope] Inline _cairo_slope_init()
Move the definition to a separate header file and allow callers to inline
the simple function.
2009-08-29 08:08:33 +01:00
Chris Wilson
3f12d9ec5d [clip] Use geometric clipping for unaligned clips
For the simple cases where the clip is an unaligned box (or boxes), apply
the clip directly to the geometry and avoid having to use an intermediate
clip-mask.
2009-08-29 08:08:33 +01:00
Chris Wilson
6dfe050d63 [polygon] Amalgamate collinear edges
Combine sequential collinear edges into a single edge, this benefits
immensely by feeding fewer edges into either the tessellator or spans.
2009-08-29 08:08:31 +01:00
Chris Wilson
f8bb3617c3 Eliminate self-intersecting strokes.
We refactor the surface fallbacks to convert full strokes and fills to the
intermediate polygon representation (as opposed to before where we
returned the trapezoidal representation). This allow greater flexibility
to choose how then to rasterize the polygon. Where possible we use the
local spans rasteriser for its increased performance, but still have the
option to use the tessellator instead (for example, with the current
Render protocol which does not yet have a polygon image).

In order to accommodate this, the spans interface is tweaked to accept
whole polygons instead of a path and the tessellator is tweaked for speed.

Performance Impact
==================

...
Still measuring, expecting some severe regressions.
...
2009-08-29 08:08:28 +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
1ae2ddc1dd [memfault] Manually inject faults when using stack allocations
Ensure that no assumptions are made that a small allocation will succeed
by manually injecting faults when we may be simply allocating from an
embedded memory pool.

The main advantage in manual fault injection is improved code coverage -
from within the test suite most allocations are handled by the embedded
memory pools.
2009-04-23 09:22:51 +01:00
Chris Wilson
e6963a5bfe Mark allocation failures as unlikely.
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
2008-11-29 11:20:34 +00:00
Chris Wilson
d7873eecc5 [spline] Eliminate intermediate allocations during spline decomposition.
The spline decomposition code allocates and stores points in a temporary
buffer which is immediately consumed by the caller. If the caller supplies
a callback that handles each point computed along the spline, then we can
use the point immediately and avoid the allocation.
2008-11-16 16:21:25 +00:00
Chris Wilson
0ab14a6b21 [polygon] Reduce number of branches.
Minimise the number of conditionals taken whilst constructing the polygon.
2008-09-18 09:06:29 +01:00
Chris Wilson
335ed74589 Enlarge the embedded arrays to eliminate frequent allocations.
Enlarge the embedded arrays of edges and points for cairo_polygon_t and
cairo_spline_t respectively, such that the frequent allocations are
eliminated whilst running a firefox3 benchmark.
2008-06-13 21:34:42 +01: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
8cba73a36c [cairo-polygon] Add a _cairo_error().
Add a _cairo_error() to an originating error site.
2007-10-04 00:42:29 +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
01955a6e82 Rename ARRAY_LEN to ARRAY_LENGTH
Yet another victim in my hunt against abbreviations within cairo's implementation.
2007-04-10 10:14:49 -07:00
Chris Wilson
619425a8b3 cairo-polygon - trivial propagation of error status
_cairo_polygon_move_to() returns an error status so use it.
2007-04-09 15:06:11 +01:00
Behdad Esfahbod
8fbf50d31d [src] Make sure all source files #include "cairoint.h" as their first include
This is necessary to avoid many portability problems as cairoint.h includes
config.h.  Without a test, we will regress again, hence add it.

The inclusion idiom for cairo now is:

	#include "cairoint.h"

	#include "cairo-something.h"
	#include "cairo-anotherthing-private.h"

	#include <some-library.h>
	#include <other-library/other-file.h>

Moreover, some standard headers files are included from cairoint.h and need
not be included again.
2007-04-03 20:28:11 -04:00
Behdad Esfahbod
ad51ee5aa0 Define and use ARRAY_LEN 2007-03-20 18:59:19 -04:00
Behdad Esfahbod
deed0f4734 [polygon,spline,traps] Avoid free(NULL) 2007-03-13 06:09:09 -04:00
Behdad Esfahbod
b706bd9b38 [cairo-polygon] Add a cache of eight edges to cairo_polygon_t
Many, if not most, of polygons have very few edges.  This avoids
calling malloc() for those cases.
2007-03-13 06:07:03 -04:00
Behdad Esfahbod
cca7e3fec3 [cairo_polygon_t] Change has_current_point from int to cairo_bool_t 2007-03-13 05:56:38 -04:00
Behdad Esfahbod
3ce84390de [cairo-polygon] Clean-up realloc algorithm for clarity 2007-03-13 05:51:39 -04: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
dcfb0d8a2b Switch from broken cworth@isi.edu address to canonical cworth@cworth.org address. 2005-02-22 11:35:03 +00:00
Carl Worth
7a5a3cb208 Remove unused CAIRO_TRAPS_GROWTH_INC.
Resize arrays by doubling rather than by linear increments.
Add new bug exposed centi_unfinished.svg.
2004-12-23 13:49:56 +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
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