Commit graph

4112 commits

Author SHA1 Message Date
Chris Wilson
dbbcb5c26f [Makefile] Correct parameters to lcov reset.
lcov uses -z to zero its counters, not --reset.
2007-10-04 21:18:47 +01:00
Chris Wilson
717dcd1a2c [cairo-pdf-surface] Propagate resource allocation failure.
Propagate failure of _cairo_pdf_surface_new_object().
2007-10-04 21:17:31 +01:00
Chris Wilson
8fb40aee97 [cairo-image-surface] Check for errors whilst cloning.
After attempting to clone an image, check the context status and return
the nil surface if there was an error.
2007-10-04 20:08:22 +01:00
Chris Wilson
b61931640d [cairo-ps-surface] Check the creation of output streams.
Check for allocation errors during the creation of the output streams.
2007-10-04 20:08:10 +01:00
Chris Wilson
353c2ab5c0 [cairo-output-stream] Guard against destroying the nil streams.
Add a guard to return early if we attempt to call
_cairo_output_stream_destroy() on the nil cairo_output_stream_t streams.
2007-10-04 20:07:58 +01:00
Chris Wilson
7cc7bf09c1 [cairo-meta-surface] Propagate errors during replay to the surface.
Store any fatal errors raised during the replay on the surface object.
2007-10-04 20:07:43 +01:00
Chris Wilson
042821b566 [cairo-surface] Propagate fatal errors to the surface.
Store errors raised by the backend on the surface.
2007-10-04 20:07:36 +01:00
Chris Wilson
535e7c161b [cairo-type1-subset] Do not mask error returns.
When propagating errors, check that we do not overwrite a pre-existing
error.
2007-10-04 18:45:17 +01:00
Chris Wilson
bb8d4c0b14 [cairo-truetype-subset] Do mask error status returns.
Be careful not to overwrite existing the error status when propagating
errors and to not blindly return INT_STATUS_UNSUPPORTED from
load_truetype_table() as this will mask fatal errors.
2007-10-04 18:33:24 +01:00
Chris Wilson
37fd0d8967 [cairo-cff-subset] Propagate errors and review error paths.
Ensure that errors get duly propagated back to the caller and all
locally allocated resources are freed along error paths.
2007-10-04 17:18:25 +01:00
Chris Wilson
add0959328 [cairo-debug] Finalize mutexes along with other static data.
Initialize (so repeated calls of cairo_debug_reset_static_data() is
safe) and finalize the mutexes with the reset of the static data.
2007-10-04 17:00:26 +01:00
Chris Wilson
a4f20610af [cairo] Protect the getters when operating on the nil object.
Put a guard that checks the context's status at the start of each
getter that prevents the function from trying to dereference NULL state.
Use the status, as opposed to the invalid reference count, for
consistency with the existing guards on some of the getters.
2007-10-04 16:44:27 +01:00
Chris Wilson
80c06f4539 [cairo-scaled-font] Don't hold onto to a dropped font.
Mark fonts that have been removed from the cache due to an error on a
shared object and do not put them into the holdovers array.
2007-10-04 16:16:58 +01:00
Chris Wilson
6e93941a76 [cairo-scaled-font] Acquire mutex around _cairo_scaled_font_glyph_path().
All calls that manipulate the scaled_font->cache must hold its mutex.
2007-10-04 16:04:49 +01:00
Chris Wilson
261971a3fb [cairo-gstate] Fix resource leaks on error paths.
Ensure that all locally allocated (or referenced) resources are freed
if we later encounter an error.
2007-10-04 16:03:12 +01:00
Chris Wilson
4e44d54f3e [cairo-matrix] Check whether a matrix is invertible before use.
Provide an early check as to whether the font matrix is invertible.
2007-10-04 16:00:22 +01:00
Chris Wilson
528da4e5e1 [cairo-scaled-font] Freeze the font cache whilst iterating over glyphs.
Prevent glyph cache removal whilst iterating over a glyph string.
2007-10-04 15:50:40 +01:00
Chris Wilson
4b81eeb20e [cairo-scaled-font] Destroy the mask on the error path.
Do not leak the mask if we encounter an error whilst tracing.
2007-10-04 15:46:13 +01:00
Chris Wilson
d0b1308cd7 [cairo-scaled-font] Store fatal errors on the cairo_scaled_font_t.
Ensure that all fatal errors raised whilst using the font are stored on
the font.
2007-10-04 15:44:10 +01:00
Chris Wilson
4c32e6bfde [cairo-scaled-font] Return the error status from _cairo_scaled_font_set_error()
Similar to the other _cairo_*_set_error() return the error status.
2007-10-04 15:31:25 +01:00
Chris Wilson
06ae5f1ba3 [cairo-font-face] Set the error on the font.
Similar to the other shared objects, store fatal errors on the shared
font_face. And do not return a cached reference to an object in an
error state.
2007-10-04 15:26:09 +01:00
Chris Wilson
4cffdf2681 [cairo-ft-font] Always call _cairo_ft_unscaled_font_fini ().
The _cairo_ft_unscaled_font_fini() was skipped during the destroy for
fonts generated by cairo_ft_font_face_create_for_ft_face(). However
this causes a mutex to be 'leaked' for each font.
2007-10-04 14:59:55 +01:00
Chris Wilson
de1f92ae14 [cairo-output-stream] Propagate error status when copying streams.
During _cairo_memory_stream_copy(), if set, copy the incoming error over
to the destination stream and return early.
2007-10-04 14:51:16 +01:00
Chris Wilson
2c256f292f [cairo-error] Another _cairo_error (CAIRO_STATUS_SUCCESS)!
Despite double checking, I still ended up converting one too many
status values.
2007-10-04 14:35:08 +01:00
Chris Wilson
bed8239f03 [cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
    return _cairo_error (CAIRO_STATUS_INVALID_DASH);

This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
2007-10-04 13:31:44 +01:00
Chris Wilson
d90d4bb6b9 [cairo-error] Make _cairo_error() return the error status.
As pointed out by Jeff Muizelaar, this allows for more concise code, as
    _cairo_error(CAIRO_STATUS_NO_MEMORY)
    return CAIRO_STATUS_NO_MEMORY
can become
    return _cairo_error(CAIRO_STATUS_NO_MEMORY);
2007-10-04 13:30:11 +01:00
Chris Wilson
71120727e1 [cairo-atomic] Use an atomic operation to set the status on a shared resource.
Since the objects can be shared and may be in use simultaneously across
multiple threads, setting the status needs to be atomic. We use a
locked compare and exchange in order to avoid overwriting an existing
error - that is we use an atomic operation that only sets the new status
value if the current value is CAIRO_STATUS_SUCCESS.
2007-10-04 11:26:44 +01:00
Chris Wilson
f4356efb64 [malloc/error] Fixup _cairo_error (CAIRO_STATUS_SUCCESS)!
At some point during the blitz, I accidentally wrote
_cairo_error (CAIRO_STATUS_SUCCESS) and then proceeded to paste it into
the next 30 error sites! s/CAIRO_STATUS_SUCCESS/CAIRO_STATUS_NO_MEMORY/
2007-10-04 09:30:32 +01:00
Chris Wilson
ef5f460eb1 [cairo-path] Check for an empty path in cairo_append_path().
As we now generate empty paths, we must be able to handle empty paths
in the user facing API. cairo_append_path() has an explicit check, and
raises an error, for a NULL path->data, so we need to check the
path->num_data first for empty paths.
2007-10-04 09:18:36 +01:00
Chris Wilson
8ad56b308a [malloc/error] Add call to _cairo_error() after a failed malloc.
Blitz all allocations to ensure that they raise a
_cairo_error(CAIRO_STATUS_NO_MEMORY) on failure.
2007-10-04 00:42:30 +01:00
Chris Wilson
6666459655 [malloc] Take advantage of calloc() argument checking.
calloc() will check its arguments for integer overflows so it is safer
not to pre-multiply them.
2007-10-04 00:42:30 +01:00
Chris Wilson
e49bcde27f [malloc] Check for integer overflow when realloc'ing.
Perform similar sanity checks to Vlad's _cairo_malloc_ab() but on the
arguments to realloc instead.
2007-10-04 00:42:29 +01:00
Chris Wilson
8cba73a36c [cairo-polygon] Add a _cairo_error().
Add a _cairo_error() to an originating error site.
2007-10-04 00:42:29 +01:00
Chris Wilson
e767c8b50a [cairo-pen] Add _cairo_error().
Markup a couple of originating error sites with _cairo_error().
2007-10-04 00:42:29 +01:00
Adrian Johnson
7047a09174 TODO: Remove PDF encoding issues
All PDF font encoding issues are fixed now that TrueType fonts are
embedded in PDF as CIDFontType2.
2007-10-03 23:10:15 +09:30
Adrian Johnson
3e70b0a388 ROADMAP: Mark EPS support done 2007-10-03 23:01:59 +09:30
Adrian Johnson
a462717766 PDF: Fix bug in font resources 2007-10-03 19:55:05 +09:30
Chris Wilson
c9a9f1299c [cairo-image-surface] Avoid trying to create surfaces with invalid strides.
pixman does not (yet?) support arbitrary strides and will fail to
generate an image for the data. We misinterpret that failure as a
CAIRO_STATUS_NO_MEMORY, so instead return CAIRO_STATUS_INVALID_FORMAT
before attempting to create the pixman image.
2007-10-01 19:50:07 +01:00
Chris Wilson
e241205f0c [cairo-image-surface] Return correct error surfaces.
Avoid returning the "generic" _cairo_surface_nil (which corresponds to
CAIRO_STATUS_NO_MEMORY) when the user asks us to create a surface with
an invalid format or content.
2007-10-01 19:50:00 +01:00
Chris Wilson
b4f86638cc [cairo-path] Don't raise an error when attempting to create an empty path.
Generate a real empty path structure instead of returning
_cairo_path_nil, if we have been asked to create an empty path.

(Also add a couple of missing _cairo_error()s and an appropriate test
case.)

Spotted by Fred Kiefer.
2007-10-01 17:59:57 +01:00
Adrian Johnson
042c382c09 CFF Subetting: Fix for #10849
This fixes the problem Apple Preview has with viewing PDFs with CFF
font subsets.
2007-09-29 07:55:48 +09:30
Chris Wilson
d837a458b9 [configure] Work-around bad interaction of libtool and lcov
libtool causes the .gcda files to be generated in the .libs/ directory,
separate from the .c source file. lcov expects them to be in the same
directory - so massage the lcov.info file to remove the reference to the
.libs/.

Also separate the target for generating the lcov output, so that it can
be run independently from triggering the tests. And improve convenience
of using the other lcov targets.
2007-09-27 17:46:15 +01:00
Chris Wilson
abe1b89da4 [test/get-path-extents] Test extents of cairo_text_path().
Check that the text path extents match the computed metrics.
2007-09-27 16:14:02 +01:00
Chris Wilson
0618818f7a [test/get-path-extents] Test extents of an arc.
Add the test case from bug 7245,
https://bugs.freedesktop.org/show_bug.cgi?id=7245.
2007-09-26 14:40:36 +01:00
Adrian Johnson
54d5dccffa PDF: Compress pattern and group streams 2007-09-26 22:21:26 +09:30
Adrian Johnson
a0a51977f4 PDF: Fix bug in font resources when same font is in multiple groups 2007-09-26 22:21:07 +09:30
Chris Wilson
76b9b18192 [test/create-for-stream] Add the missing cairo_surface_finish().
Moments after pushing the new test case did I realise the issue...
We do not attempt to write out the surface to the user stream until
we perform the cairo_surface_destroy() by which point we have lost
the ability to interrogate the error status. We can avoid this by
explicitly calling cairo_surface_finish() and then checking the
error status - and we see that the error is indeed reported
correctly.

No bug. Nothing to see here. Please move along. (Apart from the
request for the status to be return from cairo_surface_destroy!)
2007-09-26 00:41:31 +01:00
Chris Wilson
1e7f0bd4d5 [test/create-for-stream] Add test case for user error propagation.
From bug https://bugs.freedesktop.org/show_bug.cgi?id=7049, we find
that the error status from the user supplied write function to
cairo_*_surface_create_for_stream is ignored and not propagated back
to the surface/context - leading to silent data loss. Incorporate
the suggested test case, a write function that simply returns
CAIRO_STATUS_WRITE_ERROR, into create-for-stream.c.
2007-09-26 00:31:08 +01:00
Chris Wilson
1469de5211 [cairo-png] Propagate error from read and write funcs.
Use the png_struct->error_ptr to propagate the error status from the
user/stdio read and write functions through the png_error() to the
cairo_surface_write_to_png*() and cairo_surface_read_from_png*()
functions. From there the error is returned back to the user either
directly or as the most appropriate error surface.

(Fixes https://bugs.freedesktop.org/show_bug.cgi?id=6909)
2007-09-25 23:45:39 +01:00
Chris Wilson
f1d84271d3 [cairo-atomic] Do not use Intel atomic primitives on i386.
When limiting the target instruction set for compatibility with older
processors, e.g. -march=i386, the Intel atomic primitives generate a
call to a non-existent function, __sync_fetch_and_add_4(). To detect
this scenario change the configure test from AC_TRY_COMPILE to
AC_TRY_LINK which will then cause Cairo to fall back to using mutexes
for its atomic operations.
2007-09-25 22:19:22 +01:00