Commit graph

9056 commits

Author SHA1 Message Date
Alexandros Frantzis
a6facced8d gl: Use the GL core 2.0 shader implementation for both GL 1.x ARB and GL 2.x
The GL core 2.0 shader implementation can be used by both GL 1.x and 2.x
thanks to the dispatch table.
2010-12-15 15:32:20 +00:00
Alexandros Frantzis
cf518b29e0 gl: Use the dispatch table for calling ARB/EXT functions
Use the dispatch table for calling GL functions that can have multiple name
variants. Also, always use the core variant names for GL constants.
2010-12-15 15:32:20 +00:00
Alexandros Frantzis
ed862d3f7b gl: Add definitions for the core variant names of used GL constants
This allows us to use the core variant of the needed GL constants regardless of the
GL header version that is being used for compilation.
2010-12-15 15:32:20 +00:00
Alexandros Frantzis
e0ab932c61 gl: Embed the GL dispatch table in the cairo-gl context and initialize it. 2010-12-15 15:32:20 +00:00
Alexandros Frantzis
357c2f46a7 gl: Add infrastructure for calling GL functions using a dispatch table
Some GL functions can be called using different names depending on the
GL version and available extensions (ARB, EXT). The dispatch table
abstracts these differences and provides a uniform API for dealing with
these functions.
2010-12-15 15:32:20 +00:00
Alexandros Frantzis
cd7c0df2bb gl: Add functions to query GL version and extensions 2010-12-15 15:32:19 +00:00
Chris Wilson
07abd21a03 test/arc-infinite-loop: Random return value fun. 2010-12-15 15:32:19 +00:00
Andrea Canciani
65040d3e3f test: Add bug-extents
Add a test for the computation of approximate extents used by most
backends to esimate the region affected by drawing operations.

Based on:
http://lists.cairographics.org/archives/cairo/2010-December/021331.html
2010-12-14 22:18:27 +01:00
Chris Wilson
f10b3105d3 scaled-font: assert that we hold the scaled-font mutex when looking up glyphs
Holding the mutex over glyph lookup not only prevents multi-threaded
races between insertion and deletion that spell disaster for memory
integrity, but also implies that the glyph cache is frozen.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-12-13 16:30:15 +00:00
Andrea Canciani
5eadc286d8 path: Silence warnings
gcc complains that:

cairo-path-fixed.c:400: warning: inlining failed in call to
  '_cairo_path_fixed_drop_line_to': call is unlikely and code size
  would grow
2010-12-13 11:09:20 +01:00
Andrea Canciani
c05135a348 test: Update ref images
The recent (and not-so-recent) changes in gradient code changed the
results of some tests involving gradients.

radial-gradient-* tests are marked XFAIL for pdf because poppler is
not sampling the color function with a sufficient frequency, but they
look correct in Adobe Reader.
2010-12-13 10:05:42 +01:00
Andrea Canciani
3cbe82fe58 ps,pdf: Deal with empty domain gradients.
If all the stops of the gradient have the same offset and the
pattern's extend mode is EXTEND_PAD, then we cannot use the stops'
domain as the interpolation parameter range because this would produce
a gradient with the same start and end objects.  Such ranges tickle
bad behaviour in rasterisers.

We replace the color function with an appropriate step function
defined on [0 1].

Fixes radial-gradient-one-stop for pdf and ps3.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 10:05:11 +01:00
Andrea Canciani
36e58aea51 ps: Unify gradient emitters and support all extend modes.
To draw repeated gradients in ps, which only supports none and pad
extended gradients, we need an appropriate reparametrization of the
gradients that will cover the whole clip region without needing
repeats.

This commit adds support for the drawing of reflect/repeat-extended
radial gradients through native ps patterns, using pad-extension and
no fallbacks.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 10:05:03 +01:00
Andrea Canciani
20ef062511 pdf: Unify gradient emitters and support all extend modes.
To draw repeated gradients in pdf, which only supports none and pad
extended gradients, we need an appropriate reparametrization of the
gradients that will cover the whole clip region without needing
repeats.

This commit adds support for the drawing of reflect/repeat-extended
radial gradients through native pdf patterns using pad-extension and
no fallbacks.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=28870

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:09 +01:00
Andrea Canciani
ca7f141dd7 quartz: Unify gradient construction and fix radial gradients.
Share code between linear and radial gradients, using
_cairo_gradient_pattern_box_to_parameter() instead of open coding the
parameter range computation.

As a side effect this fixes parameter range computation for radial
gradients, because the previous code assumed that the focal point was
inside the circles.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:09 +01:00
Andrea Canciani
341e5b3246 pattern: Add a function to interpolate gradient objects.
This will be a common function used by the quartz, ps, and pdf
backends when rewriting EXTEND_REFLECT/REPEAT gradients in terms
of EXTEND_PAD gradients.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:09 +01:00
Andrea Canciani
08cb6db520 pattern: Use pattern parameter range when analysing all gradients.
This patch adds support for analysing the transparency of a
radial gradient within some area of interest.  Before the code
would ignore the extents for radial gradients.  Linear gradients
now use _cairo_linear_pattern_box_to_parameter() allowing us
to remove the superfluous _extents_to_linear_parameter().

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:09 +01:00
Andrea Canciani
790837ac68 pattern: Compute a covering parameter range of a gradient for a box.
This makes it possible to compute the interpolation range needed to
correctly draw a gradient so that it covers an area of interest.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:09 +01:00
Andrea Canciani
d1e9bdf7f1 ps: Avoid unneeded fallbacks for gradients with opaque stops.
_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>
2010-12-13 09:46:09 +01:00
Andrea Canciani
ec4c085624 ps, pdf, pattern: Implement _cairo_pattern_alpha_range to analyse patterns.
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>
2010-12-13 09:46:09 +01:00
Andrea Canciani
6579bf728f pattern: Improve extents computation of radial gradients.
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>
2010-12-13 09:46:08 +01:00
Andrea Canciani
86695aced9 pattern: Specialise signatures of pattern specific functions
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>
2010-12-13 09:46:08 +01:00
Andrea Canciani
ac9ed746b0 ps: Use switch instead of multiple if's
This ensures that the compiler is able to automatically point out any
unhandled pattern type.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:08 +01:00
Andrea Canciani
e6ab2e6821 pdf: Use switch instead of multiple if's
This ensures that the compiler is able to automatically point out any
unhandled pattern type.

Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
2010-12-13 09:46:08 +01:00
Andrea Canciani
790d6140e7 test: Update reference images list
Some reference images were added or removed in
f85af7fe8d,
e2dcbfd895 and
670eb260eb, but Makefile.am was not
updated accordingly.
2010-12-13 09:43:13 +01:00
Andrea Canciani
85a489f0f2 polygon: Merge _cairo_polygon_init and _cairo_polygon_limit
_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.
2010-12-10 11:04:48 +01:00
Andrea Canciani
75f34b595a fill: Simplify path to polygon conversion
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.
2010-12-10 11:04:47 +01:00
Andrea Canciani
df453b7aca path: Remove support for inverse direction interpretation
The previous commit guarantees that paths are always interpreted in
the forward direction, so the code allowing both directions is not
needed anymore.
2010-12-10 11:04:47 +01:00
Andrea Canciani
a8ae8759f5 path: Always interpret in forward direction
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.
2010-12-10 10:58:51 +01:00
Andrea Canciani
83605de995 path: Cleanup unused current_point
The code keeps track of the current point but doesn't use it.

Remove it to clean up.
2010-12-10 10:49:37 +01:00
Andrea Canciani
f317a31b3f surface: Remove _cairo_surface_*_extents
They have been replaced by cairo_composite_rect_t functions.
2010-12-10 10:34:47 +01:00
Andrea Canciani
0ae9b54741 pdf: Use composite rectangles in fill_stroke
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.
2010-12-10 10:34:47 +01:00
Andrea Canciani
71e6520fa6 surface: Remove _cairo_surface_fill_rectangle
It is not used anymore.
2010-12-10 10:34:47 +01:00
Andrea Canciani
17fef8c437 test: Add arc-infinite-loop
The handling of angles above 2pi in cairo_arc is not very solid and is
basically untested.

This test should ensure that huge inputs don't hang cairo.
2010-12-09 17:33:12 +01:00
Andrea Canciani
670eb260eb test: Add arc-looping-dash
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.
2010-12-09 17:33:12 +01:00
Andrea Canciani
1784fd403e arc: Clamp to 65536 full circles
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).
2010-12-09 17:33:12 +01:00
Andrea Canciani
4314a86aa7 arc: Avoid infinite loop
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.
2010-12-09 17:33:12 +01:00
Andrea Canciani
028797a729 test: Handle crashed tests
Crashed tests are reported as "CRASH!" in cairo-test-suite.log
2010-12-09 17:33:12 +01:00
Adrian Johnson
d3accefd3b PDF: Output a stencil mask for cairo_mask() with solid source and A1 mask
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.
2010-12-05 00:29:52 +10:30
Adrian Johnson
6732dbf299 CFF Subsetting: Subset subroutines
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.
2010-11-30 22:00:38 +10:30
Andrea Canciani
4e60a164d4 test: Fix ref images
The corners of the boxes in these ref images were not correct.
2010-11-28 19:26:35 +01:00
Andrea Canciani
8d7486a6ea image: Fix _pixel_to_solid
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).
2010-11-28 18:37:16 +01:00
Andrea Canciani
72b0a44a1f image: Fix compositing of unaligned boxes
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>
2010-11-28 18:35:16 +01:00
Andrea Canciani
1038973083 test: Add rectilinear-grid
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.
2010-11-28 15:42:08 +01:00
Andrea Canciani
cfafa3924b array: Fix comment
The comment was talking about using 0 as index, but was using
"num_elements" instead.
2010-11-28 09:33:14 +01:00
Adrian Johnson
f238da5291 CFF subset: fix bug with euro glyph in fallback fonts 2010-11-28 11:45:00 +10:30
Adrian Johnson
7feefc75f6 CFF subset: fix subsetting of Euro glyph
https://bugs.freedesktop.org/show_bug.cgi?id=31878
2010-11-28 03:46:10 +10:30
Adrian Johnson
f85af7fe8d Change fallback resolution test to use resolutions in multiples of 72
With integer aligned clipping the test output has no seams.
2010-11-28 03:39:05 +10:30
Adrian Johnson
126108a6ac Boilerplate: Set fallback resolution using force_fallbacks function
cairo_set_fallback_resolution() does not work when testing rgb24 surfaces
2010-11-28 03:38:42 +10:30
Adrian Johnson
59661f8af4 Fix fallback-resolution test
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
2010-11-28 03:38:29 +10:30