Commit graph

10979 commits

Author SHA1 Message Date
Behdad Esfahbod
040a9f678b Check for XRenderSolidFill() 2013-12-16 19:27:38 -05:00
Adrian Johnson
dcbe16eb40 pdf/ps: avoid outputting excess decimal places in matrices
Sometimes as a result of rounding errors in matrix transformations the
matrices in ps/pdf output look like:

    0.000000000000000061 1 1 -0.000000000000000061 0 842 cm

This patch rounds to zero matrix elements that are very small compared to
other elements in the same matrix.
2013-12-07 15:54:49 +10:30
Uli Schlachter
31eff5c6eb Correct usage of CAIRO_STACK_ARRAY_LENGTH
This macro wants the array type as its argument and calls sizeof() on it
internally.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-11-16 19:05:35 +01:00
Henry Song
8c73949e44 gl: Fix one off issue in context cleanup
ctx->vertex_shaders is only CAIRO_GL_VAR_TYPE_MAX large, so we should
abort the loop before the index is equal to CAIRO_GL_VAR_TYPE_MAX.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2013-11-13 17:09:29 -08:00
Bryce Harrington
56a195a765 Fix SSIZE_T definition problem when making with MSYS on Windows7
Patch provided by Martin Schlemmer <Martin.Schlemmer@nwu.ac.za> on the
mailing list.

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2013-10-31 20:34:15 -07:00
Kouhei Sutou
66f4140e73 cairo_create(): Add finished surface check
Without this change, the following program crashes:

    #include <cairo.h>
    #include <cairo-svg.h>

    int
    main(int argc, char **argv)
    {
      cairo_t *cr;
      cairo_surface_t *finished_surface;

      finished_surface = cairo_svg_surface_create ("/tmp/xxx.svg", 1.0, 1.0);
      cairo_surface_finish (finished_surface);

      cr = cairo_create (finished_surface);
      cairo_destroy (cr);

      cairo_surface_destroy (finished_surface);

      return 0;
    }

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2013-10-31 20:34:04 -07:00
egag
b9263fea14 Fixes stroke-clipped, i.c. of a dashed stroke
Similar to 1f4d05b55c
 'Fix calling '_cairo_spline_intersect' for in-bounds checking of splines'

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2013-10-31 20:33:33 -07:00
Søren Sandmann Pedersen
98fef3cef2 _cairo_color_double_to_short(): Use standard rounding algorithm
The _cairo_color_double_to_short() function converts a double
precision floating point value in the range of [0.0, 1.0] to a
uint16_t integer by dividing the [0.0, 1.0] range into 65536
equal-sized intervals and then associating each interval with an
integer.

Under the assumption that an integer i corresponds to the real value i
/ 65535.0 this algorithm introduces more error than necessary as can
be seen from the following picture showing the analogous
transformation for two-bit integers:

    +-----------+-----------+-----------+-----------+
   0b00         |  0b01     |      0b10 |          0b11
    +-----------+-----------+-----------+-----------+

which shows that some floating point values are not converted to the
integer that would minimize the error in value that that integer
corresponds to.

Instead, this patch uses standard rounding, which makes the diagram
look like this:

    +-------+---------------+---------------+-------+
   0b00     |      0b01     |      0b10     |      0b11
    +-------+---------------+---------------+-------+

It's clear that if the values corresponding to the given integers are
fixed, then it's not possible to decrease the resulting error by
moving any of the interval boundaries.

See this thread for more information:

    http://lists.freedesktop.org/archives/cairo/2013-October/024691.html

Reference images updated:

  pthread-similar.ref.png
  record-paint-alpha.ref.png
  record90-paint-alpha.argb32.ref
  record90-paint-alpha.rgb24.ref.png
  xcb-huge-image-shm.ref.png
  xcb-huge-subimage.ref.png

All of these have only one-step differences to the old images.
2013-10-22 14:27:43 -04:00
Adrian Johnson
6f05ecf488 type1-subset: don't rename glyphs used by seac operator
Bug 70364
2013-10-11 19:59:50 +10:30
Chris Wilson
f1eefee985 win32: Reorder font declarations to be in natural order
Reported-by: John Emmas <johne53@tiscali.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-10-06 09:57:44 +01:00
Uli Schlachter
49366c5e9e cairo-xlib: Fix out of bounds array access in format cache
The cairo-xlib backend maintains a mapping form cairo_format_t to xrender
formats. This is done via an array. The size of this array is
CAIRO_FORMAT_RGB16_565 + 1 which evaluates to 5.

However, CAIRO_FORMAT_RGB30 has the numeric value 5, too. Thus, using this value
as an index into the array would actually read the following force_precision
field from cairo_xlib_display_t.

This could be triggered by passing CAIRO_FORMAT_RGB30 to
_cairo_xlib_display_get_xrender_format(). From a quick look, I didn't find any
code which would allow doing this, but neither did I find anything allowing
CAIRO_FORMAT_RGB16_565, so it's better to handle this correctly than assert()ing
for this to never happen.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-10-03 17:53:34 +02:00
Uli Schlachter
217bed84dd Revert "[xlib] Fast-path the likely case of retrieving a known xrender_format"
This reverts commit 09a2b2ed31.

Back in 2009, _cairo_xlib_display_get_xrender_format() had to acquire a lock to
do its job. The above commit added a fast-path which avoided the lock in most
cases.

However, in 2010 commit f74ad37e66 modified the
locking in the cairo-xlib backend and now this function never takes any locks.

Thus, the fast-path that was added a year earlier now just does the same thing
that the regular code does and the list of cached formats was checked twice.
Reverting the earlier commit fixes this.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-10-03 17:44:27 +02:00
Uli Schlachter
592e6a9803 README: Don't mention XFAIL_TESTS anymore
The variable XFAIL_TESTS is not used anymore since commit e90073f7dd.

Instead, we now have special reference images that show the wrong output and the
test suite fails a test if it does not match the expected, wrong output.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-10-03 16:59:11 +02:00
Uli Schlachter
bc89be2fff Remove XFAIL_TESTS from Makefile.am
The variable XFAIL_TESTS is not used anymore since commit e90073f7dd.

The description for the known failures are moved into the respective tests as
comments.

The following descriptions were dropped:

- surface-pattern-big: Didn't really explain the failure
- big-line: Test isn't failing any more
- self-intersecting: Only XFAIL on quartz, but description doesn't match this

The following tests don't have a xfail reference image and seem to fail just
because of not having a reference image at all (I kept their description for
now):

big-trap, long-lines, self-copy-overlap

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-10-03 16:58:52 +02:00
Adrian Johnson
5e6e453671 pdf: stencil masks may be opaque 2013-09-29 22:23:31 +09:30
Adrian Johnson
d3a8d5a9c2 pdf: Support stencil masks with jpeg/jpx/jbig2 embedding 2013-09-29 22:18:06 +09:30
Adrian Johnson
07940ecd60 pdf: combine source and mask images into single image
Since PDF stores the alpha component of images in a separate stream
which can have a different resolution and encoding to the color
components we can optimize the case where the source and mask are both images.

If the source and mask are both images with the same extents and the
source is opaque, combine the images into a single PDF image (ie the
source is written the the image stream and the mask is written to the
smask stream).
2013-09-29 13:08:02 +09:30
Chris Wilson
c1ac8db7e6 trace: Fix operand emission
Recent updates (in the past couple of years) to firefox have exposed
numerous bugs in the way we emit the operands. A few off-by-ones,
missing surfaces and outright bugs all of which are intermixed into
producing a corrupt stack.

Reported-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-27 16:37:24 +01:00
Uli Schlachter
0c2faf6621 fill_reduces_to_source(): Handle failure of color_to_pixel()
The function color_to_pixel() can fail for unsupported pixman image formats, but
fill_reduces_to_source() ignored this possibility.

Fix this by using the return value of color_to_pixel():

Fixes the following compiler warnings:

cairo-image-compositor.c: In function 'fill_boxes':
cairo-image-compositor.c:349:15: warning: 'pixel' may be used uninitialized in this function [-Wmaybe-uninitialized]
cairo-image-compositor.c: In function 'fill_rectangles':
cairo-image-compositor.c:304:18: warning: 'pixel' may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-27 15:42:24 +02:00
Bryce Harrington
38a925460b test: Drop unnecessary math.h include
Commit 0ac81988 refactored away fmin; nothing else from math.h is
needed.
2013-09-26 10:59:14 -07:00
Chris Wilson
337ab1f8d9 font: Push the last reference dec into the backend->destroy() callback
In order to close a race between locking the backend and resurrecting a
font via the cache, we need to keep the font face alive until after we
take the backend lock. Once we have that lock, we can drop our reference
and test if that was the last. Otherwise we must abort the destroy().

This fixes the double-free exposed by multithreaded applications trying
to create and destroy the same font concurrently.

Reported-by: Weeble <clockworksaint@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69470
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-17 16:37:47 +01:00
Chris Wilson
0ac81988c1 test/pixman-downscale: Open-code fmin()
fmin() requires a bump to either _XOPEN_SOURCE_ >= 600 (POSIX 2004) or
c99 - which is a needless dependency for a single simple routine.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-17 08:37:38 +01:00
Uli Schlachter
9c75065ece xcb: Remove useless error handling
All the *_reply() functions in XCB return a pointer to their result and as last
argument they get a xcb_generic_error_t** where pointers to errors are stored,
if any occurs.

However, a request can either fail or succeed. This means that if the returned
result is a NULL pointer, then an error occurred and the other way around: If
the error pointer is set to non-NULL, then the function must have returned NULL.

Thus, all the code, which just checks if an error occurred and which does not
care about the exact error code, does not need to get the error pointer at all.
In this case, xcb will free() the error internally.

While doing this, I noticed that _cairo_xcb_connection_get_image() always
succeeds and thus its return value can be replaced with the GetImage result.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-16 12:59:03 +02:00
Uli Schlachter
440624cdf2 test/multi-page: Fix use-after-free
Commit f9dcd07d22 changed the way the file name is allocated and introduced
a use-after-free in doing so.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-16 12:58:44 +02:00
Uli Schlachter
1d00550784 image: Handle PIXMAN_a8r8g8b8_sRGB in switch
Fixes the following compiler warning:

cairo-image-surface.c: In function '_cairo_format_from_pixman_format':
cairo-image-surface.c:93: warning: enumeration value 'PIXMAN_a8r8g8b8_sRGB' not
handled in switch

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58726
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-16 12:58:38 +02:00
Uli Schlachter
966bf2fe6a check-doc-syntax: Don't hardcode path to awk
Instead of expecting awk in /usr/bin, this commit changes the code to call awk
through a shell so that $PATH is searched.

Since this awk script shouldn't really be called manually, this is done by
removing the shebang from the awk script, marking it non-executable and fixing
up the caller.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67674
Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-16 12:57:57 +02:00
Uli Schlachter
a8a805b8d9 cairo-gobject: Require at least glib 2.14
cairo-gobject uses g_once_init_enter() and g_once_init_leave(). These functions
were added in glib 2.14 and thus cairo needs at least this version for its
gobject helper functions.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69239
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-16 12:55:01 +02:00
Adrian Johnson
412a4c34d9 test: update mime-data to test jbig2 mime types 2013-09-15 21:27:50 +09:30
Adrian Johnson
5c0caa6f82 pdf: support JBIG2 mime data
JBIG2 images may have shared global data that is stored in a separate
stream in PDF. The CAIRO_MIME_TYPE_JBIG2 mime type is for the JBIG2
data for each image. All images that use global data must also set
CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID to a unique identifier. One of the
images must also set CAIRO_MIME_TYPE_JBIG2_GLOBAL to the global
data. The global data will be shared by all JBIG2 images with the same
CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID.
2013-09-15 20:50:46 +09:30
Adrian Johnson
2d6705671a ps: fix embedding of mime data 2013-09-13 22:14:49 +09:30
Adrian Johnson
266d6e7156 pdf: fix embedding of mime data that has been broken since 0a10982f
For some reason the mime-data test is not detecting this failure.
2013-09-13 22:01:02 +09:30
Bryce W. Harrington
5390c2bbca test: Document use of -k and CAIRO_TEST_TARGET to run test subsets
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-13 12:58:11 +02:00
Bryce W. Harrington
640eb02067 test: Space out keywords for clarity
As another nitpick, a comma alone is legal for separating keywords, but
most tests use a comma and a space.  Update the few tests that don't,
to make this consistent.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-13 12:57:42 +02:00
Bryce W. Harrington
a6ace0cf6b test: Comma separate keywords
The parser accepts spaces as separtors between keywords, so this is nit
picky.  But only a minority of tests don't follow the comma convention,
so change them to be consistent.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-13 12:57:17 +02:00
Bryce W. Harrington
aacc5e76ed gitignore: Ignore build chaff when configuring with --enable-gtk-doc
When this flag is enabled in configure, a couple extra build files are
created, which git should just ignore.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-13 12:56:16 +02:00
Bryce Harrington
ac5f3e2b8e test: Move cairo_pattern_set_filter to after cairo_set_source_surface
Also update the image.arg32 reference images, since for now we're just
accepting pixman's output as truth.  This fixes up several tests:

                   was   is
 Tests run:        420   420
 Passed:           224   261
 Failed:           195   159
 Expected Failed:  0     0
 Error:            0     0
 Crashed:          0     0
 Untested:         0     0
 Total:            420   420

Thanks to psychon for finding the code error in the test.
2013-09-11 19:32:08 +02:00
Bryce Harrington
ade7089f72 test: Exercise image scaling quality when downscaling
This adds testcases for the various cairo filter options, each of which
match to corresponding pixman filters.  Use the 'downscale' keyword if
invoking tests using cairo-test-suite.

The 24-pixel reference images were produced from quad-color.png using
Gimp's Scale Image command with Interpolation set to None.  It is
assumed that all filters should handle a 1:4 scaling cleanly with no
antialiased blurring.

The 95-pixel reference images assume differing types of antialiasing
based on the quality level.  We are using the image.argb32 output as
reference here.  Potentially some other rendering algorithm could
conceivably provide better results in the future.

The 96-pixel reference images are simply copies of the original
quad-color.png file.  It is assumed that 1:1 downscaling operations
should produce no visible change to the original image.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2013-09-11 19:32:08 +02:00
Bryce Harrington
0f554c36d3 test: Test a variety of scales when downscaling
Downscaling from 96 to 24 is easy since it's an even multiple, so try
scaling by -1 pixel too.

This adds a 1:1 scaling test case as well, which should pass through the
image unchanged.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2013-09-11 19:32:08 +02:00
Bryce Harrington
642b6d8091 test: Add test for image downscaling
This adds pixman-downscale.c, which tests correctness of PNG images
scaled down using pixman routines.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2013-09-11 19:32:08 +02:00
Martin Robinson
7270f22af3 gl: Extend oversize check to cairo_gl_surface_create_for_texture
If a texture is too large to render to via a framebuffer, then eagerly
fail with an error surface.
2013-09-11 08:52:31 -07:00
Uli Schlachter
279d5a2ed1 recording: Correctly determine alpha of all surfaces
This code has special cases for recording and image surfaces. For all other
kinds of source surfaces, has_bilevel_alpha was not modified, even though the
source surface could have an alpha channel.

Fix this by using the same checks as in the general path at the end of this
function.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-11 15:28:29 +02:00
Uli Schlachter
a6f51fed98 recording: Fix unitialized variable 'free_me'
This variable should be NULL by default and gets set only if a new reference to
a surface was acquired through _cairo_surface_snapshot_get_target(). This works,
because cairo_surface_destroy(NULL) is well-defined and doesn't do anything.

Fixes the following compiler warning:

cairo-recording-surface.c:1642:24: warning: 'free_me' may be used uninitialized
in this function [-Wmaybe-uninitialized]

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-11 15:24:53 +02:00
Adrian Johnson
8addb4798c pdf: avoid making groups a transparency group if not required
If the group contains only a combination of clear and opaque alpha and
only OPERATOR_OVER is used in the group and to paint the group, a
transparency group is not required. This allows the pdf viewer to
replay the group in place.
2013-09-11 21:18:45 +09:30
Bryce W. Harrington
53255625c0 svg, test: Refer to output filename by variable, not a hardcoded value
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-09 21:28:35 +02:00
Bryce W. Harrington
f9dcd07d22 test: Ensure output dirs exist, falling back to current dir if needed
This change makes several tests behave more like ps-eps.c, et al by
making them attempt to mkdir "output", and in case of trouble use "."
instead.  filenames are now allocated at runtime due to this change, so
ensure the corresponding free()'s are in place as well.

This should facilitate running the test suite with a relative path
outside cairo's source tree, such as when employing the CAIRO_REF_DIR
environment variable.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-09 21:25:12 +02:00
Bryce W. Harrington
be7f1ac98f test: Make cairo_test_mkdir() usable throughout tests.
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-09 21:21:43 +02:00
Bryce W. Harrington
6731023f1b test: Fix several tests to place output files in the output directory
The standard location for test output is cairo/test/output.  The harness
itself was updated to write automatically generated images in this
directory, however a number of tests generate their own local output
files.

This patch updates these tests to write their output into
CAIRO_TEST_OUTPUT_DIR (which defaults to cairo/test/output) as well, in
the interest of decluttering the test directory.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-09 21:15:50 +02:00
Bryce W. Harrington
f3574b8b3b test: Don't ignore test output files left in test directory
Tests should be placing output files in the output/ directory now,
although not all tests follow this standard practice.  Drop the
"*.out.*" from .gitignore to make improper test behavior more evident.

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-09-09 21:15:12 +02:00
Adrian Johnson
f52165a7bb svg: Don't embed CMYK Jpeg images
None of the SVG viewers I tried (rsvg, firefox, inkscape) support CMYK
Jpeg images.

Bug 68965
2013-09-06 08:00:46 +09:30
Adrian Johnson
8e1a1ed863 Downscaling requires pixman 0.30 2013-09-06 07:54:28 +09:30