Commit graph

110 commits

Author SHA1 Message Date
Chris Wilson
b0c466e27a path: Update last_move_point after move-to
Reported-and-tested-by: Jussi Kukkonen <jku@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54549
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-05 14:55:55 +01:00
Chris Wilson
57cfdfd979 Split cairo-list into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 13:17:29 +01:00
Chris Wilson
e9c9e28cd1 Split cairo-box-privates into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:16:53 +01:00
Andrea Canciani
d3b6e151a2 path-fixed: Silence gcc warnings
_cairo_path_fixed_last_op() contains an assertion, which gcc doesn't
like to inline. Since it is a static function, which basically
accesses a value, gcc will inline it anyway when assertions are
disabled, so remove the "inline" hint to reduce gcc warning noise when
doing debug builds.

Fixes:

cairo-path-fixed.c: In function '_cairo_path_fixed_drop_line_to':
cairo-path-fixed.c:373:1: warning: inlining failed in call to
'_cairo_path_fixed_last_op.isra.5.part.6': call is unlikely and code
size would grow [-Winline]
cairo-path-fixed.c:400:1: warning: called from here [-Winline]
...
2012-02-20 12:32:53 +01:00
Uli Schlachter
84d1eac61f path: Fix a minor oversight in 1ce5d4707c
The plan was "path: Skip calls to zero-length memcpy". However, this skipped
calls if the buffer was still empty, which means that it skipped all calls.

Fixes: Half the test suite, lots of assertion failures

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-09-16 18:00:21 +02:00
Chris Wilson
1ce5d4707c path: Skip calls to zero-length memcpy
We attempt to copy 0 points onto the array of path points for a
close-path. This is pointless and an unnecessary function call under
MSVC at least.

Based on a patch by Steve Snyder, incorporating Behdad's review
comments.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37836
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-16 16:11:42 +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
Chris Wilson
34ce4680d1 fixed: Allow the implicit close of the last fill path to complete a fill-box
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-10 10:23:51 +01:00
Chris Wilson
323e48f8ec fill: A horizontal/vertical line is also a degenerate fill box
Since we discard empty fill boxes whilst filling, we can also treat
horizontal/vertical lines as a filled box and so proceed with the
rectangular fast path in the presence of
  cairo_rectangle (x, y, w, h)
with w == 0 || h == 0.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-09 16:06:50 +01:00
Andrea Canciani
c0fe556515 path: Fix _cairo_path_fixed_is_rectangle()
__cairo_path_fixed_is_rectangle() is used by the PS and PDF backends
to check if a path is equivalent to a rectangle when stroking. This is
different from being a rectangle when filling, because of the implicit
close_path appended to every subpath when filling.

Fixes stroke-open-box.

See https://bugs.freedesktop.org/show_bug.cgi?id=34560
2011-03-18 10:30:25 +01:00
Andrea Canciani
5eadc286d8 path: Silence warnings
gcc complains that:

cairo-path-fixed.c:400: warning: inlining failed in call to
  '_cairo_path_fixed_drop_line_to': call is unlikely and code size
  would grow
2010-12-13 11:09:20 +01:00
Andrea Canciani
df453b7aca path: Remove support for inverse direction interpretation
The previous commit guarantees that paths are always interpreted in
the forward direction, so the code allowing both directions is not
needed anymore.
2010-12-10 11:04:47 +01:00
Andrea Canciani
a8ae8759f5 path: Always interpret in forward direction
Path are always interpreted in forward direction, so the ability of
interpreting in the opposite direction (which is very unlikely to be
useful at all) can be removed.
2010-12-10 10:58:51 +01:00
Andrea Canciani
b8444a5c78 path: Tighten transformed extents
The transformation code should produce tight extents if they are to be
used in the new simple extents functions.
2010-10-29 17:31:24 +02:00
Andrea Canciani
958c56e2b4 path: Tighten curve_to extents
The additional time spent in the computation of tight extents for the
curve_to operation doesn't seem to be significant, but it makes the
extents computations faster and the approximations more accurate.
2010-10-29 17:31:23 +02:00
Andrea Canciani
a1d8763236 path: Replace _cairo_path_fixed_extents_add with _cairo_box_add_point
Path extents now satisfy _cairo_box_add_point requirements, so it can
be used instead of _cairo_path_fixed_extents_add.
2010-10-29 17:31:23 +02:00
Andrea Canciani
0268706550 path: Fix _cairo_path_fixed_transform
current_point and last_move_to were previously left in their old
position (which could lead to incorrect flag computation if other
operations were added to the path) and flags were not updated.
2010-10-29 17:31:23 +02:00
Andrea Canciani
29d5b18cba path: Recompute flags in _cairo_path_fixed_scale_and_offset
Only fill_maybe_region can change its value because the transformation
preserves vertical and horizontal lines, but can move the points and
make them integer if they were not or non-integer if they were.

Recomputing it is just as easy as checking if all the points are
integer and the path is fill_is_rectilinear.
2010-10-29 17:31:23 +02:00
Andrea Canciani
634fcf2c0a path: Transform current_point and last_move_to in _cairo_path_fixed_scale_and_offset
They were previously left in their old position (which could lead to
incorrect flag computation if other operations were added to the
path).
2010-10-29 17:31:23 +02:00
Andrea Canciani
9c0e4db570 path: Recompute flags in _cairo_path_fixed_translate
Only fill_maybe_region can change its value because the transformation
preserves vertical and horizontal lines, but can move the points and
make them integer if they were not or non-integer if they were.

Recomputing it is just as easy as checking if all the points are
integer and the path is fill_is_rectilinear.
2010-10-29 17:31:23 +02:00
Andrea Canciani
9d84dff0c6 path: Cleanup close_path
Instead of explicitly calling _cairo_fixed_move_to, setting the
needs_move_to flags is sufficient because the current_point is already
updeted correctly.
2010-10-29 17:31:23 +02:00
Andrea Canciani
17fef2fe4d path: Make _cairo_path_fixed_last_op assert on empty path
_cairo_path_fixed_last_op should now only be used on non-empty path
(to test if the previous operation was a line_to).
2010-10-29 17:31:23 +02:00
Andrea Canciani
568a975a62 path: Cleanup _cairo_path_fixed_iter_at_end
The last operation of a path cannot be a move_to anymore (since
move_to is only added if another operation is added after it).
2010-10-29 17:31:23 +02:00
Andrea Canciani
929571b4b5 path: Cleanup _cairo_path_fixed_transform
Clean up the code and make sure that _cairo_path_fixed_translate is
used whenever the _cairo_fixed_to_double rounding would result in the
matrix being approximated with a translation.
2010-10-29 17:31:23 +02:00
Andrea Canciani
34f1db13a1 path: Log flags
When logging path operations, also log computed flags.
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
Andrea Canciani
a2ac91eb5f path: Drop degenerate line_to in _cairo_path_fixed_curve_to
When a degenerate line_to is followed by a curve_to operation, the
line_to can be safely dropped, just like for degenerate line_to
followed by line_to.
2010-10-29 17:31:22 +02:00
Andrea Canciani
2352b48f9e path: Move _cairo_path_fixed_add at the end of line_to and curve_to 2010-10-29 17:31:22 +02:00
Andrea Canciani
46584e01a8 box: Add box header
Add a new header implementing very simple box functions:
 - initialization with the two extrema
 - extension with a point
 - in/out test
2010-10-29 17:31:22 +02:00
Andrea Canciani
65d57313f0 path: Cleanup _cairo_path_fixed_line_to
The low-level line_to optimizations can be implemented in a more
abstract way using _cairo_path_fixed_penultimate_point and
_cairo_path_fixed_drop_line_to.
2010-10-29 17:31:22 +02:00
Andrea Canciani
f3e7677109 path: Simplify close_path
Instead of explicitly computing the flag in close_path, manually close
the path with a line_to, then drop the last operation if it is a
line_to (it might be another operation if the line_to was ignored
because it would have been degenerate).
2010-10-29 17:31:22 +02:00
Andrea Canciani
641d314b9a path: Add utility functions
Add a function to get the penultimate point and another one to drop
the last operation (assuming it is a line_to).

This allows some more abstraction in the line_to and close_path code.
2010-10-29 17:31:22 +02:00
Andrea Canciani
4075ed9686 path: Rename _cairo_path_last_op to _cairo_path_fixed_last_op
Aestetical change, to make the naming consistent with that of the
other functions.
2010-10-29 17:31:22 +02:00
Andrea Canciani
a8763d8fde path: Make path equality independent of flags
Flags for the same path can be different depending on its "history"
(in particular if it was constructed and transformed they might be
different from what they would be if each point was transformed and
then the path constructed).
2010-10-29 17:31:21 +02:00
Andrea Canciani
f4b2ce1c78 path: Improve hashing
Make the hash independent of buf bucketing, extents and flags.

This makes the hash depend only on the actual content of the path, not
on how it is stored or on any computed property.
2010-10-29 17:31:21 +02:00
Andrea Canciani
14cc9846b3 path: Replace _cairo_path_fixed_is_equal with _cairo_path_fixed_equal
Remove _cairo_path_fixed_is_equal and use _cairo_path_fixed_equal
instead.
The latter function can recognize that two paths are equal even if the
drawing commands have been partitioned in a different way in the buf
list.
2010-10-29 17:31:21 +02:00
Chris Wilson
eeafeebd2e path: Exponentially grow buffer based on populated points and ops.
Instead of simply doubling the buffer size every time we overflow a point
or an op, enlarge the buffer to fit twice the number of used points and
ops.  We expect paths to be fairly consistent in the mix of operations,
and this allows the buffer size to tune itself to actual usage and reduce
wastage.
2010-06-11 09:06:20 +01:00
timeless
01a208f7e3 Remove useless null checks of a and b in _cairo_path_fixed_equal
'a' and 'b' are dereferenced before being checked for null.

From https://bugzilla.mozilla.org/show_bug.cgi?id=555706
2010-05-07 10:24:49 -04: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
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
74ea4c9080 path: Do not remove anti-parallel line segments in case we are stroking
Bug 26010 - cairo_line_to optimizes away path segments
  http://bugs.freedesktop.org/show_bug.cgi?id=26010

As exercised by path-stroke-twice, we incorrectly optimise away a line
segment if the path doubled back upon itself. This is very reminiscent
of the optimisation bug for replacing curve-to with line-to.
2010-01-12 17:07:30 +00:00
Chris Wilson
19c411a5b8 path: Skip any secondary degenerate line-to segments.
Only the very first line-to following a move-to can have any
significance if degenerate whilst stroking, so skip all others.
In other words,

  0 0 m 0 0 l stroke

produces a capped degenerate path (i.e a dot),

  0 0 m 0 0 l 0 0 l stroke

produces the same degenerate stroke, and

  0 0 m 0 0 l 1 0 l stroke

produce a horizontal line.
2009-10-30 08:08:27 +00:00
Chris Wilson
23bcf91748 path: Misclassification of rectilinear after degenerate line-to
Malte Nuhn reported hitting an assertion:

  cairo-path-stroke.c:1816: _cairo_rectilinear_stroker_line_to: Assertion `a->x == b->x || a->y == b->y' failed.
  http://bugs.freedesktop.org/show_bug.cgi?id=24797

when stroking an apparently simple path:

  0 8.626485 m
  0 8.626485 l
  5.208333 2.5 l
  10.416667 2.5 l
  15.625 2.5 l
  20.833333 2.5 l
  26.041667 2.5 l
  31.25 2.5 l
  36.458333 2.5 l
  41.666667 2.5 l
  46.875 2.5 l
  52.083333 2.5 l
  57.291667 2.5 l
  62.5 2.5 l
  67.708333 2.5 l
  72.916667 2.5 l
  78.125 2.5 l
  83.333333 2.5 l
  88.541667 2.5 l
  93.75 2.5 l
  98.958333 2.5 l
  104.166667 2.5 l
  109.375 2.5 l
  114.583333 2.5 l
  119.791667 2.5 l
  125 2.5 l
  stroke

which upon reduction becomes:

  0.000000 8.625000 m 5.207031 2.500000 l 125.000000 2.500000 l stroke

The bug is that after spotting a repeated line-to we move the previous
end-point without reclassifying the path, hence we miss the
non-rectilinear step.
2009-10-30 08:08:13 +00:00
Chris Wilson
5393aa6d6c [path] Return the canonical box.
When returning the single box that represents a path, always return it
consistently wound.
2009-08-29 17:07:40 +01:00
Chris Wilson
20cdb99ae8 [path-fixed] Distinguish cw and ccw boxes
To correctly handle retessellating trapezods constructed from alternately
wound boxes, then we need to pass that information from the path to the
tessellator. We do this by switching the direction of the box if the first
edge is horizontal as opposed to vertical.
2009-08-29 17:07:39 +01:00
Chris Wilson
cfd78393f3 [path] Handle the implicit close for path_fixed_is_box()
_cairo_path_fixed_is_box() is only called for filled paths and so must
handle the implicit close (which was already being correctly handled by
_cairo_path_fixed_iter_is_box).
2009-08-29 17:07:38 +01:00