Commit graph

2541 commits

Author SHA1 Message Date
Behdad Esfahbod
7f21bfb0a8 [meta-surface] Adjust tolerance when replaying to surfaces with device scale
such that we get a consistent look with different fallback resolutions.
2007-11-05 13:23:28 -05:00
Richard Hult
4270cd3358 [atsui] Use ascent+descent+leading to get the distance between baselines
The height is currently mapped to the atsui metrics property capHeight, which
is documented as "The height of a capital letter in the font from the baseline
to the top of the letter".

That doesn't match what height is in cairo, it should be the disctance between
baselines. This patch that fixes that (and makes webkit on GTK+ OS X
layout nicely).
2007-11-05 10:05:07 +00:00
Chris Wilson
bd5ed9a398 [cairo-atomic] Declare the mutex for NEEDS_MEMORY_BARRIER.
Whilst NEED_MEMORY_BARRIER should be a subset of ! HAS_ATOMIC_OPS,
until we have accurate configure tests NEED_MEMORY_BARRIER may be
invoked independently.
2007-11-05 09:05:25 +00:00
Chris Wilson
901b0c9752 [cairo-path-fixed] Exponentially enlarge cairo_path_buf_t.
Allocate subsequent path bufs twice as large as the previous buf,
whilst still embedding a small initial buf into cairo_path_fixed_t
that handles the most frequent usage.
2007-11-05 08:51:06 +00:00
Chris Wilson
92a18464ba [cairo-surface] Avoid allocation for common case of 1 box.
_cairo_surface_fill_region(): avoid allocating the array of boxes if we
know that the region only contains one box and is therefore defined by its
extents.
2007-11-05 08:51:06 +00:00
Chris Wilson
e60a7c39cd [cairo-atomic] Check whether we can access int/pointers atomically.
Add a configure check to determine whether the host cpu can read/write
cairo_atomic_t without an explicit memory barrier, and update the macros
within cairo-atomic-private.h to reflect this knowledge.
2007-11-05 08:51:06 +00:00
Chris Wilson
eb0b16837b [cairo-spline] Eliminate redundant _cairo_fixed_to_double().
Inline and unroll PointDistanceSquaredToSegment() and eliminate the
multiple conversions between fixed point and doubles. This simple
transformation both shrinks the code and wins a few percent in path
intensive benchmarks such as fuckhergently.swf
2007-11-01 22:42:34 +00:00
Chris Wilson
2a25e22658 [cairo-spline] Reduce stack requirements during recursive refinement.
By splitting out the knot vectors into a smaller, separate structure, we
can dramatically reduce the stack allocation for each level of recursion.
Secondly we can have the storage requirements by modifying the first set
of knots in-place, thus we need only allocate stack space for the knots
covering the deferred half of the spline.
2007-11-01 22:27:34 +00:00
Chris Wilson
b311c414a2 [cairo] Use NULL instead of a bare 0.
Silence a sparse warning.
2007-11-01 22:27:19 +00:00
Chris Wilson
fd5c517818 [cairo-scaled-font] Zero extents on early error.
Ensure that the output extents of cairo_scaled_font_glyph_extents(),
are zeroed if we return early due to being passed by the user a
cairo_scaled_font_t with an error set.
2007-11-01 22:27:04 +00:00
Chris Wilson
cee6aa016b [cairo-paginated-surface] Mark the backend static.
Only used within the file, so do not expose outside the library.
2007-11-01 22:26:19 +00:00
Chris Wilson
6e0151df46 [cairo-atomic] Rearrange code under the correct ifdefs.
The atomic get/set depend upon NEED_MEMORY_BARRIER which is separate
from HAVE_ATOMIC_OPS.
2007-11-01 22:26:06 +00:00
Chris Wilson
a26118cf5b [cairo-png] Check for feof whilst reading.
We need to check for both ferror() and feof() when handling short reads.
2007-10-31 21:41:24 +00:00
Chris Wilson
61143e5b21 [cairo-png] Handle missing PNG_SETJMP_SUPPORTED
If libpng has not been compiled with jmpbuf support, then we cannot
atempt to use it - in which case we fall back to png's default error
handler and abort.
2007-10-31 21:41:00 +00:00
Adrian Johnson
c37a8ace81 Round floats in output-stream to 6 significant digits after decimal
The previous commit increased the precision of floats from 6 digits
after the decimal point to 18 digits to correct rounding errors with
very small numbers. However most of the time this extra precision is
not required and results in increased PS/PDF output.

This commit makes the precision after the decimal point 6 significant
digits. For example:

   1.234567
   0.123456
   0.00123456
   0.00000000123456
2007-11-01 00:01:16 +10:30
Behdad Esfahbod
8297daff89 [cairo-output-stream] Write out floats to 18 digits after decimal point
We write floats using %f as the scientific format used by smarter %g is
invalid in PS/PDF.  %f however by default rounds to five digits after
decimal point.  This was causing precision loss and making the newly
added degenerate-pen test fail for PDF.  We now print up to 18 digits
which is as many bits doubles can accomodate.  We can be smarter, but
that's for another commit.
2007-10-31 02:41:33 -04:00
Keith Packard
06af5c2891 Force non-AA text when using a bitmap strike with only scaling transform.
When the current font size matches one of the available fixed sizes, and
the overall transform has only scaling components, FreeType will use the
fixed size bitmaps by default. For glyphs which do not have bitmaps,
force them to be rendered in monochrome instead of anti-aliased so
that they all match nicely.
2007-10-30 22:01:36 -07:00
Carl Worth
448c931425 Fix degenerate-pen test case by removing the triggering assertion
Instead we choose either the first or last pen vertex as
appropriate.

This makes the degenerate-pen pass stop failing on an
assertion, and passes for most backends. It's still failing
for the PDF backend, but that looks like a new, PDF-specific
bug.
2007-10-30 17:17:38 -07:00
Carl Worth
6957aa27e8 Merge in fix for get-path-extents test case.
With independent fixes on both branches, the test case now
passes completely. Hurrah!
2007-10-30 09:46:59 -07:00
Carl Worth
8d8724e804 Improve brace readability for multi-line conditional 2007-10-30 09:45:45 -07:00
Carl Worth
f43f0c1040 Fix remaining two calls to _cairo_path_fixed_get_current_point
The previous commit failed to fix up two callers to the
_cairo_path_fixed_get_current_point function, (and since
C doesn't distinguish between an enum and our integer-as-
Boolean, the compiler didn't complain).

Fortunately, though, the test suite did complain, as the
bug introduced a new failure into the get-path-extents
test, and git-bisect helpfully pointed to the previous
commit.

With this fix, the new failure of get-path-extents is
eliminated, (though, in this branch the arc-based failure
of that test still exists).
2007-10-30 09:44:42 -07:00
Carl Worth
00d701ff7d Limit miters for small angles
This fixes the current failure get-path-extents, which is a
demonstration of the following bug:

	cairo_stroke_extents() gives wrong result for arcs in some cases
	https://bugs.freedesktop.org/show_bug.cgi?id=7245

Many thanks to Michael Urman whose review of early versions of
this work found a fatal mistake in my algebra.
2007-10-30 08:18:57 -07:00
Carl Worth
9bf0a640d2 Add figure illustrating derivation of miter limit
And use sin in the first place rather than the more awkward
secant.
2007-10-30 08:18:56 -07:00
Chris Wilson
0d42af2427 [cairo-surface] Fix typo in doc.
s/INVALUE_FORMAT/INVALID_FORMAT/
2007-10-30 11:13:44 +00:00
Chris Wilson
39664b7cac [cairo-path] Return CAIRO_STATUS_SUCCESS.
If we have already returned the error status, then it is cleaner (and
the common idiom) to use 'return CAIRO_STATUS_SUCCESS' rather than
'return status'.
2007-10-30 11:01:40 +00:00
Chris Wilson
e57df31963 [cairo-path] Make _cairo_path_nil static.
_cairo_path_nil is only used within cairo-path.c, so there is no reason
to expose it to the rest of the libary.
2007-10-30 10:58:16 +00:00
Chris Wilson
6fdb7f129c Simplify return value from cairo_path_fixed_get_current_point().
The only caller of cairo_path_fixed_get_current_point(), used the status
return to determine whether or not the path had a current point (and did
not propagate the error) - for which we had already removed the
_cairo_error() markup. Now we reduce the boolean status return to a
cairo_bool_t, with a net reduction in code.
2007-10-30 10:43:55 +00:00
Chris Wilson
4a2ab87e1a [cairo-surface] Add the usual guards to _cairo_surface_set_font_options().
Adrian Johnson hit a SEGV after
_cairo_paginaged_surface_create_image_surface() tried to set the font
options on an error surface after running out of memory. So add the
usual checks that the surface is not a snapshot, or in an error state or
finished before modifying its font options.
2007-10-29 12:04:33 +00:00
Carl Worth
a69d473130 Fix typo in _cairo_gstate_fini
Obrigado a Luiz Americo Pereira Camara <luizmed@oi.com.br>
2007-10-26 22:58:57 -07:00
Chris Wilson
0c02b998f9 [cairo-gstate] Allow angle==0 whilst rotating.
Cut'n'paste error whilst copying the NaN check from
_cairo_gstate_scale() flagged the no rotation case as an error.
2007-10-26 18:07:31 +01:00
Chris Wilson
ce44cd6523 [cairo-gstate] Add a missing _cairo_error() markup.
Missed calling _cairo_error() for the CAIRO_STATUS_NULL_POINTER
returned by _cairo_gstate_init(). Rearrange the code to avoid the
overly complicated return statement. We note that _cairo_gstate_init()
is special as _cairo_gstate_fini() will always be called, even if an
error is thrown, and so do not do the usual cleanup in the case of an
aborted initialization.
2007-10-25 01:02:03 +01:00
Chris Wilson
4ce785e6a9 [cairo-gstate] Add NaN check to rotate.
Check the user input to _cairo_gstate_rotate() for invalid numbers.
2007-10-25 01:00:55 +01:00
Chris Wilson
6295a296b0 [cairo-gstate] Check scale sx * sy != 0.
Bill Spitzak said
    "If you really want to match when the determinant is non-zero in the
    resulting matrix, use sx*sy != 0. This appears the same as sx&&sy but
    may also catch when underflow makes the determinant zero."

Return CAIRO_STATUS_INVALID_MATRIX if we know the user input will
generate a degenerate matrix. For additional paranoia we could recompute
and validate the inverse each time as well.
2007-10-25 01:00:30 +01:00
Chris Wilson
e3248a2184 [cairo-matrix] Check user input for invalid numbers.
Supplement the guards for scale==0 with checks that the user does not
attempt to translate or scale by invalid numbers.
2007-10-22 17:16:50 +01:00
Adrian Johnson
8888afe9a4 PDF: Fix meta surface patterns with EXTEND_REFLECT 2007-10-22 23:05:25 +09:30
Adrian Johnson
fb2bf3e250 win32-printing: remove unused code 2007-10-21 23:50:57 +09:30
Adrian Johnson
b854d1e1b5 win32-printing: fix typo in comment 2007-10-21 23:50:28 +09:30
Adrian Johnson
2d68c46b77 win32-printing: fix dash-caps-joins test failure 2007-10-21 23:49:58 +09:30
Adrian Johnson
e63b5e5201 win32-printing: Use the surface ctm in show_glyphs
show_glyphs needs to scale the font by the current CTM.
2007-10-21 23:47:35 +09:30
Adrian Johnson
ac9831ea55 win32-printing: fix stroke rounding problems
The win32 CTM is changed to user space to set the stroke parameters.
As win32 uses integers for stroke parameters this will cause rounding
problems depending on the CTM used.

This is fixed by factoring out a scale from the user space CTM so that
xx, xy, yx, and yy in the CTM are all < 1. This preserves the shape
of the transformation while ensuring that the CTM does not cause
rounding problems. The stroke parameters are multiplied by the scale
value.
2007-10-21 23:46:52 +09:30
Adrian Johnson
89fe7b2ff0 win32-printing: fix rounding problems when using pattern matrix
When using meta surface patterns, the win32 CTM is changed to the
inverted pattern matrix then the meta surface is replayed to the
surface. The problem with this is that win32 uses integer coordinates
for GDI functions. A pattern matrix that scale the CTM up will cause
rounding errors in the position of each path in the pattern.

This is fixed by always keeping the win32 CTM set to the identity
matrix. The CTM is stored in the surface and all coordinates are
transformed by the CTM before calling GDI functions.
2007-10-21 23:45:40 +09:30
Adrian Johnson
af01d9b8fa win32-printing: add meta surface pattern support 2007-10-21 23:43:27 +09:30
Adrian Johnson
c8da2a7ded win32-printing: check if images are opaque
Don't use fallback for argb32 images with all alpha == 255.
2007-10-21 23:42:22 +09:30
Adrian Johnson
9eb5747755 win32-printing: Add missing struct initializers 2007-10-21 23:41:31 +09:30
Brian Ewins
8f6abdbc26 [quartz] return status instead of CGPatternRef
Returning status improves error handling, since
returning NULL doesn't let us distinguish different
types of error.
2007-10-20 23:41:46 +01:00
Brian Ewins
cfb26fdf0f [quartz] return status instead of cairo_quartz_surface_t
Returning status improves error handling, since
returning NULL doesn't let us distinguish different
types of error.
2007-10-20 23:41:32 +01:00
Brian Ewins
dec3099585 [quartz] return status instead of CGShadingRef
Returning status improves error handling, since
returning NULL doesn't let us distinguish different
types of error. Suggested by Chris Wilson.
2007-10-20 22:45:30 +01:00
Brian Ewins
481ce2b8cb implement clipping with surface masks.
This implements clipping using CGContextClipToMask, which
means that it will only have an effect on OS X 10.4+.
No additional tests pass with this fix - mainly due to
text effects and problems with the IN, OUT, DEST_IN, DEST_ATOP
operators.
2007-10-20 14:06:07 +01:00
Brian Ewins
b9c065df74 fix dash-zero-length test
Quartz was failing the dash-zero-length test for odd numbers
of dashes; it seems cairo wants 3 dashes to be on-off-on,
off-on-off, wheras quartz uses on-off-on, on-off-on. Fixed
by doubling the number of dashes used.
2007-10-20 14:02:19 +01:00
Brian Ewins
f334ee0397 Implement EXTEND_NONE for gradients.
Fixes linear and radial gradients, which were displaying with
extend_pad when extend_none was requested. Makes the
radial-gradient test pass.
2007-10-20 14:02:17 +01:00