Commit graph

3077 commits

Author SHA1 Message Date
Chris Wilson
f2f91db131 [cairo-png] Create an ARGB32 surface for paletted PNGs.
jeremie54 reported a regression in the handling of transparent paletted
PNGs beween 1.4.14 and 1.6.4. This was caused by the change to load
opaque PNGs into a RGB24 image surface, which made the assumption that
indexed PNGs were opaque. However, alpha/transparency in PNG is more
complicated, as PNG uses a tRNS chunk to supply transparency data for
paletted images and other image types that don't need a full alpha
channel. Therefore if the PNG contains a tRNS chunk always generate an
ARGB32 surface.
2008-04-21 18:35:07 +01:00
Chris Wilson
ea6dbfd36f [cairo-meta-surface] Save and restore the original clip.
When replaying the meta-surface to the target, we apply a stack-based
clip to the surface. However, we did not remove this clip from the
surface and so a pointer into our stack existed beyond the scope of
function.

Saving the original clip pointer and restoring it before leaving the
function resolves the issue and appears to fix
https://bugzilla.mozilla.org/show_bug.cgi?id=429071.
2008-04-21 18:35:07 +01:00
Adrian Johnson
a2c4fd0572 Add "Since: 1.6" to win32 printing surface 2008-04-18 18:18:30 +09:30
Robert O'Callahan
212357cb4c Clone surface correctly when doing a deep clip copy
The rect specifies the clip surface location within the owning surface;
when cloned, the x/y should be 0 to get the entire surface.

Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=409227
2008-04-18 06:15:26 +02:00
Chris Wilson
a0d71e5a38 [Makefile.am] Fix breakage in previous commit.
I checked with --disable-pdf and with --disable-ps, but forgot to
check with them both enabled. D'oh.
2008-04-16 14:33:00 +01:00
Chris Wilson
472637da05 [Makefile.am] Add cairo-pdf-operators*.[ch] to ps_sources
The postscript backends depends upon cairo-pdf-operators.c, so list it
as a requirement in ps_sources. This enables the postscript backend to
build even if the pdf backend is disable by the user during configure.

(Fixes http://bugs.freedesktop.org/show_bug.cgi?id=15532.)
2008-04-16 14:19:02 +01:00
Behdad Esfahbod
cafdd01619 [Makefile.am] Document why beos was removed from build, and remove some cruft 2008-04-15 13:33:50 -04:00
Richard Hult
8514d33444 Fix to install cairo-quartz-font.pc 2008-04-14 16:55:23 -07:00
Kouhei Sutou
4ff59960f3 Fix typo in documentation (missing stride argument) 2008-04-14 16:53:37 -07:00
Carl Worth
9db764c732 Merge in '1.6'
This gets us a fix for not linking with g++ from 1.6.4

We don't take from 1.6.4 the revert of the addition of
missing locking from the GC cache, (meanwhile, we've
already got a corrected fix for this).

Conflicts:

	src/cairo-xlib-screen.c
2008-04-14 16:42:07 -07:00
Adrian Johnson
d96fdd58ab win32: Fix broken printing of type1 fonts
ExtTextOut() does not work with Type 1 font glyph indices when
printing. The same code works fine when dst->dc is a display. It
appears that ExtTextOut expects unicode character values when using
Type 1 fonts and a printer DC.

Fix this by making Type 1 fonts in the win32-printing surface use the
fallback path for non Windows fonts. ie the glyphs will be emitted as
filled paths.
2008-04-13 22:16:52 +09:30
Chris Wilson
ff5376563b [xlib] Clear the gc_needs_clip_reset after use.
If you think this commit is reminiscent of
40558cb15e, you would be right as it fixes
exactly the same bug I made then and reintroduced in dc714106e1.

So quoting 40558cb:
After consuming the GC we need to unset the clip reset flag, so that
if we try and get a new GC without first putting a fresh one we do not
try to call XSetClipMask on a NULL GC.
2008-04-11 23:57:01 +01:00
Carl Worth
32e576382b Prevent cairo from being linked unnecessarilly with g++
The beos backend involves a source file written in C++.
Apparently, automake sees the conditional inclusion of
that source file and insists on doing the final link of
cairo with g++ even though that file isn't being compiled
at all.

We definitely don't want that as it makes libcairo link
and depend on libstdc++ unnecessarily, (which can break
distribution packaging when not expecting it, etc.).
2008-04-11 14:13:03 -07:00
Carl Worth
8f1c8d4b26 Revert "[xlib] Add locking around GC cache."
This reverts commit 9cfd82e87b.

The fix was broken as it introduced crashes by calling
XSetClipMask with a NULL GC, (basically a reintroduction
of the bug originally fixed here:

	7802de6d5edaf998c98b141870dc2c6b4c0f3e91

Let's revert for sake of the release, and fix this correctly
on master.
2008-04-11 14:09:15 -07:00
Chris Wilson
9cfd82e87b [xlib] Add locking around GC cache.
The per-screen cached of most-recently freed GCs lacks suitable locking
for it to be threadsafe.
(cherry picked from commit dc714106e1)
2008-04-11 09:07:24 -07:00
Adrian Johnson
cf057c1e86 PS: Fix inefficient implementation of Tm/Td operators that was crashing printers
The Td and Tm operator emulation were setting the font matrix like this:

  /some_font [xx yx xy yy x0 y0] selectfont

where [xx yx xy yy] is the font matrix and [x0 y0] is the position of
the first glyph to be drawn. This seemed to be the easiest way to
emulate the Tm operator since the six arguments to Tm required by PDF
are xx,yx,xy,yy,x0,y0.

Before the switch to pdf-operators the font matrix was set like this:

  /somefont [xx yx xy yy 0 0] selectfont x0 y0 moveto

The selectfont operator is equivalent to calling findfont, makefont,
and setfont. The makefont operator creates a new font dictionary for
specified font that contains the specified font matrix. The
description of the makefont operator in the PostScript Language
Reference Manual states:

  "The interpreter keeps track of font dictionaries recently created
   by makefont. Calling makefont multiple times with the same font and
   matrix will usually return the same font rather than create a new
   one."

So the emulation of Tm and Td was creating a new font dictionary every
time a text string was displayed due to the change in the translation
components of the font matrix. Previously the font dictionary was
re-used as with the translation components of the matrix set to zero,
the font matrix did not change frequently.

Some printers did not handle well the frequent creation a font
dictionary every time a few glyphs were displayed.

Fix this by ensuring the translation components of the font matrix
used in the emulation of Tm and Td operators is always set to
zero. Use moveto instead for the translation components.
(cherry picked from commit c5814d2aa3)
2008-04-11 09:03:49 -07:00
Chris Wilson
e4fc5279cc [cairo-font-options] Eliminate internal use of cairo_font_options_create()
Within the library, we know the precise size of the struct and so can
allocate temporary font options on the stack - eliminating the need
to export an internal alias of cairo_font_options_(create|destory).
2008-04-11 15:39:11 +01:00
Chris Wilson
b72fe9bb5f [cairo-arc] Check that the context is not error before proceeding.
We depend on values stored on the context that become invalid upon an
error, so stop processing as soon as an error occurs. Prior to
adjusting, the values returned from the error context, this would cause
an infinite loop whilst calculating the number of segments required for
a tolerance of 0.
2008-04-11 15:39:10 +01:00
Chris Wilson
f6834dacef [cairo] Return defaults when the context is in error.
Return the default values instead of zero for an error context. This
helps to prevent application logic faults when using the values from
the error context (for an example, see _cairo_arc_in_direction()).
2008-04-11 15:39:10 +01:00
Chris Wilson
68f53282b9 [xlib] Clear the Visual cache upon display closure.
Clear the Visual cache, similarly to flushing the GC cache, upon
XCloseDisplay.
2008-04-11 15:39:10 +01:00
Chris Wilson
a2608cdde5 [xlib] Convert the Visual cache to use the screen mutex.
Use the per-screen mutex, introduced for the GC cache, to lock access to
the Visual cache (instead of the per-display mutex).
2008-04-11 15:39:10 +01:00
Chris Wilson
dc714106e1 [xlib] Add locking around GC cache.
The per-screen cached of most-recently freed GCs lacks suitable locking
for it to be threadsafe.
2008-04-11 15:39:09 +01:00
Adrian Johnson
c5814d2aa3 PS: Fix inefficient implementation of Tm/Td operators that was crashing printers
The Td and Tm operator emulation were setting the font matrix like this:

  /some_font [xx yx xy yy x0 y0] selectfont

where [xx yx xy yy] is the font matrix and [x0 y0] is the position of
the first glyph to be drawn. This seemed to be the easiest way to
emulate the Tm operator since the six arguments to Tm required by PDF
are xx,yx,xy,yy,x0,y0.

Before the switch to pdf-operators the font matrix was set like this:

  /somefont [xx yx xy yy 0 0] selectfont x0 y0 moveto

The selectfont operator is equivalent to calling findfont, makefont,
and setfont. The makefont operator creates a new font dictionary for
specified font that contains the specified font matrix. The
description of the makefont operator in the PostScript Language
Reference Manual states:

  "The interpreter keeps track of font dictionaries recently created
   by makefont. Calling makefont multiple times with the same font and
   matrix will usually return the same font rather than create a new
   one."

So the emulation of Tm and Td was creating a new font dictionary every
time a text string was displayed due to the change in the translation
components of the font matrix. Previously the font dictionary was
re-used as with the translation components of the matrix set to zero,
the font matrix did not change frequently.

Some printers did not handle well the frequent creation a font
dictionary every time a few glyphs were displayed.

Fix this by ensuring the translation components of the font matrix
used in the emulation of Tm and Td operators is always set to
zero. Use moveto instead for the translation components.
2008-04-11 21:42:19 +09:30
Behdad Esfahbod
11299ae5c5 Add doc/tutorial/src/singular.c 2008-04-09 11:17:14 -05:00
Chris Wilson
39100439ca Check surface->status and finished in cairo_surface_write_to_png_stream
Cut'n'paste from commit c1f765:
Without these checks, a user could hit an assertion failure by passing
a finished surface to cairo_surface_write_to_png_stream.  Now we return
a nice CAIRO_STATUS_SURFACE_FINISHED error in that case instead.
2008-04-08 11:32:51 +01:00
Carl Worth
c26a7de970 Prevent potentially infinite wandering through memeory in _cairo_hull_prev_valid
It is possible for _cairo_hull_prev_valid to be called just once
right before the calling loop is going to terminate. In this
case we really don't want to walk off the beginning of the
array and start wandering.

Thanks to Jonathan Watt for noticing this problem:

	https://bugzilla.mozilla.org/show_bug.cgi?id=306649#c21
2008-04-08 01:54:27 -07:00
Carl Worth
c1f7655f2f Check surface->status and finished in cairo_surface_write_to_png
Without these checks, a user could hit an assertion failure
by passing a finished surface to cairo_surface_write_to_png.
Now we return a nice CAIRO_STATUS_SURFACE_FINISHED error in
that case instead.
2008-04-08 00:41:09 -07:00
Chris Wilson
4924d4d928 [cairo-xlib] Do not create surface with mismatching Visual and PictFormat.
As identified by Vladimir Vukicevic,
_cairo_xlib_surface_create_similar_with_format() was erroneously passing
down the source Visual when creating a surface with a different
XRenderPictFormat.
2008-04-08 07:52:47 +01:00
Chris Wilson
f6afba8f54 [cairo-xlib] Create Pixmap using depth from xrender_format.
Use the depth as specified by the xrender_format when creating the
pixmap (as opposed to a guess based on the cairo_format_t).
2008-04-08 07:52:47 +01:00
Chris Wilson
922fefdde4 [cairo-xlib] Handle missing RENDER during similar surface creation
If the xserver doesn't support the RENDER extension or simply doesn't
have the matching PictFormat then xrender_format might be NULL. Check
and fallback in this case.
2008-04-08 07:52:46 +01:00
Carl Worth
36246c51ba Revert "_cairo_pattern_get_extents: Fix to allow for expansion based on filter"
This reverts commit 731e121c80.

This commit introduced various problems, (some likely noticeable
in the test suite, and others perhaps not). For some details, see
the latest comments in the original bug report leading to the
fix now being reverted:

	http://bugs.freedesktop.org/show_bug.cgi?id=15349
2008-04-07 16:09:06 -07:00
Carl Worth
164e9c195c SVG: Fix generation of mask_id identifiers
In tests such as smask-mask (and others) the cairo_mask operation
is used in the construction of a mask. In this case, the single
document->mask_id value was being incremented at inappropriate
times.

We fix this by adding a new _cairo_svg_document_allocate_mask_id
that returns the current value and increments it. That way,
callers can hold onto this reliable value for the desired lifetime
that the code needs the identifier.
2008-04-07 15:56:26 -07:00
Carl Worth
f2a94c84a1 Add underscore prefix to private _cairo_pdf_surface_set_size_internal 2008-04-07 13:03:58 -07:00
Adrian Johnson
688fbc24c3 PDF: Add a function for changing the surface size
The smask-fill test was failing for PDF output because in some places
where the surface size is changed (eg when emitting patterns or
smasks) the cairo_to_pdf matrix was not updated.

Fix this by adding a function to handle the surface size change and
replace all the duplicated code for changing surface size with a call
to this function.
2008-04-06 20:24:40 +09:30
Carl Worth
3f5ce00e99 Add missing parens() to function name in gtk-doc comment 2008-04-06 03:09:45 -07:00
Carl Worth
c08e2ba974 Document default opaque black source pattern. 2008-04-06 02:56:19 -07:00
Carl Worth
e07e1b7bbb Document many more defaults
Including: fallback_resolution, fill_rule, line_cap, line_join,
miter_limit, font_face, font_size, and operator.
2008-04-06 02:47:32 -07:00
Carl Worth
a55669c325 Document toy nature of cairo_select_font_face 2008-04-06 02:17:33 -07:00
Carl Worth
d1fe008440 Document default extend modes 2008-04-06 02:17:09 -07:00
Carl Worth
abe6f9541e Document EXTEND_REFLECT and EXTEND_PAD as implemented for surfaces since 1.6 2008-04-06 02:01:04 -07:00
Carl Worth
b61d1b01e9 Change default filter from BEST to GOOD
Right now the two filters are implemented identically, so there's
no real change for now. But in the future, it's conceivable that an
X server could implement some crazy, high-quality filter for BEST
without regard to performance, (since that's what BEST means).

Meanwhile, GOOD actually captures what we want by default which is
a good mix of both quality and performance.
2008-04-06 01:07:32 -07:00
Adrian Johnson
ae6fbe9e6e scaled-font-subsets: Special case .notdef in a new subset
If the .notdef glyph is the first glyph in the subset to be mapped in
scaled font, we do not know if the subset will scaled or unscaled. We
can put it in the unscaled subset as Type1-fallback will embded an
empty glyph if it can not get the path.
2008-04-06 01:08:31 +10:30
Adrian Johnson
0d5902b716 Type1-fallback: Use correct glyph metrics for .notdef glyph
Bug 15348 references the following PDF that was printing incorrectly
when running through poppler and cairo to generate PostScript.

http://launchpadlibrarian.net/12921700/UbuntuDesktop.pdf

The PostScript output had too much space between each word causing
strings of glyphs printed with the TJ operator to overlap.

The original PDF file contains an CFF font with CID Identity-H
encoding. The PDF file is using character code 0 (glyph 0 due to
Identity-H encoding) as a space character. The CFF specification
defines glyph 0 to be the .notdef glyph.

The PS backend subsets CFF fonts as a Type1-fallback
font. Type1-fallback creates it's own empty .notdef glyph with an
arbitrary glyph advance of 500. The problem here is the TJ operator
used to output the glyphs depends on the glyph advance being
correct. pdf-operators.c uses the glyph advance returned by
_scaled_glyph_init(). However the PostScript interpreter sees the
glyph advance of 500 for .notdef. This problem does not occur when
generating PDF as the PDF font dictionary contains an list of glyph
advances that override the font metrics.

Fix this by making Type1-fallback not treat .notdef as special and to
create it the path and metrics obtained from _scaled_glyph_init(). As
a special case, make it not fail if _scaled_glyph_init() is unable to
return a path for .notdef. This was probably the reason Type1-fallback
previously created it's own .notdef glyph as calling
_scaled_glyph_init(_GLYPH_INFO_PATH) for glyph 0 returns
CAIRO_INT_STATUS_UNSUPPORTED for some fonts.

This ensures the Type1-fallback font metrics match the metrics used
by pdf-operators.c to position the glyphs. This also results in the
removal of some duplicated code.
2008-04-06 00:36:02 +10:30
Adrian Johnson
03d2b098ff Type1-fallback: Use correct glyph advance in Type 1 charstrings
5050c55f93 fixed type1-fallback to use the glyph advance instead of
glyph width in the stored glyph metrics in the font. However it did
not fix the same bug in Type 2 charstrings (used by CFF fallback in
PDF). This problem was not noticed since the glyph widths in the PDF
font dictionary overrides these values.

Fix this in case any software reading cairo PDFs uses these values.
2008-04-06 00:36:02 +10:30
Adrian Johnson
40cee8c578 Add assert to scaled_glyph_lookup in scaled-font-subsets
If _cairo_scaled_glyph_lookup() returns CAIRO_INT_STATUS_UNSUPPORTED
it will be caught by the ASSERT_NOT_REACHED in
_emit_unscaled_font_subset in PS/PDF. It is more useful to catch this
closer to the source.
2008-04-06 00:36:02 +10:30
Carl Worth
731e121c80 _cairo_pattern_get_extents: Fix to allow for expansion based on filter
This fixes the filter-bilinear-extents test case and the
related bug entry:

	bad clipping with EXTEND_NONE
	http://bugs.freedesktop.org/show_bug.cgi?id=15349

Though there are still differences in the PDF and PostScript
backends, (primarily because we can't capture cairo's filter
modes in those file formats).
2008-04-04 19:00:28 -07:00
Carl Worth
04608952e2 Replace open-coded transformation with a call to _cairo_matrix_transform_bounding_box
It's a wonderful feeiling to remove duplicate code.
2008-04-04 18:56:38 -07:00
Carl Worth
80f7aa03b3 Enable buggy_repeat workaround for X.Org servers < 1.4
This covers the known-to-broken 1.3 servers such as appeared
in Fedora 8. It also leaves the workaround off, (since it's
a severe slowdown), for the known-to-be-working 1.4.99.901
server as appears in Fedora 9 Betas.
2008-04-04 11:30:16 -07:00
Chris Wilson
2c8ead12a6 [xlib] Avoiding sending glyphs > XMaxRequestSize.
XRenderAddGlyph() does not split its image data across multiple requests
and so the glyph surface must be smaller than XMaxRequestSize or else
the server will disconnect the client, causing "Fatal IO error 104".
As this will require an extension to the XRender spec, we can work
around the issue by using our fallbacks if we detect that the glyph will
be too large for a single request.

See bugs https://bugs.freedesktop.org/show_bug.cgi?id=4339 and
http://bugs.freedesktop.org/show_bug.cgi?id=13266 for examples.
2008-04-04 18:08:25 +01:00
Chris Wilson
c0593d16c7 [pdf] Copy the glyphs for use within an smask group.
When constructing an smask group using PDF_SHOW_GLYPHS, we need a copy
of the glyphs else they'll be freed be we use them (in _show_page()).
2008-04-04 13:40:46 +01:00