Commit graph

9110 commits

Author SHA1 Message Date
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
Andrea Canciani
7b188f852e test: Make huge-* test gradients not within pixed_fixed_t range
Cairo represents gradients coordinate with 24.8 fixed point precision,
but pixman uses 16.16 fixed point coordinates.

This shows that cairo is currently unable to handle gradients with
coordinates which are valid for cairo but not for pixman.
2011-01-02 18:31:50 +01:00
Andrea Canciani
51594d9787 matrix: Cairo matrix to pixman transform/offset conversion
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a
backend-specific transform.

The code did not handle correctly some matrices, thus a new function
that performs the conversion in a more generic way was added and used
in the backends instead of fixing the repeated code.

Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
2011-01-02 18:31:42 +01:00
Andrea Canciani
ada6057b8c test: New radial-gradient tests
The old radial gradient tests were actually drawing the same gradients
with different operators (OVER/SOURCE) and operations (paint/mask).

It is possible to refactor them to share the gradient construction
code. This makes it easy to change the gradient shape in all of them
to test more interesting combinations.

Instead of testing 16 generic positions we are now testing just 7
cases, which correspond to every possible combination of the relative
size and position of the two circles defining the gradient. In
particular we are now testing a constant radius gradient and gradients
with tangent circles.
2011-01-02 18:31:35 +01:00
Andrea Canciani
b4aa01f72f pattern: Make functions not used elsewhere static
_cairo_pattern_init_linear() and _cairo_pattern_init_radial() are only
called from within cairo-pattern.c
2011-01-02 18:31:25 +01:00
Andrea Canciani
b0aef7202d pattern: Use cairo_color_stop_t when hashing gradient stops
Since 18b48a6ebc the color of each
gradient stop is stored in a cairo_color_stop_t, but
_cairo_gradient_color_stops_hash() was not updated accordingly.
2011-01-02 18:31:07 +01:00
Andrea Canciani
0501777598 pattern: Remove unused 'opaque' variable
opaque is never read, thus it can be removed.
2011-01-02 18:31:03 +01:00
Andrea Canciani
5d5d24c6a2 doc: Add documentation for the mesh API
The documentation content is in the comments of the functions.
2011-01-01 13:05:14 +01:00
Adrian Johnson
a8344f98e7 test: Add tests for mesh patterns
mesh-pattern tests a mesh pattern with non-opaque two overlapping
patches.

mesh-pattern-accuracy tests the accuracy of the color computed in each
point of a patch. It can point out defects in rasterizers which rely
on mesh subdivision only use the mesh shape instead of both shape and
color to decide when the tensor-product patches can be approximated
with Gouraud-shaded triangles.

mesh-pattern-conical is an example of how a conical gradient can be
approximated with a mesh pattern.

mesh-pattern-control-points tests a mesh pattern with control points
in non-default position to verify that their position affects the
color as expected.

mesh-pattern-fold tests a mesh pattern with a patch which folds along
both sides.

mesh-pattern-overlap tests a mesh pattern with a patch which folds
along just one side.

mesh-pattern-transformed tests a mesh pattern with non-identity
transform matrix.
2011-01-01 13:05:14 +01:00
Andrea Canciani
b164187ff6 test: Extend pattern-get-type and pattern-getters for mesh patterns
Add testing for mesh patterns to pattern-get-type and pattern-getters.
2011-01-01 13:05:13 +01:00
Andrea Canciani
96426fdf01 script: Add support for mesh patterns
Extend CairoScript with operators based on the mesh pattern API.
2011-01-01 13:05:13 +01:00
Adrian Johnson
c243f3ac9c pattern: Add public mesh pattern API
Add public funcions to create and define mesh patterns and getters to
examine their definition.
2011-01-01 13:05:13 +01:00
Adrian Johnson
30636206b0 pdf,ps: Add native mesh pattern support
PS and PDF have native support for mesh patterns, but they have encode
mesh points and colors in an appropriate binary stream.

cairo_pdf_shading_* functions implement the encoding, which is the
same for PDF and PS.
2011-01-01 13:05:13 +01:00
Andrea Canciani
8df122cb4b Add mesh gradient rasterizer
Add an implementation of a fast and reasonably accurate
non-antialiased mesh gradient rasterizer.
2011-01-01 13:05:12 +01:00
Andrea Canciani
f3c34887bd gstate: Disallow incomplete mesh gradient sources
Mesh gradients are constructed using multiple commands, bracketed by
explicit begin/end pairs. Using a mesh gradient inside a begin/end
pair is not allowed.
2011-01-01 13:05:12 +01:00
Adrian Johnson
ed24deaa2e mesh: Add mesh pattern type and enum values
Add the mesh pattern type and an error status to be used to report an
incorrect construction of the pattern.

Update the backends to make them ready to handle the new pattern type,
even if it cannot be created yet.
2011-01-01 13:05:12 +01:00
Andrea Canciani
19b840a904 Keep makefiles in alphabetical order
Recording surfaces were at first called meta surfaces. When the name
was changed, makefiles were not updated to keep alphabetical order.
2011-01-01 13:05:12 +01:00
Andrea Canciani
8f598dd69d quartz: Use native PDF blend modes
Quartz supports PDF blend modes since 10.4 and exposes Porter-Duff
compositing operators through the public API since 10.5.
2011-01-01 12:54:32 +01:00
Andrea Canciani
fabbc16253 quartz: Don't dynamically load unused functions
Remove an unused variable.
2011-01-01 12:54:32 +01:00
Andrea Canciani
1bc7d948c7 quartz: Clean up dynamically loaded functions
README indicates MacOSX 10.4 as a requirement for quartz and we are
directly using some functions that have been added to the public
CoreGraphics API in 10.4.

rop 10.3-specific workarounds and link to 10.4 API functions instead
of loading them at runtime.
2011-01-01 12:54:15 +01:00
Uli Schlachter
7f68461e0b Detach snapshots after flushing in cairo_surface_finish()
Flushing a surface can attach snapshots to it, thus we have to detach
the snapshots after the flush, to make sure they aren't leaked.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-29 17:44:07 +01:00
Uli Schlachter
59ac884c60 Verify that surfaces leak no snapshots
Finished surfaces should own no snapshots, because finished surfaces
can't be used as sources, thus their snapshots would never be used.

When free'ing the surface in cairo_surface_destroy(), it should have
no snapshots, or they will be leaked.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-29 17:16:51 +01:00
Chris Wilson
a4ae7d59be gl: Enable PLT symbol hiding for dispatch entries
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-12-25 09:50:34 +00:00
Uli Schlachter
109fcb3950 XCB: Stop taking the xcb socket
This makes the xcb backend use the auto-generated xcb API instead of
hand-writing each request. This should also improve parallelism with non-cairo
threads that use the same xcb connection.

Big thanks to Andrea Canciani for taking a look at this and finding lots of good
improvements (especially finding xcb_send_request was great).

cairo-perf-trace and cairo-perf-diff-files between master
(6732dbf299) and this change:

 $ ./cairo-perf-diff-files ../master_perf ../xcb_no_socket_perf
old: master_perf
new: xcb_no_socket_perf
Speedups
========
  xcb-rgba                  evolution-0    23558.86 (23558.86 0.00%) -> 19338.78 (19338.78 0.00%):  1.22x speedup
▎
  xcb-rgba          poppler-bug-12266-0     98.43 (98.43 0.00%) ->  82.36 (82.36 0.00%):  1.20x speedup
▎
  xcb-rgba         gnome-terminal-vim-0    5518.08 (5518.08 0.00%) -> 4905.92 (4905.92 0.00%):  1.12x speedup
▏
  xcb-rgba    gnome-terminal-20090601-0    45648.46 (45648.46 0.00%) -> 41231.25 (41231.25 0.00%):  1.11x speedup
▏
  xcb-rgba         evolution-20090607-0    71643.69 (71643.69 0.00%) -> 66314.95 (66314.95 0.00%):  1.08x speedup
▏
  xcb-rgba                    poppler-0    3501.69 (3501.69 0.00%) -> 3322.26 (3322.26 0.00%):  1.05x speedup

Slowdowns
=========
  xcb-rgba       gnome-system-monitor-0    7500.01 (7500.01 0.00%) -> 7923.70 (7923.70 0.00%):  1.06x slowdown

  xcb-rgba        swfdec-youtube-full-0    26409.89 (26409.89 0.00%) -> 28430.76 (28430.76 0.00%):  1.08x slowdown
▏
  xcb-rgba gnome-system-monitor-20090821-0    34801.61 (34801.61 0.00%) -> 37891.14 (37891.14 0.00%):  1.09x slowdown

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-12-25 09:50:34 +00:00
Uli Schlachter
cf0a4ed862 xcb: Remove a wrong optimization
Clear surfaces with an alpha channel are already replaced with a
transparent color in gstate, so this code was never hit.

Clear surfaces without an alpha channel, can be replaced with solid
black only if the surface pattern has an extend other than
CAIRO_EXTEND_NONE.

Fixes the clear-source test for xcb.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Andrea Canciani <ranma42@gmail.com>
2010-12-18 15:50:29 +01:00
Uli Schlachter
e6c3efdd65 xcb: Work around wrong extent computation in the X server
The X server calculates the bounding box for traps and then allocates
a temporary picture for this. When the X server calculates different
values than cairo got in extents->bounded, unbounded operators will
have wrong results. The X server only ever calculates bounds that are
larger than the correct values.

Fix this by explicitly clipping the drawing to the expected bounds.

Fixes clip-fill-{eo,nz}-unbounded and clip-stroke-unbounded.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Andrea Canciani <ranma42@gmail.com>
2010-12-18 15:48:53 +01:00
Andrea Canciani
4e3eb5e8ed gl: Fix #include's to pass 'make check'
'make check' complains that:
Checking that private header files #include "some cairo header" first (or none)
cairo-gl-dispatch-private.h:#include <stddef.h>
Checking that source files #include "cairoint.h" first (or none)
cairo-gl-dispatch.c:#include "cairo-gl-private.h"
cairo-gl-info.c:#include "cairo-gl-private.h"
2010-12-17 19:41:57 +01:00