Cairo makes it possible to create gradients whose extreme objects are
defined with double precision coordinates, but it internally
represents them with 24.8 fixed point precision.
This shows that coordinates that don't fit the valid range are
mishandled and don't even trigger an error status.
The same code was duplicated (incorrectly and with some minor
differences) in pattern, image, xlib and xcb.
_cairo_gradient_pattern_max_val() abstracts that code in a function
that can be used whenever a gradients extremes need to be rescaled to
fit within a given range.
Fixes huge-linear, huge-radial.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
Cairo represents gradients coordinate with 24.8 fixed point precision,
but pixman uses 16.16 fixed point coordinates.
This shows that cairo is currently unable to handle gradients with
coordinates which are valid for cairo but not for pixman.
Xlib, XCB and image use the same code to convert a cairo_matrix_t to a
backend-specific transform.
The code did not handle correctly some matrices, thus a new function
that performs the conversion in a more generic way was added and used
in the backends instead of fixing the repeated code.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
The old radial gradient tests were actually drawing the same gradients
with different operators (OVER/SOURCE) and operations (paint/mask).
It is possible to refactor them to share the gradient construction
code. This makes it easy to change the gradient shape in all of them
to test more interesting combinations.
Instead of testing 16 generic positions we are now testing just 7
cases, which correspond to every possible combination of the relative
size and position of the two circles defining the gradient. In
particular we are now testing a constant radius gradient and gradients
with tangent circles.
Since 18b48a6ebc the color of each
gradient stop is stored in a cairo_color_stop_t, but
_cairo_gradient_color_stops_hash() was not updated accordingly.
mesh-pattern tests a mesh pattern with non-opaque two overlapping
patches.
mesh-pattern-accuracy tests the accuracy of the color computed in each
point of a patch. It can point out defects in rasterizers which rely
on mesh subdivision only use the mesh shape instead of both shape and
color to decide when the tensor-product patches can be approximated
with Gouraud-shaded triangles.
mesh-pattern-conical is an example of how a conical gradient can be
approximated with a mesh pattern.
mesh-pattern-control-points tests a mesh pattern with control points
in non-default position to verify that their position affects the
color as expected.
mesh-pattern-fold tests a mesh pattern with a patch which folds along
both sides.
mesh-pattern-overlap tests a mesh pattern with a patch which folds
along just one side.
mesh-pattern-transformed tests a mesh pattern with non-identity
transform matrix.
PS and PDF have native support for mesh patterns, but they have encode
mesh points and colors in an appropriate binary stream.
cairo_pdf_shading_* functions implement the encoding, which is the
same for PDF and PS.
Mesh gradients are constructed using multiple commands, bracketed by
explicit begin/end pairs. Using a mesh gradient inside a begin/end
pair is not allowed.
Add the mesh pattern type and an error status to be used to report an
incorrect construction of the pattern.
Update the backends to make them ready to handle the new pattern type,
even if it cannot be created yet.
README indicates MacOSX 10.4 as a requirement for quartz and we are
directly using some functions that have been added to the public
CoreGraphics API in 10.4.
rop 10.3-specific workarounds and link to 10.4 API functions instead
of loading them at runtime.
Flushing a surface can attach snapshots to it, thus we have to detach
the snapshots after the flush, to make sure they aren't leaked.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Finished surfaces should own no snapshots, because finished surfaces
can't be used as sources, thus their snapshots would never be used.
When free'ing the surface in cairo_surface_destroy(), it should have
no snapshots, or they will be leaked.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Clear surfaces with an alpha channel are already replaced with a
transparent color in gstate, so this code was never hit.
Clear surfaces without an alpha channel, can be replaced with solid
black only if the surface pattern has an extend other than
CAIRO_EXTEND_NONE.
Fixes the clear-source test for xcb.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Andrea Canciani <ranma42@gmail.com>
The X server calculates the bounding box for traps and then allocates
a temporary picture for this. When the X server calculates different
values than cairo got in extents->bounded, unbounded operators will
have wrong results. The X server only ever calculates bounds that are
larger than the correct values.
Fix this by explicitly clipping the drawing to the expected bounds.
Fixes clip-fill-{eo,nz}-unbounded and clip-stroke-unbounded.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Andrea Canciani <ranma42@gmail.com>
When a drawing operator doesn't actually have any effect, we don't have to set
the surface's is_clear flag to FALSE.
Signed-off-by: Uli Schlachter <psychon@znc.in>
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.
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>
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
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.
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>
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>
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>
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>
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>
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>
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>