Commit graph

6515 commits

Author SHA1 Message Date
Chris Wilson
09589e20e1 [clip] Intersect to region extents.
When querying the intersection of a rectangle with the clip region, the
result only depends upon the region extents so we do not need to perform
an expensive region-region intersection computation.
2008-12-12 12:00:40 +00:00
Chris Wilson
c5acb125e9 [surface] Avoid a short-lived context during fallback_clone_similar()
We can paint to the surface directly without need of a temporary context,
so do so.
2008-12-12 12:00:36 +00:00
Chris Wilson
888f62feaa [test] Propagate error from path
If the path is in error, just append it to the context so that the error
is propagated correctly.
2008-12-12 11:11:49 +00:00
Chris Wilson
f13f63e3d8 [test/clip-nesting] Propagate status from sub-context.
Use cairo_path_append() to propagate an error status from a child context
to it parent so that it is properly reported under memfault.
2008-12-12 11:11:49 +00:00
Chris Wilson
e6e33b036f [test/solid-pattern-cache-stress] Propagate status from sub-contexts.
Use a cairo_append_path() to set an arbitrary error status on the parent
context, in order to propagate errors from a child.
2008-12-12 11:11:49 +00:00
Chris Wilson
bcb2724920 [path] Mark points as const during _cairo_path_fixed_interpret()
Use const to document the read-only nature of the arguments passed to the
callbacks.
2008-12-12 11:11:49 +00:00
Chris Wilson
68b29cafa5 [spline] Propagate errors during add point.
Yikes! The callback could fail so we need to propagate the error status.
2008-12-12 11:11:48 +00:00
Chris Wilson
2f3905dec3 [image] Set status on error path.
We failed to set the status after cairo_image_surface_create() returned an
error.
2008-12-12 11:11:48 +00:00
Chris Wilson
dfc49a67e6 [test] Trim the number of fallback resolutions tested.
Simplify the test matrix to only include testing the fallback-resolution
of a uniform scale in one or both axes.
2008-12-12 11:11:48 +00:00
Chris Wilson
0ebbcd671c [test] Fix memleak from fallback-resolution.
The test-name was being recreated for every pass, but was never freed.
2008-12-12 11:11:48 +00:00
Chris Wilson
a9697e5fb0 [test] Exercise glyph culling.
Sascha Steinbiss reported an issue with glyph culling,
http://lists.cairographics.org/archives/cairo/2008-December/015976.html,
whereby we failed to update the text clusters upon culling the glyphs in
the gstate and proceeded to read beyond the end of the glyph array in the
PDF backend. This test case setups a similar condition as reported, by
trying to write a wide string into a small box.
2008-12-12 11:11:48 +00:00
Chris Wilson
095a1fd786 [gstate] Remove culled glyphs from clusters.
Sascha Steinbiss reported a bug where the PDF backend was reading beyond
the end of the glyph array:
http://lists.cairographics.org/archives/cairo/2008-December/015976.html.

It transpires that in the early glyph culling in the gstate we were
not updating the clusters to skip culled glyphs.
2008-12-12 10:20:47 +00:00
Julien Danjou
834f1d7b70 [xcb] check for render extension presence
Otherwise this may leads to an invalid memory access to r.

Fixes: Bug 18588 - XCB backend fails with missing render.
https://bugs.freedesktop.org/show_bug.cgi?id=18588

Signed-off-by: Julien Danjou <julien@danjou.info>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2008-12-12 10:20:47 +00:00
Chris Wilson
e184bf0d35 Fix compilation with --enable-png=no
Adrian Johnson spotted that the build was broken if the PNG functions were
disabled. Fix.
2008-12-12 10:20:47 +00:00
Jeff Muizelaar
391c602640 Merge branch '1.8' 2008-12-11 14:41:01 -05:00
Jeff Muizelaar
2f1b581f54 [quartz] Create a copy instead of increasing the reference
The pattern could be stack allocated so we can't take a reference to it.

Some testing of quartz shows that it doesn't deal with malloc failure particularily
well. In the best case CGFunctionCreate returns NULL, in the worst case it just crashes.
Quartz does seem to be able to handle a NULL CGFunctionRef, so returning NULL if
we fail to copy the pattern avoids complicating the code to deal with
propagating the failure and shouldn't cause any additional crashes.

Based on a patch by Paolo Bonzini.
2008-12-11 14:39:23 -05:00
Jeff Muizelaar
f7b3f1b7d7 [quartz] Propagate const patterns through the casts
As part of this avoid using cairo_pattern_get_matrix() because it requires a
'cairo_pattern_t *' instead of 'const cairo_pattern *'

Also, make a copy of the pattern before pasing it in to cairo_set_source()
2008-12-10 17:55:28 -05:00
Jeff Muizelaar
d93bf10edc [quartz] Create a copy of the pattern so that the reference counts are balanced
The pattern could be stack allocated so we can't take a reference to it;
instead make a copy.

Based on a patch by Paolo Bonzini.
2008-12-10 17:41:45 -05:00
Jeff Muizelaar
db4c427e84 [quartz] Change some pattern casts to access to the base class
Avoiding casts gives us some more type safety.
2008-12-09 12:03:11 -05:00
Jeff Muizelaar
5f60e2e004 Reorganize the (set|get)_antialias prototypes
Move _cairo_gstate_set_antialias() and _cairo_gstate_get_antialias() into the
gstate section of cairoint.h
2008-12-09 11:41:10 -05:00
Jeff Muizelaar
673640a3b3 [win32] Use MOD instead of the '%' operator
Repeat should be handled using MOD instead of '%' so that negative numbers
are handled as expected. E.g. -1 mod 600 = 599, not 495 as the '%' operator
gives. This was causing https://bugzilla.mozilla.org/show_bug.cgi?id=466258

Patch from Robert O'Callahan
2008-12-08 11:37:38 -05:00
M Joonas Pihlaja
5e06085b48 [cairo-spans] Render clip mask surfaces with spans if we can.
Generating surface masks for clipping can also benefit from span
rendering sometimes.
2008-12-07 03:51:07 +02:00
M Joonas Pihlaja
18634c3702 [cairo-spans] Hook up filling paths with spans to cairo-surface-fallback.c.
This speeds up the mask generation step in cairo_fill() for the image
surface by up to 10x in especially favourable cases.

image-rgba                              twin-800 7757.80 0.20% -> 749.41 0.29%: 10.36x speedup
image-rgba spiral-diag-pixalign-nonzero-fill-512   15.16 0.44% ->   3.45 8.80%:  5.54x speedup

More typical simple non-rectilinear geometries are sped up by 30-50%.
This patch does not affect any stroking operations or any fill
operations of pixel aligned rectilinear geometries; those are still
rendered using trapezoids.
2008-12-07 03:27:13 +02:00
M Joonas Pihlaja
85b81a3e59 [cairo-spans] Implement a span renderer for cairo_image_surface_t.
This implementation first produces an A8 alpha mask and then
pixman_image_composites the result to the destination with the source.
Clipping is handled by pixman when it is region clipping or by
cairo-surface-fallback when it is something more complex.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
7994fc06ad [cairo-spans] New cairo_tor_scan_converter_t.
Imports a new polygon scan converter implementation from the
repository at

http://cgit.freedesktop.org/~joonas/glitter-paths/

Glitter paths is a stand alone polygon rasteriser derived from David
Turner's reimplementation of Tor Anderssons's 15x17 supersampling
rasteriser from the Apparition graphics library.  The main new feature
in this implementation is cheaply choosing per-scan line between doing
fully analytical coverage computation for an entire row at a time
vs. using a supersampling approach.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
2078e5b20f [cairo-spans] New _cairo_path_fixed_fill_using_spans().
Adds a helper function for backends to use for filling a path using
spans.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
4a9b274eeb [cairo-spans] Add a check/create_span_renderer backend methods.
A surface will have the chance to use span rendering at cairo_fill()
time by creating a renderer for a specific combination of
pattern/dst/op before the path is scan converted.  The protocol is to
first call check_span_renderer() to see if the surface wants to render
with spans and then later call create_span_renderer() to create the
renderer for real once the extents of the path are known.

No backends have an implementation yet.
2008-12-06 14:04:36 +02:00
M Joonas Pihlaja
948c3526dc [cairo-spans] New abstract types for scan converting polygons.
A cairo_span_renderer_t implementation can be provided by a surface if
it wants to render paths as horizontal spans of the alpha component of
a mask.  Its job is to composite a source pattern to the destination
surface when given spans of alpha coverage for a row while taking care
of backend specific clipping.

A cairo_scan_converter_t takes edges of a flattened path and generates
spans for a span renderer to render.
2008-12-06 14:04:35 +02:00
M Joonas Pihlaja
4b227143b3 [cairo-spans] Introduce a type to track which pixels combine in a compositing op.
A cairo_composite_rectangles_t contains the coordinates of rectangular
windows into each of the source pattern, mask, clip and destination
surface containing the pixels that will combine in a compositing
operation.  The idea is to have a uniform way to represent all the
translations involved rather than overloading parameters like src_x/y,
dst_x/y, etc., sometimes with different incompatible meanings across
functions.
2008-12-06 14:04:35 +02:00
M Joonas Pihlaja
a370d077bc [path-fixed] New _cairo_path_fixed_is_region().
We want to hit the current fast paths for rendering axis aligned
rectilinear paths rather than spans, and for that we need to be able
to identify regional paths.
2008-12-06 14:04:35 +02:00
M Joonas Pihlaja
6acb822393 [path-fixed] Avoid extra indirection when iterating already flat paths.
Perform a plain iteration rather than a flattening one if the path
knows it doesn't have any curves.
2008-12-06 14:04:35 +02:00
Chris Wilson
0c0f4862c5 [perf-diff] Fix cairo-perf-diff for git 1.6
Since git 1.6 the plumbing commands aren't installed in the user's
path by default.  This patch fixes cairo-perf-diff to find the
git-sh-setup command from git's lib dir.
2008-12-06 13:32:37 +02:00
M Joonas Pihlaja
afba0c3129 [perf] Add perf tests to hit rectilinear code paths.
These tests look at the differences in code paths
hit by filling paths that are rectilinear (or not) and
pixel aligned (or not) with the even-odd and non-zero
fill rules.  The paths are not simple, so they don't
hit the special case quad/triangle tessellator.
2008-12-06 13:30:29 +02:00
M Joonas Pihlaja
8ec58113df [perf] Explicitly test rendering a path with lots of intersections.
We don't have one just for this purpose.  The only other
path with many intersections that gets actually rendered is zrusin-another,
but that might be sped up in the future (say by identifying
collinearities up front or something like that.)
2008-12-06 13:21:44 +02:00
Jeff Muizelaar
08b486c9aa [win32] Use MOD instead of the '%' operator
Repeat should be handled using MOD instead of '%' so that negative numbers
are handled as expected. E.g. -1 mod 600 = 599, not 495 as the '%' operator
gives. This was causing https://bugzilla.mozilla.org/show_bug.cgi?id=466258

Patch from Robert O'Callahan
2008-12-04 17:53:06 -05:00
Chris Wilson
540de34453 [matrix] Optimise invert for simple scaling|translation matrices.
Peter Hercek reported, and provided a very useful test case for, a bug
that caused his applications to crash with Cairo detecting an
non-invertible pattern matrix and thus asserting the impossible happened.
Bisecting revealed that the bug first appeared with 3c18d95 and
disappeared with 0d0c6a1. Since neither of these explain the crash,
further investigation revealed a compiler bug (gcc 4.3.3 20081130,
earlier versions have different bugs!) that caused the matrix inversion
to be invalid iff _cairo_matrix_scalar_multiply() was inlined (i.e. -O0,
or an explicit noinline atttribute on that function prevented the bug, as
did -msse.) So we apply this workaround to hide the bug in the stable
series...

The matrix is quite often just a simple scale and translate (or even
identity!). For this class of matrix, we can skip the full adjoint
rearrangement and determinant calculation and just compute the inverse
directly.
(cherry picked from commit 0d0c6a199c)
2008-12-02 17:31:51 +00:00
Behdad Esfahbod
aff32019a7 [Makefile.am] Use top_srcdir instead of srcdir
Doesn't make much difference here, but makes our intention clear.
2008-11-30 23:28:59 -05:00
Luo Jinghua
51a75ad932 glitz: Replace specified color with an opaque one if dst surface don't have an alpha channel.
Otherwise if underlying glitz drawable has an alpha channel, glitz_set_rectangles
will set its alpha channel to specified value instead of opaque one and effects following
composite operations since glitz draws to attached drawable then copies its content to
the dst surface. With this commit, three test cases such as operator, operator-alpha and
unbounded-operator passes now.
2008-11-30 21:44:36 +08:00
Chris Wilson
7247017cf5 Fix up a couple of likely(malloc==NULL)
Adrian Johnson spotted that I marked a few malloc failures as likely,
whoops.
2008-11-29 11:48:17 +00:00
Chris Wilson
1659db2c1f [test] Fix surface leak from device-offset-positive.
A forgotten cairo_surface_destroy() caused the similar surface to be
leaked during the test.
2008-11-29 11:20:35 +00:00
Chris Wilson
0d757a793d [png] Fix leak of original png data on error path.
The error path was missing a _cairo_output_stream_destroy() to cleanup a
copy of the incoming PNG data.
2008-11-29 11:20:34 +00: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
d1801c23fa Mark if(status) as being unlikely.
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
2008-11-29 11:20:33 +00:00
Chris Wilson
f0804d4856 [test] Exercise caps and joins under reflection.
The nature of the joins depends critically upon whether the joint is
clockwise or counter-clockwise, so extend the basic caps-joins test to
exercise both conditions i.e. repeat the test under a reflection.
2008-11-29 11:20:29 +00:00
Chris Wilson
f39dd86e29 [test] Add simple cap test.
Add a test case that only exercises capping, useful for developing
new strokers.
2008-11-29 10:14:26 +00:00
Chris Wilson
f2982e103c [fill] Allow rectangles to be implicitly closed.
Also scan for appendages of simple rectangles.
2008-11-29 10:14:26 +00:00
Chris Wilson
d2bcf1d76d [path] Carefully check for no more points.
As the empty path points to an embedded buf, we cannot rely on the buf
pointer being NULL to mark end-of-path.
2008-11-29 10:14:26 +00:00
Chris Wilson
424aba9be5 [check] Search for the word NOTE
Add word boundary markers around the regexp so that we only match for the
word NOTE and not on substrings like GL_NOTEQUAL.
2008-11-29 10:14:26 +00:00
Chris Wilson
36147140ce [perf] Fix build
If automake detects the use of cairo_perf_LDADD in an unused conditional
that overrides the default - so we need to manually set cairo_perf_LDADD.
2008-11-29 10:13:53 +00:00
Luo Jinghua
ed6bd4766c image: Use unsigned long to compute color masks.
Use unsigned long in the first place to prevent compiler from
expanding signed bit to all upper bits. e.g, a alpha mask 0xff0000
will expand to 0xffffffffff00000 on 64 bit platform which is not
what we expected.
2008-11-28 07:54:41 +08:00