_cairo_pattern_is_opaque() returns false for none-extended linear
gradients and for radial gradients, but fallback is only needed if
they have non-opaque stops.
This can be tested using _cairo_pattern_alpha_range(), which only
analyses the part of the pattern which is drawn.
Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
Both the ps and pdf backends are open coding analyses of the
range of pattern alphas. This patch factors out a new function
_cairo_pattern_alpha_range() to do that for them.
Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
Use the tests for degeneracy and new radial gradient definition
when computing pattern extents. Degenerate gradients are optimised
away by cairo-gstate into solid or clear patterns, and
the radial gradients semantics have changed to match PDF semantics.
Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
Change the signature of type-specific functions to make them only
accept the correct pattern type instead of the abstract cairo_pattern_t.
Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
_cairo_polygon_limit() had to be called immediately after
_cairo_polygon_init() (or never at all).
Merging the two calls is a simple way to enforce this rule.
Using _cairo_path_fixed_interpret_flat() greatly simplifies the path
to polygon conversion (because it already converts curve_to's to
line_to's).
This commit also removes the optimization which merges two consecutive
lines if they have the same slope, because it's unlikely (since it
should already happen during path construction), it doesn't provide
better performance (at least not measurable with the currently
available cairo-traces) and bloats the code.
Path are always interpreted in forward direction, so the ability of
interpreting in the opposite direction (which is very unlikely to be
useful at all) can be removed.
All other pdf drawing functions have been updated to use
cairo_composite_rectangles_t to compute the extents affected by the
operation in 3a5d71c431, but fill_stroke
was not changed.
This removes the last usage of the old _cairo_surface_*_extents()
functions.
The handling of angles above 2pi in cairo_arc is not very solid and is
basically untested.
This test should ensure that changes in the behavior will be noticed
by the testsuite.
To limit the amount of memory used for arcs describing a circle
wrapped multiple times we ignore the circles after the 65536th (but
preserve the same start and end angle mod 2pi).
Adding/subtracting 2 * M_PI to a huge floating point number doesn't
change it (because of rounding) and for smaller numbers it still
requires a lot of cycles before the angle is in the desired range.
The same computation can be performed using fmod, which should provide
more accurate results and only requires O(1) time.
In https://bugs.launchpad.net/ubuntu/+source/libcairo/+bug/680628 a
65K PDF printed to PDF using poppler-cairo turns into an 8MB PDF. The
original PDF contains a very large number of stencil mask images (an
A1 image used as a mask for the current color). The PDF surface was
not optimized for this particular case. It was drawing a solid color
in a group and then using an smask with the image in another group.
Fix this by checking for source = solid and mask = A1 image and
emitting a stencil mask image.
Go through each Charstring looking for the local and global
subroutines called. To avoid modifying the Charstrings [1], the unused
subroutines are reduced to a single byte return op [2] leaving the
remaining subroutines in their original array index position.
Results of testing with some CFF fonts with a 26 glyph [a-z] subset:
Font Subset size: Before After
-------------------------------------------------------
LinBiolinum_Re-0.6.4.otf 48,423 8,295
LinBiolinum_It-0.5.1.otf 88,942 11,501
LinBiolinum_Sl-0.4.9.otf 89,231 11,505
LinLibertine_Re-4.7.5.otf 51,125 8,654
LinLibetine_It-4.2.6.otf 59,333 9,632
Inconsolata.otf 13,826 8,407
[1] Further reductions could be obtained by stripping out unused
subroutines and renumbering the remaining subroutines but is more
complicated due to the encoding used for subroutine numbers that is
both variable length and a function of the size of the subroutine
array.
[2] Poppler and Fontforge do not seem to like zero length unused
subroutines.
An A1 image with full alpha should be opaque black, not opaque white.
Use specialized solid black image instead of the generic constructor
for an A8 image with full alpha (it is likely to be cached).
The input of _fill_unaligned_boxes is (supposed to be) composed only
of disjoint rectangles, that can safely be passed to the rectilinear
span converter, but this function artificially introduces intersecting
rectangles when drawing non-aligned boxes.
Using non-intersecting rectangles is easy and makes the code correct.
Fixes rectilinear-grid.
Reviewed-by: Uli Schlachter <psychon@znc.in>
The rectilinear scan converter assumes disjoint rects as input, but
cairo-image passes intersecting rectangles to it.
This test shows that image and any backends passing through it for the
rasterization (fallbacks, vector backends whose renderer is
cairo-based) fail in compute the corners of intersecting rectangles
correctly.
The recording surface source image painted onto fallback images always
had the resolution 72ppi instead of the fallback resolution of the
target surface. Fix this by passing adding a new
acquire_source_image_transformed backend function for the recording
surface to use and passing the target device transform through to the
recording surface when the image is acquired.
Based on Carl Worth's experimental acquired_source_image_transformed
branch.
https://bugs.freedesktop.org/show_bug.cgi?id=24692
The compiler complains about a const pointer being free'd and memcpy'd
to:
cairo-pdf-surface.c: In function ‘_cairo_pdf_surface_add_source_surface’:
cairo-pdf-surface.c:1208: warning: passing argument 1 of ‘__builtin___memcpy_chk’ discards qualifiers from pointer target type
cairo-pdf-surface.c:1208: warning: passing argument 1 of ‘__inline_memcpy_chk’ discards qualifiers from pointer target type
cairo-pdf-surface.c: In function ‘_cairo_pdf_source_surface_entry_pluck’:
cairo-pdf-surface.c:1666: warning: passing argument 1 of ‘free’ discards qualifiers from pointer target type
493aaf0f15 made all cairo_array
functions use unsigned int for indexes and sizes.
This commit fixes the compiler warnings about those values being
compared to signed int's.
Const-ify where appropriate and make all index and element counts
unsigned int.
This is needed to enable accessing const cairo_array_t's without
having to manually remove the const qualifier (which happens in the
to-be-merged mesh pattern code, for example).
It is sometimes useful to read the elements of a const cairo_array_t,
but it is currently only possible by ignoring the const qualifier.
The _cairo_array_index_const function allows read-only access to the
array elements.
This is needed to enable accessing const cairo_array_t's without
having to manually remove the const qualifier (which happens in the
to-be-merged mesh pattern code, for example).
Array snapshots are not used anymore and just bloat the implementation
of cairo_array_t.
In particular, double indirection was needed to implement array
snapshots, as explained in c786853993.
Painting of some pattern was broken because the paint operation was
implemented as a fill to a rect containing the clip, but this rect was
not transformed as appropriate (using the cairo_to_ps matrix).
PDF simply fills the whole surface rect, so we implement the same
behavior in PS.
Fixes clip-group-shapes-circles, clip-stroke, linear-gradient-extend,
linear-gradient-one-stop, radial-gradient-one-stop.
There were some difference between how the FT and Win32
load_truetype_table font backend functions worked due to the
difference between FT_Load_Sfnt_Table() and GetFontData(). eg FT
returns an error if less than the requested number of bytes could be
read while Win32 returns success and sets the length to the number of
bytes read.
Make the default case be an assert to catch a silly programming error
and silence the compiler:
cairo-pdf-operators.c: In function ‘_word_wrap_stream_write’:
cairo-pdf-operators.c:300: warning: ‘count’ may be used uninitialized in
this function
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>