Commit graph

4055 commits

Author SHA1 Message Date
Chris Wilson
aaec63d483 [scaled-font] Global glyph cache
Currently glyphs are cached independently in each font i.e. each font
maintains a cache of up to 256 glyphs, and there can be as many scaled fonts
in use as the application needs and references (we maintain a holdover
cache of 512 scaled fonts as well).

Alternatively, as in this patch, we can maintain a global pool of glyphs
split between all open fonts. This allows a heavily used individual font
to cache more glyphs than we could allow if we used per-font glyph caches,
but at the same time maintains fairness across all fonts (by using random
replacement) and provides a cap on the maximum number of global glyphs.

The glyphs are allocated in pages, which are cached in the global pool.
Using pages means we can exploit spatial locality within the font
(nearby indices are typically used in clusters) to reduce frequency of small
allocations and allow the scaled font to reserve a single MRU page of
glyphs. This caching dramatically reduces the cairo overhead during the
cairo-perf benchmarks, and drastically reduces the number of allocations
made by the application (for example browsing multi-lingual site with
firefox).
2009-01-29 10:10:39 +00:00
Chris Wilson
54f6a49ebb [bounds] Skip spline evaluation based on bounding bbox of control points.
The bounding polygon of the control points, defines the extents of the
spline. Therefore if the control points are entirely contained within the
current path extents, so is the spline and we do not need to evaluate its
tight bounds.
2009-01-29 10:10:39 +00:00
Chris Wilson
e217c4da7b [in-stroke] Check point against extents before computing path.
We can avoid tessellating the path entirely by first checking whether the
query point is inside the path extents.
2009-01-29 10:10:39 +00:00
Chris Wilson
48f9a0e6da [spline] Correct the definition of a cubic Bezier curve.
Add the missing coefficients for p1 and p2 so the derivation of the
derivative and the solution for its inflection points stands correct.
2009-01-29 10:10:39 +00:00
Chris Wilson
ee7ac5681f [path] A degenerate curve_to becomes a line_to.
Be consistent.
2009-01-29 10:10:39 +00:00
Chris Wilson
778ced4879 [path] Rename _cairo_path_fixed_approximate_extents()
Rename approximate_extents() to approximate_clip_extents() so that it is
consistent with the fill and stroke variants and clearer under what
circumstances you may wish to use it.
2009-01-29 10:10:39 +00:00
Chris Wilson
ff5d37a8ad [mutex] Civilise the comment.
Note bene that Behdad does not like people shouting.
2009-01-29 10:10:38 +00:00
Jeff Muizelaar
f4ff6128d7 Avoid "empty body in an if-statement" warning
Use '(void)expr;' instead of 'if (expr) ;' to avoid getting the warning.
'if (expr) {}' is an option, however '(void)expr;' seems like a more common
idiom and getting warnings for __attribute__((warn_unsed_result)) functions is
probably prefered.
2009-01-28 17:16:32 -05:00
Adrian Johnson
41feeedcc1 Use PS font name in PS TrueType fonts 2009-01-22 23:12:14 +11:00
Adrian Johnson
b7a9e1d4ac Embed full font name in PDF TrueType and CFF fonts
if the full font name was available in the font.
2009-01-22 23:12:14 +11:00
Adrian Johnson
6f2db9a4b0 Use PS font name in CFF and TrueType PDF font subsets
James Cloos found that the font name in embedded fonts should be the
PostScript font name (nameID=6 in the name table).

http://lists.cairographics.org/archives/cairo/2008-December/015919.html
2009-01-22 23:12:14 +11:00
Adrian Johnson
2ed08f7801 Factor out duplicate code in truetype and cff subsetting
The code for reading the font name from the name table has been moved
to a new function: _cairo_truetype_read_font_name().
2009-01-22 23:12:14 +11:00
Adrian Johnson
1deb1e4510 PDF: Include subset tag in font name
PDF requires font names of subsetted fonts to be preprended with
"XXXXXX+" where XXXXXX is a sequence of 6 uppercase letters unique the
font and the set of glyphs in the subset.
2009-01-22 23:12:14 +11:00
Chris Wilson
afce1cfe98 [scaled-font] Avoid repeated lookup of the same unicode during text->glyphs
Performing the unicode to index is quite expensive, the
FcFreeTypeCharIndex() taking over 12% in the cairo-perf text benchmarks.
By adding a simple cache of translated unicode indices, we save around 25%
of the lookups during benchmarks, with a relative reduction in runtime.
2009-01-14 16:51:08 +00:00
Behdad Esfahbod
06deaa98b6 [build] Include all generated win32 build files in the repo
So a git clone can be built on win32.  The files only change after adding
new backends.
2009-01-09 15:55:24 -05:00
Chris Wilson
acb2717372 [quartz] Define RTLD_DEFAULT
RTLD_DEFAULT is a gnu-ism (at least according to the manpage on my linux
system) so declare _GNU_SOURCE before including dlfcn.h and failing that
provide our own definition.
2009-01-03 21:53:15 +00:00
Chris Wilson
f230ce7658 [path] Fix typo in bounds for empty path.
We set the width to be zero, twice, and the height not even once!
2009-01-02 15:44:51 +00:00
Chris Wilson
65f9760d66 [toy-font-face] Return defaults for error objects.
Similar to the behaviour of the other objects, we return the default
conditions if the object is in any error (and not just a nil object).
2009-01-02 15:44:50 +00:00
Behdad Esfahbod
d478d5ed5c [doc] Give a small hint about Twin font
Though, the details are not documented yet.  I'm not sure how much of it
I do want to document.
2009-01-02 06:51:15 -05:00
Chris Wilson
c601f30843 [cairo] Early return if we attempt to set the same colour.
Profiling a silly video renderer that called set-source; rectangle; fill;
for each pixel, we can shave 5% off the cairo overhead by introducing an
early return if we attempt to reset the current colour.
2009-01-02 09:53:27 +00:00
Chris Wilson
fb3522f33a [os2] Fix memory leak of surface on error path
Of we fail to create the mutex, free the surface before returning the
failure.

Reported: http://bugs.freedesktop.org/show_bug.cgi?id=19208.
2009-01-02 09:53:27 +00:00
Chris Wilson
8d23c3a6c2 [quartz] Delay allocation of string until after guard.
Fixes a memory leak should we bail due to the version of Quartz being
insufficient.

Reported: http://bugs.freedesktop.org/show_bug.cgi?id=19209.
2009-01-02 09:53:27 +00:00
Chris Wilson
9c9ed8f0b5 [scaled-font] Post-process hash value.
Mix the bits within the hash value to reduce clustering.
2009-01-02 09:53:26 +00:00
Chris Wilson
555dd6b97e [scaled-font] Switch to a constant loop for hashing.
As we only use the FNV hash for hashing matrices, expose the constant size
to the compiler so that it can perform its magic.
2009-01-02 09:53:26 +00:00
Chris Wilson
f5274f5847 Iterate over hash table using foreach() in destructors.
Don't use the remarkably inefficient _cairo_hash_table_random_entry() to
remove all entries from the hash table!
2009-01-02 09:53:26 +00:00
Chris Wilson
1c4ea84b24 [cairo] Early return if we attempt to set the same scaled_font
If the application calls cairo_set_scaled_font() with the current
scaled font, we can return early as it is a no-op.
2009-01-02 09:53:26 +00:00
Chris Wilson
b661f3d27b [cairo] Embed a second gstate.
Experiment with embedding a second gstate into the initial context to
reduce allocations.
2009-01-02 09:53:25 +00:00
Behdad Esfahbod
14d94d9354 Fix various README typos 2009-01-02 02:56:38 -05:00
Behdad Esfahbod
28a72648ba [gstate] Change the glyph dropping safety margin from 2em to 10em
The small margin caused bugs with math fonts.  See:
https://bugzilla.mozilla.org/show_bug.cgi?id=460023
2008-12-30 13:48:47 -05:00
Chris Wilson
fa63c43532 [spline] Be pedantic and propagate errors.
We know that the current users will always return SUCCESS, but propagate
the status return for future users.
2008-12-29 16:11:29 +00:00
Chris Wilson
e10af38799 make "make check" happy again
Add the missing scoping that caused check-plt to complain.
2008-12-29 12:55:10 +00:00
Chris Wilson
0100856226 [path] Remove tolerance from path bounders
With Behdad's analytical analysis of the spline bbox, tolerance is now
redundant for the path extents and the approximate bounds, so remove it
from the functions parameters.
2008-12-29 12:55:09 +00:00
Behdad Esfahbod
efb1716090 [_cairo_spline_bound] Protect against b == 0 2008-12-28 16:06:27 -05:00
Behdad Esfahbod
0b59e29004 [_cairo_spline_bound] Simplify condition 2008-12-28 02:49:39 -05:00
Behdad Esfahbod
3bf1b7d574 [_cairo_spline_bound] Fix the check for feasible solutions
Also make it more strict.  The only times we call sqrt now is
when a solution in (0,1) exists.
2008-12-28 02:41:39 -05:00
Behdad Esfahbod
7f840d156c [spline] Save a couple more muls 2008-12-28 02:02:30 -05:00
Behdad Esfahbod
3292f9906b [spline] Do some checks to avoid calling sqrt() if no feasible solution exists 2008-12-28 01:59:12 -05:00
Behdad Esfahbod
efe4d2ce99 [spline] Simplify code 2008-12-28 01:22:40 -05:00
Behdad Esfahbod
8672178bf6 [spline] Remove duplicated code by using a macro 2008-12-28 01:20:37 -05:00
Behdad Esfahbod
ef0f6c3ca3 [spline] Add an analytical bounder for splines
The way this works is very simple:  Once for X, and once for Y, it
takes the derivative of the bezier equation, equals it to zero and
solves to find the extreme points, and if the extreme points are
interesting, adds them to the bounder.

Not the fastest algorithm out there, but my estimate is that if
_de_casteljau() ends up breaking a stroke in at least 10 pieces,
then the new bounder is faster.  Would be good to see some real
perf data.
2008-12-27 23:44:58 -05:00
Behdad Esfahbod
f2f62c7c44 [twin] Micro-optimize 2008-12-27 16:25:51 -05:00
Chris Wilson
50bc2bc017 [path] Simply track the current point for bounds.
The idea is to track always update the current point, but not add it
during a move-to.
2008-12-27 11:46:24 +00:00
Chris Wilson
078ebb01ba [path] Initialise spline from current point
Joonas spotted that the breakage with the curve bounds was the result of
initialising the spline using the original move to point and not the
current point.

Fixes: Bug 19256 Gnome Foot in gnome-games rendered incorrectly
(https://bugs.freedesktop.org/show_bug.cgi?id=19256)
2008-12-27 11:34:31 +00:00
Chris Wilson
e76a676c8f [twin] Trivial spelling correction.
This ain't no decadent descendent of the Hershey font...
2008-12-27 11:34:31 +00:00
Behdad Esfahbod
ab1febbf22 [twin] Resnap margin under monospace 2008-12-26 16:37:06 -05:00
Behdad Esfahbod
3c91d9f5a2 [twin] Adjust margins 2008-12-26 16:30:01 -05:00
Behdad Esfahbod
0b5c60bae1 [twin] Clean up hinting 2008-12-26 15:49:28 -05:00
Behdad Esfahbod
6e7a2c4ce3 [twin] Fix monospace for narrow glyphs 2008-12-26 15:41:13 -05:00
Behdad Esfahbod
e8e6ae1294 [twin] Cache pen and other properties on the scaled font 2008-12-26 15:17:15 -05:00
Behdad Esfahbod
e133cc1446 [twin] Don't stretch pen 2008-12-26 14:56:32 -05:00