The stream handling has been changed to support writing the content to
one or more group objects. Each page has a top level knockout
group. The first operation in the knockout group paints another group
containing the content. Fallback images are painted from the knockout
group. This ensures that fallback images do not composite with any
content under the image.
Introduce cairo_gradient_stop_t, and remove pixman dependency
for core pattern types. Perform conversion from cairo types
to pixman types as necessary in fallback code.
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them. The macros
return NULL if int overflow would occur during the allocation. See
CODING_STYLE for more information.
_cairo_pdf_surface_emit_pattern_stops() tried to set the last element
to have an offset of exactly 1.0, but missed and set the next element
after the end of the array.
Original work by Jorn Baayen <jorn@openedhand.com>,
2715f20981
We use a small cache of size 16 for surfaces created for solid patterns.
This mainly helps with the X backends where we don't have to create a
pattern for every operation, so we save a lot on X traffic. Xft uses a
similar cache, so cairo's text rendering traffic with the xlib backend
now completely matches that of Xft.
The cache uses an static index variable, which itself acts like a cache of
size 1, remembering the most recently used solid pattern. So repeated
lookups for the same pattern hit immediately. If that fails, the cache is
searched linearly, and if that fails too, a new surface is created and a
random member of the cache is evicted.
A cached surface can only be reused if it is similar to the destination.
In order to check for similar surfaces a new test is introduced for the
backends to determine that the cached surface is as would be returned by
a _create_similar() call for the destination and content.
As surfaces are in general complex encapsulation of graphics state we
only return unshared cached surfaces and reset them (to clear any error
conditions and graphics state). In practice this makes little difference
to the efficacy of the cache during various benchmarks. However, in order
to transparently share solid surfaces it would be possible to implement a
COW scheme.
Cache hit rates: (hit same index + hit in cache) / lookups
cairo-perf: (42346 + 28480) / 159600 = 44.38%
gtk-theme-torturer: (3023 + 3502) / 6528 = 99.95%
gtk-perf: (8270 + 3190) / 21504 = 53.29%
This translates into a reduction of about 25% of the XRENDER traffic during
cairo-perf.
Some PDF viewers forget the CTM when drawing gradient patterns
with SMasks. This patch works around these bugs by using the default
identity matrix for the CTM. All paths are transformed from
cairo to pdf coordinates before writing to the pdf file.
Make cairo-scaled-font-subsets.c limit Type1 font subsets to
256 glyphs. This allows Type1 subsetting to be enabled again
with type1-fallback as the fallback option for Type1 fonts.
OpenType/CFF fonts come in two types: CID and non CID.
CFF CID font subsetting was previously disabled in cairo
due 1) to the need to embed CFF CID fonts in PDF as a CID fonts
and 2) there is no easy way to convert CFF CID to CFF non CID.
With the switch to CID fonts cairo-cff-subset.c has been
updated to subset CID fonts and to covert non CID fonts to
CID. A further advantage of converting non CID CFF fonts
to CID is the reduction in size due to not embedding the
name of each glyph in the font subset.
cairo-scaled-font-subsets.c now provides three functions for creating subsets:
_cairo_scaled_font_subsets_create_scaled()
Create a subset for each scaled font with maximum size INT_MAX.
_cairo_scaled_font_subsets_create_simple()
Create subsets suitable for embedding as simple fonts in PS/PDF.
_cairo_scaled_font_subsets_create_composite()
Create subsets suitable for embedding as composite fonts in PS/PDF.
The _create_simple() and _create_composite() functions both merge
scaled fonts with the same face and an outline path available into
the same subset. _create_composite() has a maximum subset size of
65536 for outline fonts. Bitmap fonts have a separate subset for
each scale with a maximum subset size of 256.
The _create_simple() and _create_composite() functions both reserve
the first glyph in the subset for the .notdef glyph. CID fonts require
CID 0 to be .notdef.
Update Type1, TrueType and CFF subsetting to expect glyph 0 of each
subset to be the .notdef.
Obviously, the new name is _cairo_pdf_surface_emit_to_unicode_stream which
is consistent with the to_unicode_stream identifiers already existing in
the implementation.
With the hack in _cairo_pattern_acquire_surface to return a 2x2
surface for reflected patterns, we can now accept REFLECT surface
patterns natively in all backends. SVG was already doing that.
The PDF case needed some changes to go through
_cairo_pattern_acquire_surface. A similar change to the recent
change in SVG.
cairo-scaled-font-subsets stores two sets of subsets -
scaled and unscaled. The first time each glyph is mapped,
_cairo_scaled_glyph_lookup() is called to determine if
the glyph is bitmap or outline. Outline glyphs are put
in the unscaled subsets. Bitmap glyphs are put in the
scaled subsets. The unscaled subsets hash table keyed is
the scaled_font->font_face to ensure only one font for
each font face is created. The scaled subsets hash
table is keyed by scaled_font.
_cairo_scaled_font_subsets_create() now takes two arguments
to specify the maximum size of the scaled and unscaled subsets.
If the unscaled max size is set to 0 all glyphs are mapped
to scaled subsets.
A separate foreach function is provided for scaled and unscaled
subsets. The PDF and PS backends iterate over the unscaled
subsets to emit CFF, TrueType, and Type1 fonts. The scaled
subsets are iterated to emit Type3 bitmap fonts.
The function _cairo_pdf_surface_write_fonts is the
original PDF TrueType font embedding function that was
disabled in commit f500cef19f
shortly before Type3 font support was added.
TrueType font embedding was later reintroduced as new code
making this function obsolete.
- Add a to_unicode array to the scaled_font_subsets
for mapping glyphs to unicode characters
- Add a function to the TrueType subsetting for
performing a reverse cmap for mapping glyph indices
to unicode characters.
- Add a new scaled font backend function for mapping
glyph indices to unicode characters. Provide FreeType
and Win32 implementations of the font backend mapping
function.
- Modify the PDF backend to embed ToUnicode streams
into each font. The unicode mapping is obtained by
first trying the reverse cmap. If this fails the font
backend mapping function is called.