Commit graph

4199 commits

Author SHA1 Message Date
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
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
dc23ecb619 [cairo-boilerplate] Do not throw an error if an exclude target is not found.
If we fail to exclude a target because it was not in the list of
targets - job done and no need to throw a tantrum.
2007-09-23 21:35:59 +01:00
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