Commit graph

309 commits

Author SHA1 Message Date
Adrian Johnson
7c8c9cf334 PDF: Support OPERATOR_SOURCE when pattern is opaque 2008-02-25 21:50:37 +10:30
Adrian Johnson
eaaa1415a9 Change PDF newline characters from \r\n to \n
The PDF backend has always used "\r\n" for the newline character.
There was no particular reason for this choice. PDF allows "\n", "\r",
or "\r\n" as the end of line marker.

Since the PS backend (which uses "\n") has started sharing
cairo-pdf-operators.c with the PDF backend, the PS output has been
getting mixed "\n" and "\r\n" newlines.

Fix this by changing the PDF backend to use "\n".
2008-02-20 21:05:23 +10:30
Adrian Johnson
8fb624dbf2 Use correct prefix for _cairo_pdf_operators_stroke
s/operator/operators/
2008-02-17 21:33:25 +10:30
Adrian Johnson
d2a1576941 PDF/PS: Fix mismatched save restore when using fill-stroke 2008-02-17 21:33:16 +10:30
Adrian Johnson
3a05b5d2d5 PDF/PS: No need to use save/restore for solid colors 2008-02-17 21:33:04 +10:30
Adrian Johnson
2dfe32a0ff Implement PDF fill-stroke 2008-02-17 17:21:35 +10:30
Behdad Esfahbod
1e7fa4b9f5 [cairo-pdf-operators] Pass matrix by reference, not by value 2008-02-16 22:48:06 -05:00
Chris Wilson
bc83e028b8 [cairo-output-stream] Add format(printf) markup.
Add CAIRO_PRINTF_FORMAT attribute to the printf-esque output stream
functions, and fixup the one warning caught by the compiler.
2008-02-15 13:50:42 +00:00
Chris Wilson
d0cc1d9291 [cairo-pdf-surface] Minor code tidy.
Remove code duplication.
2008-02-15 13:50:41 +00:00
Adrian Johnson
fd3181c7bf PDF: Remove stale comments 2008-02-12 20:22:38 +10:30
Adrian Johnson
bdb857a78b PDF: Fix uninitialized variable in previous commit 2008-02-12 20:19:03 +10:30
Kristian Høgsberg
ba6788fc96 [pdf] Use compressed PDF stream instead of compress_dup()
The deflate stream has bounded (constant) memory overhead, whereas
compress_dup() allocates memory proportional to the uncompressed data.

This replaces compress_dup() usage with a compressed PDF stream for
emitting images, alpha masks and font subsets, and eliminates the
compress_dup() function.
2008-02-11 16:57:56 -05:00
Vladimir Vukicevic
80e11a85a9 [pdf] restore alpha_size back to correct bit size 2008-02-07 14:36:51 -08:00
Vladimir Vukicevic
a9b0e54d38 Avoid buffer overflow in ps/pdf surface
A few places weren't using _cairo_malloc_*; fixed.
2008-02-06 13:52:33 -08:00
Adrian Johnson
367e50137e PDF: Use correct surface size when emitting patterns
Store the surface size in each pattern and smask group and use this
size when the pattern/group is emitted. This is required as a pattern
or group may be used from a meta surface with a different size to the
PDF surface. However the pattern or group is emitted after the the meta
surface content has been emitted and the surface size has been
restored to the the page size.

This fixes the following pdf test failures:
  extend-reflect-similar
  extend-repeat-similar
  mask
2008-02-02 21:22:16 +10:30
Behdad Esfahbod
f0633f4449 [doc] Make sure all function names in docs are followed by () 2008-01-28 21:49:57 -05:00
Behdad Esfahbod
0d898f2bad [doc] Make sure all type names in docs are prefixed by # 2008-01-28 20:49:44 -05:00
Behdad Esfahbod
9ecde82d35 [doc] Make sure all macro names in docs are prefixed by % 2008-01-28 20:48:48 -05:00
Behdad Esfahbod
efd3a96524 [cairo-scaled-font] Don't err on font size 0, really
First, seems like we were rejecting degenerate font matrix right away
at the constructor.  Don't do that.

Next, PS/PDF were inverting the font scale matrix, assuming that it's
invertible.  We now keep the inverse too, so they can use it.  For the
case of a size 0 font, both the scale matrix and its invert are set to
0,0,0,0.  That's safe, even if slightly inconsistent.
2008-01-24 23:35:06 -05:00
Vladimir Vukicevic
02970ac8cf Fix usage of cairo_rectangle_int16_t leading to memory corruption
cairo_rectangle_int16_t was being used in a number of places instead
of cairo_rectangle_int_t, which led to memory corruption when cairo was
using a fixed point format with a bigger space than 16.16 (such as 24.8).
2008-01-22 15:32:11 -08:00
Adrian Johnson
ec272fbd09 Fix PDF extend-reflect test failure
Previously, when emitting image patterns the PDF backend used
_cairo_pattern_acquire_surface to get the image. For reflected images
this would return an image containing four images in a reflect
pattern.  When drawn in a PDF pattern (which only does repeating
patterns) this would create the reflected pattern in PDF.

For some reason _cairo_pattern_acquire_surface is no longer returning
a reflected image pattern.

This is fixed by only using _cairo_surface_acquire_source_image to get
the image and using the same code as is used for reflected
meta-surface patterns to created a reflected pattern by drawing four
transformed copies of the image inside the PDF patten.

This is the better way to implement reflected images as we are no
longer embedding an image four times larger than the original.
2008-01-19 12:46:24 +10:30
Chris Wilson
dec2daeaf3 [cairo-{ps,pdf}-surface] Assert the font is supported during emission.
Add an ASSERT_NOT_REACHED to the tail of the font subset emission
functions - as they should always, at least, be supported by the
fallbacks.
2008-01-17 15:34:51 +00:00
Chris Wilson
1bccbd88c3 [cairo-pdf-surface] Review error propagation from output stream.
Ensure that errors encountered whilst processing the output stream are
propagated back to the surface (and the user).
2008-01-16 17:02:52 +00:00
Chris Wilson
7111b18c27 [cairo-surface] Introduce _cairo_surface_create_in_error().
Unexport all the static error surfaces and use a function to select
the appropriate error surface for the status.
2008-01-16 16:51:32 +00:00
Chris Wilson
409e91b576 [cairo-pdf-surface] Review error handling.
Ensure all errors are propagated back to the caller with locally
allocated resources destroy as required.
2008-01-10 17:11:04 +00:00
Chris Wilson
6134600988 [cairo-pdf-surface] Skip emitting the font subset if not among resources.
Do not emit the font_subset if we did not successfully add it to the list
of font resources - can only happen after an error
2008-01-10 17:10:52 +00:00
Adrian Johnson
25f24e79f8 PDF: Update the PDF page structure comment 2008-01-07 21:19:35 +10:30
Adrian Johnson
21f842f0df PDF: Remove copy_page
Now that the content stream is no longer split into multiple streams
it is not possible to implement a copy_page function that shares the
common content between pages.

Remove this function so the paginated surface will rewrite the
content from the meta surface.
2008-01-07 21:17:26 +10:30
Adrian Johnson
e2adb921f8 PDF: Put each fallback image in a separate group
Each fallback image needs to be in a separate group in the knockout
group. Otherwise transparent edges of adjacent fallback images will
composite with each other creating visible seams between the images.
2008-01-07 21:15:18 +10:30
Adrian Johnson
3c725d50db PDF: Make _SOURCE operator work inside meta surface patterns 2008-01-07 21:09:04 +10:30
Adrian Johnson
6d6b74ac4c PDF: Support _OPERATOR_SOURCE when nothing under the operation
CAIRO_OPERATOR_SOURCE operations on the PDF backend are now natively
supported when there is nothing already underneath the operation.
2008-01-07 21:08:09 +10:30
Adrian Johnson
e195cb551c Add FALLBACK mode to paginated surface
The PDF surface needs to know when the fallback images start so it can
close off the content stream and create a knockout transparency group
for the fallback images. Currently it does this by looking for
operations with CAIRO_OPERATOR_SOURCE. PDF returns unsupported for
_SOURCE during the analysis phase so _SOURCE will never appear during
native operations. However this prevents the PDF surface from
supporting _SOURCE operations that can be natively supported. For
example a _SOURCE operation with nothing painting under it can be
converted to _OVER and natively supported.

A third mode, CAIRO_PAGINATED_MODE_FALLBACK, has been added. The
paginated surface will set this mode before it paints finer-grained
fallback images.
2008-01-07 21:05:36 +10:30
Adrian Johnson
d2a5d1ace6 PDF: Remove the remaining code for splitting the content
across multiple streams. This fixes the problem reported here

http://lists.cairographics.org/archives/cairo/2007-December/012197.html
2008-01-07 21:04:06 +10:30
Adrian Johnson
099810b6c3 PDF: Perform all clipping in the content stream
Previously this was done in a separate group. Now that the PDF backend
has been re-organized to not interrupt the content stream the clipping
can be done in the same stream.
2008-01-07 20:59:22 +10:30
Adrian Johnson
83630b1c70 PDF: Emit all patterns after content stream
To fix this performance issue

http://lists.cairographics.org/archives/cairo/2007-December/012197.html

the PDF surface needs to avoid starting and stopping the content
stream every time it emits a pattern. This patch makes the PDF surface
store a list of all patterns used while the content stream is written
out then write out all the patterns after the content stream is
closed.
2008-01-07 20:55:56 +10:30
Adrian Johnson
26c6159b1e Move the PDF drawing operators into cairo-pdf-operators.c
By defining PostScript functions the same as the PDF drawing
operators, this code can be shared by both the PDF and PS backends.
2008-01-07 20:36:32 +10:30
Adrian Johnson
a0e0aae32d PDF: Remove the Type 3 outline glyph code
This code is never used because outline glyphs that go through the
fallback path are always embedded with Type 1 fallback. The only fonts
that are embedded as Type 3 are bitmap fonts.
2008-01-07 20:34:55 +10:30
Adrian Johnson
5b3f6405d8 PDF: Fix gradient-zero-stops test failure 2008-01-06 16:15:32 +10:30
Chris Wilson
399f7c24e3 [cairo-pdf-surface] Continue to close streams even after error.
Do not return after encountering the first error whilst closing streams,
but continue to close any auxiliary streams before finally reporting the
error. Also during finalize check that we have closed any streams that
may have been left open after encountering an error.
2008-01-03 17:34:58 +00:00
Chris Wilson
42e77c1077 [cairo-pdf-surface] Destroy closed streams.
Destroy the streams when closing groups in order to free the associated
resources.
2008-01-03 17:34:47 +00:00
Chris Wilson
42bfe370f8 [cairo-pdf-surface] Propagate error from emit_glyph().
Propagate the error and return early rather than setting the error on
the surface and continuing.
2008-01-03 17:34:38 +00:00
Chris Wilson
e89cc8fa15 [cairo-scaled-fonts-subsets] Memleak and error reporting.
Fix leaks of strings and hash table from
_cairo_scaled_font_subset_create_glyph_names().

Whilst we are in the vicinity, review the error handling.
2008-01-03 11:03:17 +00:00
Adrian Johnson
060f384310 Fix PS/PDF meta surface patterns
This was failing with more than one level of push/pop group.  The
problem was that the meta surface replay in PS/PDF emit_meta_surface
was replaying all the meta surface commands insteads of only the
natively supported commands. The analysis surface has also been
changed to replay meta surface patterns back to the one analysis
surface instead of creating a separate analysis surface for each
pattern. The analysis surface now transforms bounding boxes with the
meta surface pattern matrix so that fallback regions are correctly
tracked.
2007-12-29 00:26:11 +10:30
Chris Wilson
62d64e12aa [cairo-pdf-surface] Create a new path for an empty clip.
If the clip path is empty, then we need to start a new path otherwise
the clip is ineffective.
2007-11-06 15:22:07 +00:00
Adrian Johnson
8888afe9a4 PDF: Fix meta surface patterns with EXTEND_REFLECT 2007-10-22 23:05:25 +09:30
Adrian Johnson
4660561cb5 PDF: Add support for CAIRO_FORMAT_A1 images 2007-10-14 19:05:06 +09:30
Adrian Johnson
39044157da PDF: Add support for linear gradients with REPEAT and REFLECT 2007-10-14 19:04:33 +09:30
Chris Wilson
0222c02d95 [cairo-pdf-surface] Return UNSUPPORTED from _to_unicode_stream().
Distinguish the UNSUPPORTED case where the font backend does not
support conversion to unicode from other fatal errors by returning a
status value rather than using stream.id == 0 to indicate any error.
2007-10-11 15:00:59 +01:00
Chris Wilson
05702b8b6e [cairo-pdf-surface] Free the clip path on error.
If we fail to add the clip path to the current group, destroy it.
2007-10-11 15:00:22 +01:00
Chris Wilson
8fa5f638a5 [cairo-pdf-surface] Restore old_group for failed emit_meta_surface().
Ensure we restore the surface->current_group if we encounter an error
during _cairo_pdf_surface_emit_meta_surface() lest we leak the
current_group array.
2007-10-11 15:00:13 +01:00