In order for custom context to automatically track when a pattern is
modify after being set on the context (and before it is used in an
operator), we need for there to be a callback when the pattern is
modified.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
cairo_pattern_create_rgb() and cairo_pattern_add_color_stop_rgb()
implement the same logic as cairo_pattern_create_rgba() and
cairo_pattern_add_color_stop_rgba() with an alpha == 1.0.
Instead of duplicating the code, they can simply call into the more
general functions.
Conditional compilation was needed to avoid warnings:
cairo-clip.c:51: warning: ‘clip_path_pool’ defined but not used
cairo.c:181: warning: ‘context_pool’ defined but not used
They can be avoided by making sure that _freed_pool_reset(ptr)
actually consumes its argument. This has the pleasant side-effect that
forgetting to properly reset a freed-pool now results in a warning if
atomic ops are disabled/not available.
gcc complains that
cairo-surface-wrapper.c:647: warning: ignoring return value of
‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result
It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
The RENDER specification requires radial gradients to have the first
circle completely inside the second one, but the error is not actually
generated.
The implementation produces the expected results if either circle
contains the other one, so only fall back in these cases.
This is consistent with the naming of most cairo types/functions
(example: cairo_foo_surface_*).
The substitution in the code has been performed using:
sed -i 's/cairo_pattern_mesh_/cairo_mesh_pattern_/' <files>
The tolerance argument of _cairo_gradient_pattern_box_to_parameter ()
is in pattern space, so to have it constant in device space, it should
depend on the pattern matrix.
In ps and pdf the fallback resolution alone is not meaningful. The
resolution/fallback_resolution ratio should be used instead.
Using double precision for gradient extreme objects ensures that they
are preserved as specified when constructing the gradient pattern.
Fixes huge-linear, huge-radial.
Fixes part of https://bugs.freedesktop.org/show_bug.cgi?id=32215
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
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
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.
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.
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>
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>
Degenerate linear patterns are considered clear if they have
EXTEND_NONE, the average of the first and the last stop if they are
EXTEND_PAD, the weighted average of the stops (based on the size of
the interpolation range in which they are active, just like integrating
over the whole interpolation range and taking the average) if they are
EXTEND_REPEAT or EXTEND_REFLECT.
Fixes degenerate-linear-gradient
Introduce two new (private) functions for testing the degeneracy of linear
and radial gradients and use them instead of verbose (and error-prone) tests.
I did this manually so I could review the docs at the same time.
If anyone finds typos or other mistakes I did, please complain to me (or
better: fix them).
Safe reduction of patterns is performed in gstate, so not only are the
extra checks in _cairo_pattern_acquire_surface redundant there are also
unsafe. Simply remove them.
Fixes test/radial-gradient-extend [xlib-fallback]
Miraculously the circular references from self-copy have disappeared and
the forced finish within _cairo_pattern_fini_snapshot() now quite
explosive. By replacing them with an ordinary _cairo_pattern_fini() the
crash from test/smask-image-mask disappear along and valgrind remains
happy.
Fixes test/smask-image-mask and similar.
Hopefully reduce the occurrence of the confusion between the
premultiplied shorts in cairo_color_t and the non-premultiplied shorts
in cairo_color_stop_t.
The existence of the two separate types is debatable and open for
review.
color stops are not premultiplied so we need to handle them carefully
when comparing. The next step will be to make cairo_color_stop_t a
unique type to prevent this mistake again.
In order to reuse the original image as the pixman pattern, then the
entire operation must be wholly contained within the extents of the
image (including subsurfaces) and be reducible to an untransformed
REPEAT_NONE.
_gradient_is_opaque() previously returned TRUE for gradient with
no stops, triggering a false optimization in _cairo_gstate_mask().
Fixes test/gradient-zero-stops-mask
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Still an experimental backend, it's now a little too late to stabilise
for 1.10, but this should represent a major step forward in its feature
set and an attempt to catch up with all the bug fixes that have been
performed on xlib. Notably not tested yet (and expected to be broken)
are mixed-endian connections and low bitdepth servers (the dithering
support has not been copied over for instance). However, it seems robust
enough for daily use...
Of particular note in this update is that the xcb surface is now capable
of subverting the xlib surface through the ./configure --enable-xlib-xcb
option. This replaces the xlib surface with a proxy that forwards all
operations to an equivalent xcb surface whilst preserving the cairo-xlib
API that is required for compatibility with the existing applications,
for instance GTK+ and Mozilla. Also you can experiment with enabling a
DRM bypass, though you need to be extremely foolhardy to do so.
By preallocating in our data segment a couple of solid patterns for the
stock colours, it becomes more convenient when using those in surface
operations, such as when clearing.