Commit graph

2403 commits

Author SHA1 Message Date
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
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
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
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
03be41151d [cairo-atomic] Rewrite reference counting using atomic ops.
Introduce an opaque cairo_reference_count_t and define operations on it
in terms of atomic ops. Update all users of reference counters to use
the new opaque type.
2007-09-25 16:29:54 +01:00
Chris Wilson
8b6c871c90 [cairo-atomic] Introduce atomic ops.
Test for the availability of the Intel __sync_* atomic primitives and
use them to define a few operations useful for reference counting -
providing a generic interface that may be targeted at more architectures
in the future. If no atomic primitives are available, use a mutex based
variant. If the contention on that mutex is too high, we can consider
using an array of mutexes using the address of the atomic variable as
the hash.
2007-09-25 16:29:54 +01:00
Chris Wilson
42de1a0a7f Move GCC attributes wrapping into a separate header.
The wrapping of GCC attributes (such as cairo_private) needs to be
visible to any header file, including those that avoid cairoint.h such
as cairo-boilerplate. To achieve this we move the pre-processor magic to
its own header file and include it as required.
2007-09-25 16:29:54 +01:00
Adrian Johnson
be327a7b49 PDF: Compress the content stream
The content stream compression that was previously implemented was
inadvertently bypassed when the new stream handling for meta surface
patterns was implemented.
2007-09-25 23:04:03 +09:30
Adrian Johnson
99fd9449c2 PDF: Remove duplication from the resource dictionary
The same font identifer was being added the resources every time it
was referenced.
2007-09-25 21:57:46 +09:30
Chris Wilson
4f7c5a5033 [cairo-region] Call _cairo_error() at original error site.
Before returning a fresh CAIRO_STATUS_NO_MEMORY, remember to call
cairo_error().
2007-09-23 21:35:49 +01:00
Chris Wilson
45feb13c26 [cairo-clip] Avoid a malloc(0).
Avoid a potential allocation of 0 bytes, and a potential NULL leading to an
incorrect CAIRO_STATUS_NO_MEMORY, when copying an empty clip region.
2007-09-23 21:35:25 +01:00
Adrian Johnson
77f1aa7887 Add Encapsulated PostScript support
The analysis surface will calculated the tight bounding box for each
page. A new paginated-surface backend function set_bounding_box() has
been added for passing the page bounding box to the target surface at
the end of the analysis phase.

The changes to the PS file when EPS is enabled are:
    - Add EPS header
    - Use tight bounding box instead of page size
    - Use save/restore to ensure PS interpreter is left in the same state
2007-09-23 17:43:44 +09:30
Adrian Johnson
beefbdd638 Add Encapsulated PostScript API 2007-09-23 14:23:33 +09:30
Adrian Johnson
b20e08999e Truetype Subsetting: Avoid failing when fonts are missing optional tables
Previously, the TrueType subsetting would fail if any of the "cvt",
"fpgm", or "prep" tables were missing from the source font. However
these tables are optional and not required in the subsetted font if
they do not appear in the source font.

The "name" table has been removed from the subsetted font as the
Type42 specification does not require this table.
2007-09-23 11:37:02 +09:30
Brian Ewins
8132b8b417 [type1-subset] only subset ft fonts
If atsui and ft were both enabled, the code crashed trying to subset
type-1 fonts; fixed by checking if fonts really are ft before using
them as ft fonts. This is a temporary fix until we support subsetting
across all font backends.
2007-09-23 02:52:01 +01:00
Vladimir Vukicevic
6020f67f1a Avoid divide-by-zero when trying to allocate a 0-sized array
Fix up the _cairo_malloc_* wrappers to avoid blindly dividing by zero;
any attempt to allocate a zero-sized chunk of memory will result in
NULL.
2007-09-21 11:02:42 -07:00
Adrian Johnson
12b2ab630c PDF: Add support for CAIRO_FORMAT_A8 images 2007-09-20 22:51:39 +09:30
Vladimir Vukicevic
d8b0de01d6 fix trailing whitespace 2007-09-18 09:28:30 -07:00
Vladimir Vukicevic
4fd9acc1b3 [win32] add new win32 printing surface 2007-09-18 09:28:30 -07:00
Vladimir Vukicevic
e3c16e15e3 Make NO_MUTEX really mean no mutexes 2007-09-18 09:28:30 -07:00
Vladimir Vukicevic
ffc16c4be2 [win32] Add win32 printing surface
Add win32 surface intended for use with printer DCs; GDI will be used
as much as possible, and the surface will be a paginated surface
that supports fine-grained fallback.

(Original work from Adrian Johnson; additional fixes by me.)
2007-09-18 09:28:29 -07:00