Commit graph

9136 commits

Author SHA1 Message Date
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
Andrea Canciani
e0b741de90 test: Add group-state
The interaction between the group and the state API is currently
untested and buggy. This test tries to use them incorrectly and check
that cairo notices the problem and marks the cr object with an error
status.
2011-01-22 11:59:38 +01:00
Andrea Canciani
b51520628d clip: Improve _cairo_clip_contains_*
_cairo_clip_contains_rectangle() considered a NULL clip empty instead
of containing everything.

_cairo_clip_contains_rectangle() checks for NULL clips, so we don't
have to check for them in _cairo_clip_contains_extents().
2011-01-22 11:56:37 +01:00
Mats Palmgren
47d14586f5 win32: Improve error logging
On win32 stderr is fully buffered, so fflush() should be called after
each error to ensure it is printed to the console.

There is no need to use fwprintf if the format string can be
represented as char*.

See https://bugs.freedesktop.org/show_bug.cgi?id=33319
2011-01-21 09:56:46 +01:00
Andrea Canciani
72a9d49a53 Bump pixman requirements to 0.20.2 for radial gradients
Pixman has PDF-like radial gradients since 0.20.0, but the
implementation of the tangent circles case was not correct. This has
been fixed in 0.20.2, along with some invalid operations fixes.
2011-01-19 15:04:49 +01:00
Andrea Canciani
67cfb20bd0 test: Workaround pixman limits in large-source-roi
Since 1cc750ed92a936d84b47cac696aaffd226e1c02e pixman won't perform
the compositing if it can't prove that this the computations it has to
perform will fit within the size of the variables it uses.

It looks like in this case it cannot prove that no overflow will
happen unless surface_width <= 30582. Instead of this size (discovered
by bisection), a safer looking 30000 was chosen. It should still
trigger the problems the original test was looking for, because
backends which support 30000xheight surfaces will likely support
32767xheight as well.
2011-01-19 14:41:52 +01:00
Andrea Canciani
b8e7bfdff0 quartz: Respect pattern filter settings
CAIRO_FILTER_FAST and CAIRO_FILTER_NEAREST both map to nearest
neighbor filtering, whereas all other filter modes are names for
bilinear filtering.

Additionally, translations matrices are transformed into integer
translations when possible (i.e. when they are used on an nearest
neighbor filtered surface pattern), which makes Quartz behave as
cairo-image for these simple transformations.

Fixes a1-image-sample, a1-mask-sample, filter-nearest-offset.

Improves the output of filter-nearest-transformed and
rotate-image-surface-paint. They are not blurry anymore, but they are
different from the reference images because of different in/out rules
between Quartz and cairo-image.
2011-01-19 13:27:33 +01:00
Andrea Canciani
45da39dda7 quartz: Avoid using private APIs
CGContextSetCTM() is not part of the public API and can easily be
replaced by CGContextConcatCTM()-ing an appropriate matrix.
2011-01-19 12:00:58 +01:00
Andrea Canciani
ca9068839b quartz: Use CGLayer to implement unbounded operators
Quartz operators are not unbounded, but it is possible to implement
unbounded operators by using a temporary destination.

Fixes clip-stroke-unbounded, clip-fill-nz-unbounded,
clip-fill-eo-unbounded, clip-operator, operator-alpha-alpha,
overlapping-glyphs, surface-pattern-operator, unbounded-operator.
2011-01-19 12:00:58 +01:00
Andrea Canciani
d7e3637af2 quartz: Cleanup extents computation
All the draw operations use the same code to compute the gradient
parameter range. It can be moved to the function which sets up the
source.
2011-01-19 11:53:53 +01:00
Andrea Canciani
aa2fb0c05f quartz: Do not use opaque patterns as masks
When an opaque surface is used as a mask, Quartz converts it to
greyscale and uses the result as an alpha value. Cairo expects the
mask operation to ignore the color components and only use the alpha
of the pattern.

The expected behavior can be achieved by drawing the mask on a
temporary surface with an alpha channel.

Fixes clear-source.
2011-01-19 11:53:53 +01:00
Andrea Canciani
7d89d69c49 quartz: Make huge domain handling more stable
Quartz cannot correctly handle arbitrary domains. Falling back is
needed to get correct results on very large (in parameter space)
gradients.

For PAD extended gradients, limiting the domain to (at most) [-0.5,
1.5] is sufficient to guarantee that it will correctly sample the
extreme stops and improves the accuracy (over having a much bigger
domain).

Fixes radial-gradient, radial-gradient-mask, radial-gradient-source,
radial-gradient-mask-source, radial-gradient-one-stop.

Improves the quality of the linear gradients in linear-gradient,
linear-gradient-subset, mask, operator-source, trap-clip.
2011-01-19 11:53:52 +01:00
Andrea Canciani
4874dab984 quartz: Use standard stack allocation size
Make cairo-quartz respect the convention that stack-allocated data
structures use the size computed by CAIRO_STACK_ARRAY_LENGTH ().

Additionally this increases the size of the dash and glyph arrays,
making dynamic memory allocation less likely.
2011-01-19 11:53:52 +01:00
Andrea Canciani
5a1e590b12 test: Update quartz ref images
The following commits fix and/or improve the output of some tests.
Updating the ref images before fixing the code allows to check that
the fix is correct and makes it easy to find out which tests are fixed
by each commit.
2011-01-19 11:52:41 +01:00
Andrea Canciani
2e75bf5a25 test: Fix operator-alpha-alpha
The test is checking the compositing of color-alpha sources although
it was meant to check the compositing of alpha-only sources on
alpha-only destinations.

This commit fixes the code to respect the test description.
2011-01-19 11:52:40 +01:00
Andrea Canciani
45505fc5fb Add a results.tar.gz target to the test Makefile
Sometimes it is useful to be able to package the result of a run of
the testsuite. This new target creates an archive containing the html
page and at least all the files it links to.

The archive might contain some unneeded images.
2011-01-18 16:00:08 +01:00
Andrea Canciani
8c031c029d pdf,ps,quartz: Use correct tolerance for gradient domain computation
The tolerance argument of _cairo_gradient_pattern_box_to_parameter ()
is in pattern space, so to have it constant in device space, it should
depend on the pattern matrix.

In ps and pdf the fallback resolution alone is not meaningful. The
resolution/fallback_resolution ratio should be used instead.
2011-01-18 15:15:28 +01:00
Andrea Canciani
78eade13b1 gl: Don't ignore offset for gradient sources
_cairo_gl_operand_init() has parameters to specify an offset for the
source and another for the destination.

_cairo_gl_gradient_operand_init() incorrectly assumed that the two
offsets were identical.

Fixes mask, radial-gradient-mask-source.
2011-01-18 15:10:55 +01:00
Andrea Canciani
49171fb534 gl: Update radial gradient implementation
Cairo assumes that radial gradients are drawn as defined in ISO3200
since b661bc8712.

To implement them in GLSL, three different shaders are required:
 - tangent circles (a=0 in the parameter equation)
 - none-extended gradient (solutions outside [0,1] must be ignored)
 - extended gradient

Moreover, texcoords are used instead of gl_FragCoord, to fix the
flipping as per 31e116f084.

Fixes huge-radial, radial-gradient, radial-gradient-extend,
radial-gradient-mask, radial-gradient-source.
2011-01-18 15:10:55 +01:00
Robert O'Callahan
922bbd4320 tee: Do not apply two times the master device transform
cairo_tee_surface_create copies the device transform from 'master' to
the new surface. This is wrong since all the cairo_surface_wrapper
functions apply master's device transform themselves.

Reviewed-by: Benjamin Otte <otte@redhat.com>
2011-01-18 13:55:02 +01:00
Andrea Canciani
b0e1c837ac gl: Ensure that gl surface resizes are properly applied
If a gl surface is resized (with cairo_gl_surface_set_size()) while being the
current target, the resize does not take effect until the target changes to a
different surface and back to the original one. This patch allows a gl_context
to track when the current target surface has been changed and ensures that a
resize always take effect the next time a resized surface is used as the target.
2011-01-18 06:36:06 +02:00
Alexandros Frantzis
45331fe87c gl: Fix condition that prevents setting the size of window surfaces
A typo in cairo_gl_surface_set_size() prevents resizing of window surfaces
while incorrectly allows resizing of texture-backed surfaces.
2011-01-18 06:36:06 +02:00
Andrea Canciani
55c57a5b3d mesh: Do not declare min and max functions
Using the names "min" and "max" is likely to cause collisions. Instead
of them, use the MIN and MAX macros provided by cairoint.h

Reviewed-by: Uli Schlachter <psychon@znc.in>
2011-01-17 23:15:00 +01:00
Andrea Canciani
e6e0161b7e xcb: Add a short comment to the Picture cache
When we create a temporary cairo_xcb_picture_t, we want to be able to
reuse it, but we don't want the Picture to be alive forever to eat up
resources when it is not being used anymore.

When a surface pattern is about to be used for compositing, if it has
a cairo_xcb_picture_t snapshot, the latter is just reused. Otherwise a
new cairo_xcb_picture_t with the same content is created and attached
as a snapshot to the surface.

To keep the resource usage bounded we keep a per-screen cache of
cairo_xcb_picture_t. When the cache is full, a random entry is evicted
and we detach this snapshot from the surface that it is a snapshot
for. It will be immediately destroyed if nothing else holds a
reference to it. Otherwise it will be charged against the holder of
the reference, so it won't count anymore in the resources occupied by
the cache elements. This makes sure that the cached surface isn't
kept alive indefinitely because of caching.

Based on a patch by Uli Schlachter.
2011-01-17 23:09:27 +01:00
Uli Schlachter
7f83b4e949 xcb: Don't finish snapshots when they are detached
Some code might own a reference to the snapshot when it is
detached. For this reason, we shouldn't finish the snapshot except
when its reference count drops to zero.

This avoids destroying source patterns which get evicted from the
cache while acquiring the mask.

Fixes xcb-stress-cache.

Big "thank you" to Andrea Canciani for helping in figuring this one out.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-17 22:21:20 +01:00
Uli Schlachter
44095f3dde Add a test case for a bug in the xcb backend
This was found via cairo-perf-micro which sometimes triggered this bug in its
mask-similar_image-* test.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-17 22:21:20 +01:00
Andrea Canciani
01799bf052 Fix optimization of white IN dest compositing
The optimization of any opaque color IN an alpha-only surface is a
noop (it multiplies the alpha of each pixel of the destination by 1).
The same does not apply to colored destinations, because IN replaces
the original color with the color of the source.

Fixes white-in-noop.
2011-01-17 12:18:21 +01:00
Andrea Canciani
9e6d8ff86c test: Add missing ref image to REFERENCE_IMAGES 2011-01-17 12:17:30 +01:00
Andrea Canciani
2af0b0f5da test: Add white-in-noop
Exercise an incorrect optimization in cairo-surface.c. It replaces
with a noop any region-based fill with solid white source and an IN
operator.
2011-01-17 10:59:33 +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
32241cde01 doc: Add links to flush() and mark_dirty() in direct access functions
cairo_image_get_data() and other direct access functions are often
misused by applications because they don't call cairo_surface_flush()
and/or cairo_surface_mark_dirty() around the code which accesses the
surface data directly.

Although this information is already available in the description of
the cairo_surface_t type, adding a reminder about it in the direct
access functions should make it easier to use them correctly.
2011-01-16 18:40:42 +01:00
Maarten Bosmans
01c66d34c3 doc: Add a remark about toy status of the PNG API
The PNG API is just a toy API whose main purpose is to make it easy to
write minimal examples of cairo features or testcases for bugs. For
these purposes there is no need to tune the output PNG file or to
provide additional information in optional PNG chuncks, but real
applications need to do that quite often. The documentation now points
out what is the correct procedure to write image data to a file.
2011-01-10 18:25:09 +01:00
Andrea Canciani
14afb69d3d xlib: Handle a wider range of glyph positions
Backport the change from 588dead005 to
Xlib.
2011-01-07 00:19:55 +01:00
Andrea Canciani
588dead005 xcb: Handle a wider range of glyph positions
_can_composite_glyphs() checks that the position of each glyph can be
represented as a 16-bit offset from the destination origin.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=31897
2011-01-06 11:37:28 +01:00
Andrea Canciani
10bae9d9ce xcb: Stricter glyph validation
To ensure that we can correctly issue the glyph operation, glyph size
must fit in an XCB request and its position must be within the
representable range (16-bit offset).
2011-01-06 11:37:28 +01:00
Andrea Canciani
c3f9a0cf47 xcb: Correct handling of index 0 glyphs
Glyph caches (with direct glyph index matching) cannot be completely
initialized with zeroes, otherwise the code will incorrectly believe
that the lookup for the 0-index glyph has already been performed.
2011-01-06 11:37:28 +01:00
Uli Schlachter
a87001c063 xcb: Fix premature pixmap free in boilerplate cleanup
A xcb surface has to be finished before the associated drawable can be freed or
there will be X11 errors when the surface is later finished or used again.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Uli Schlachter
673c44d3e8 xcb: Check the check for errors in boilerplate
We have to make sure we received all errors that the X server sent out before we
can be sure there are none. To do so, we just have to send some request and wait
for its reply, because that guarantees that the replies/errors to all previous
requests were received.

_cairo_boilerplate_xcb_synchronize doesn't need this, because the GetImage
request already makes sure we received everything.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Uli Schlachter
51626ed2ee xcb: Check harder for X11 errors in boilerplate
This commit makes the boilerplate code check for errors from the X server before
disconnecting and during synchronize. This should make sure no errors are ever
lost and silently ignored.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Uli Schlachter
f8277dfdaf xcb: Only print the first error and ignore subsequent ones
It is quite likely that following errors are caused by the previous ones. To
avoid flooding users we now silently discard all the errors and events after the
first one.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Uli Schlachter
8a65279ee1 xcb: Add a define for some magic number
In X11, errors look like events with response_type == 0. Using a define looks
better than just a "trust me!".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Uli Schlachter
8957e50632 xcb: Handle events in boilerplate
Cairo shouldn't cause any events during a test run. Verify this by explicitly
handling events, too.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-05 22:04:45 +01:00
Andrea Canciani
f0bb3a29b3 pattern: Remove unused _cairo_pattern_size function
'git log -S_cairo_pattern_size' only finds the commit
a856371bef, in which this function was
added, thus it looks like it has never been used.
2011-01-03 20:13:31 +01:00
Uli Schlachter
e5f54bb9f3 XCB: Make sure SHM memory isn't reused too early
This commit delays the return of a SHM area to the free pool. When
_cairo_xcb_shm_info_destroy is called, it now adds the cairo_xcb_shm_info_t to a
list of pending memory areas and sends a GetInputFocus request to the server.

This cairo_xcb_shm_info_t is only really freed when the GetInputFocus request
completes. To avoid unnecessarily waiting for the X server, we check via
xcb_poll_for_reply for the reply which returns immediately if the reply isn't
received yet.

This commits fixes a race where the shared memory area is reused before the X
server finished reading data from it. This does NOT fix races where cairo draws
something new to the same cairo_xcb_shm_info_t while the X server still reads
from it. However, there doesn't seem to exist any code currently where the shm
info isn't immediately destroyed after it was used.

This commit fixes the following tests for xcb-render-0.0 if SHM is enabled:

joins mask mask-transformed-image push-group push-group-color radial-gradient
radil-gradient-mask radial-gradient-mask-source radial-gradient-one-stop
radial-gradient-source smask smask-mask smask-paint

This also fixes mesh-pattern-transformed for all the xcb boilerplate "backends".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-02 23:50:47 +02:00
Uli Schlachter
6b4e07d143 Switch the order of two functions in the C file
The following commit adds a call to _cairo_xcb_shm_info_destroy to some function
in-between, but it also renames it and does some other changes to this. Thus,
move this function first to make the diff easier to read. :)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-02 23:50:47 +02:00
Uli Schlachter
30b961f895 Remove an unused field from cairo_xcb_shm_info_t
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-01-02 23:50:47 +02:00
Andrea Canciani
c72c7aa6d6 matrix: Fix warnings about documentation by 'make check'
'make check' complains about the syntax of the documentation: the
space between the function name and the parenthesis is not allowed.
2011-01-02 19:32:26 +01:00
Andrea Canciani
200e147322 pattern: Use double precision for gradient extreme objects
Using double precision for gradient extreme objects ensures that they
are preserved as specified when constructing the gradient pattern.

Fixes huge-linear, huge-radial.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:33:14 +01:00
Andrea Canciani
6472864b2c test: Huge means more than MAX_INT
Cairo makes it possible to create gradients whose extreme objects are
defined with double precision coordinates, but it internally
represents them with 24.8 fixed point precision.

This shows that coordinates that don't fit the valid range are
mishandled and don't even trigger an error status.
2011-01-02 18:32:46 +01:00
Andrea Canciani
38dce5d144 pattern: Factor out pattern rescaling
The same code was duplicated (incorrectly and with some minor
differences) in pattern, image, xlib and xcb.

_cairo_gradient_pattern_max_val() abstracts that code in a function
that can be used whenever a gradients extremes need to be rescaled to
fit within a given range.

Fixes huge-linear, huge-radial.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:32:13 +01:00