Commit graph

10965 commits

Author SHA1 Message Date
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
Chris Wilson
0266cb821f script: Add support for replaying device-scale
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-05 16:13:56 +01:00
Chris Wilson
a4164142f2 trace: Record set-device-scale
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-05 16:12:26 +01:00
Alexander Larsson
935c64a434 surface: Inherit device scale in cairo_surface_create_similar()
Without this most code that uses similar surfaces for offscreen
rendering will render in a pixelized fashion if the final
target uses a device scale.
2013-09-05 16:11:10 +01:00
Alexander Larsson
bc792a5e0e surface: Merge scratch construction into _cairo_surface_create_scratch
We merge _cairo_surface_create_similar_scratch and
_cairo_surface_create_similar_solid into a single function named
_cairo_surface_create_scratch, to avoid confusion with
cairo_surface_create_similar which now will have a different
behaviour wrt the sizes and the device-scale.

_create_scratch assumes the width and height are in backend
coordinates, while create_similar does not.
2013-09-05 16:11:09 +01:00
Alexander Larsson
bdccf4fe51 surface: Opencode create_similar
We copy the _cairo_surface_create_similar_solid code into
cairo_surface_create_similar so that we can separate these later
as one wants to use backend sizes and one not.
2013-09-05 16:11:08 +01:00
Chris Wilson
5f70148467 test: Allow CAIRO_TEST_MODE to independently enable extended testing
Such as CAIRO_TEST_MODE=scale for testing application of
cairo_surface_set_device_offset.

CAIRO_TEST_MODE=similar - test rendering through similar surfaces
CAIRO_TEST_MODE=offset - test rendering with a device offset
CAIRO_TEST_MODE=scale - test rendering with a device scale
2013-09-05 16:08:20 +01:00
Alexander Larsson
690c61aa54 tests: Add device scale test to "full" testrun similar to offsets 2013-09-05 16:08:20 +01:00
Alexander Larsson
7ab34f302b surface: expose the device scale
This adds the new public functions
cairo_surface_set_device_scale and cairo_surface_get_device_scale and
updates old users of the internal functions.
2013-09-05 16:08:19 +01:00
Chris Wilson
38217d67fc spans,traps: Undo device transform from source matrix for recording replays
As the replay of the recording surface applies the device_transform of
the matrix once again to all its operations, we end up with a repeated
transform through the source matrix of the recording surface. We need to
remove one of these, and the easiest way to do that appears to be to
undo the application to the source matrix.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-05 16:08:19 +01:00
Alexander Larsson
f0e2cd4494 gstate: Handle device scale on surface as source
When creating a transformed pattern we must apply the device
transform *before* the transform set on the pattern itself, otherwise
e.g. its translation will not be affected by the device scale.

We also fix up the device_transform related handling in
_cairo_default_context_pop_group().  With a device scale we can
no longer just use the device_transform_inverse to unset the
device offset for the extents, so we make that a simple translate
instead.

We also remove some weird code that tries to handle the device
transform but seems unnecessary (maybe a workaround for applying
the device transform in the wrong order?). With that code removed
things work fine, but with it things get translated wrongly when
there is a scale.
2013-09-05 16:08:19 +01:00
Alexander Larsson
900fc4a890 gstate: Move device-scale font scaling to gstate
If we do this in surface it will be applied twice then
we chain to a different surface, like e.g. a subsurface.

We also remove a hack in cairo-surface-wrapper where it compensated
for the device scale not being applied.

v2: Compute the backend CTM in ensure_scaled_font().
2013-09-05 16:08:19 +01:00
Alexander Larsson
25eaec0a38 subsurface: Handle device scales 2013-09-05 16:08:19 +01:00
Alexander Larsson
633d573889 default-context: Inherit device scale in push_group surface
Without this we will only render to part of the newly created
surface and then copy+scale that part back, which causes fuzziness.
2013-09-05 16:08:19 +01:00
Alexander Larsson
db7e551a6b gstate: Respect device transform in stroke
We need to apply the device transform to the ctm when stroking, as
otherwise line widths are not affected by the device scale.
2013-09-05 16:08:19 +01:00