Commit graph

322 commits

Author SHA1 Message Date
Chris Wilson
2458120dee pattern: Add observer hooks
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>
2011-07-15 11:05:19 +01:00
Andrea Canciani
9374cf0a97 pattern: Implement _rgb functions as wrappers over _rgba functions
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.
2011-07-08 11:14:16 +02:00
Andrea Canciani
fe3ca9c36f Remove conditional compilation of freed-pools
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.
2011-07-05 10:00:13 +02:00
Andrea Canciani
ab8c108b88 Do not warn when ignoring the return value of _cairo_rectangle_intersect()
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.
2011-03-19 12:24:14 +01:00
Andrea Canciani
6521bab6e8 xcb,xlib: Fallback upon generic radial gradients
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.
2011-03-18 09:48:56 +01:00
Uli Schlachter
788bdec628 Fix errors from src/check-plt.sh
All of these symbols are used in cairo-script-surface.c for emitting mesh
patterns.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-12 21:12:46 +01:00
Andrea Canciani
5f039f0f89 mesh: Rename cairo_pattern_mesh_* functions to cairo_mesh_pattern_*
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>
2011-02-07 20:28:09 +01:00
Andrea Canciani
8c031c029d pdf,ps,quartz: Use correct tolerance for gradient domain computation
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.
2011-01-18 15:15:28 +01:00
Maarten Bosmans
a351807147 doc: Fix some broken references and gtk-doc warnings
The gtk-doc comments contain some typos and are missing some escaping.
2011-01-16 18:40:49 +01:00
Andrea Canciani
f0bb3a29b3 pattern: Remove unused _cairo_pattern_size function
'git log -S_cairo_pattern_size' only finds the commit
a856371bef, in which this function was
added, thus it looks like it has never been used.
2011-01-03 20:13:31 +01:00
Andrea Canciani
200e147322 pattern: Use double precision for gradient extreme objects
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
2011-01-02 18:33:14 +01:00
Andrea Canciani
38dce5d144 pattern: Factor out pattern rescaling
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
2011-01-02 18:32:13 +01:00
Andrea Canciani
51594d9787 matrix: Cairo matrix to pixman transform/offset conversion
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
2011-01-02 18:31:42 +01:00
Andrea Canciani
b4aa01f72f pattern: Make functions not used elsewhere static
_cairo_pattern_init_linear() and _cairo_pattern_init_radial() are only
called from within cairo-pattern.c
2011-01-02 18:31:25 +01:00
Andrea Canciani
b0aef7202d pattern: Use cairo_color_stop_t when hashing gradient stops
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.
2011-01-02 18:31:07 +01:00
Andrea Canciani
0501777598 pattern: Remove unused 'opaque' variable
opaque is never read, thus it can be removed.
2011-01-02 18:31:03 +01:00
Adrian Johnson
c243f3ac9c pattern: Add public mesh pattern API
Add public funcions to create and define mesh patterns and getters to
examine their definition.
2011-01-01 13:05:13 +01:00
Andrea Canciani
8df122cb4b Add mesh gradient rasterizer
Add an implementation of a fast and reasonably accurate
non-antialiased mesh gradient rasterizer.
2011-01-01 13:05:12 +01:00
Adrian Johnson
ed24deaa2e mesh: Add mesh pattern type and enum values
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.
2011-01-01 13:05:12 +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
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
ae2b7b13cd pattern: Simplify degenerate linear pattern to solid colors
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
2010-08-08 12:07:08 +02:00
Andrea Canciani
d54a5a9fc9 pattern: Add gradient degeneracy testing functions
Introduce two new (private) functions for testing the degeneracy of linear
and radial gradients and use them instead of verbose (and error-prone) tests.
2010-08-08 10:53:51 +02:00
Benjamin Otte
b870cc030d doc: Move tmpl/ docs to inline docs
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).
2010-07-08 14:27:16 +02:00
Chris Wilson
a049889c64 pattern: Remove incorrect optimisations from _cairo_pattern_aquire_surface()
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]
2010-06-11 21:26:26 +01:00
Chris Wilson
00bc1d1578 pattern: Remove extraordinary _cairo_pattern_fini_snapshot().
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.
2010-06-11 21:08:06 +01:00
Andrea Canciani
e2660a0eac pattern: improve single stop gradients handling
None-extended single stop gradients are now explicitly made clear.
2010-06-10 16:07:42 +02:00
Andrea Canciani
a0f8cfe646 pattern: improve degenerate gradients handling
Degenerate radial gradients are now considered clear.
2010-06-10 16:07:42 +02:00
Andrea Canciani
06c6207ad4 pattern: add gradient_is_solid function
It contains in a single place the logic needed to check if a gradient
pattern is solid (within a specified region).
2010-06-10 16:07:42 +02:00
Andrea Canciani
561625ee3b pattern: improve clear/opaque check functions
_cairo_pattern_is_opaque was missing some checks about the extend type.
Conversely _cairo_pattern_is_clear was being too strict about gradients.
2010-06-10 16:07:42 +02:00
Andrea Canciani
baaf312e04 pattern: remove content field from solid patterns
The content field in solid patterns had ill-defined semantic (or no
semantic at all), thus it can be removed.
2010-06-10 16:07:41 +02:00
Andrea Canciani
7461947eb1 surface: remove content argument from is_similar
The content argument was basically unuses.

Xlib change extracted from ickle's wip/compositor branch.
2010-06-10 16:07:41 +02:00
Chris Wilson
18b48a6ebc Make cairo_color_stop_t a unique type.
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.
2010-05-13 10:00:18 +01:00
Chris Wilson
dfa2544f15 color: Special case comparing color stops.
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.
2010-05-13 09:52:39 +01:00
Chris Wilson
a3cb52e403 simplify pattern extents for translation matrices 2010-05-12 20:54:48 +01:00
Chris Wilson
d45c7dc62d xcb: discard glyph mask and use dst directly when possible. 2010-05-12 20:54:48 +01:00
Chris Wilson
a505104013 image: Compute sample extents
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.
2010-04-27 11:07:45 +01:00
Benjamin Otte
2bffa2467e Use pixman_image_composite32()
Replace all occurences of pixman_image_composite()
2010-04-15 18:31:01 +02:00
Andrea Canciani
35f19bc084 pattern: Fix _gradient_is_opaque() for zero stops
_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>
2010-03-31 12:52:09 +02:00
Chris Wilson
1ecefc53a1 pattern: Zero-length gradients are not necessary empty
Fixes: test/linear-step-function

If the extend mode is unbounded, then the gradient is also unbound.
2010-02-02 16:31:36 +00:00
Chris Wilson
1236c41072 xcb: Refresh.
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.
2010-01-22 23:01:52 +00:00
Chris Wilson
4d52be39bf gstate: Skip ops with a clear mask.
As pointed out by Benjamin Otte, these are expensive no-ops that we can
trivially detect, just so long as we remember the semantics of extend
modes.
2010-01-22 23:01:52 +00:00
Chris Wilson
29bedde904 pattern: Add convenience patterns for stock colours
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.
2010-01-22 23:01:51 +00:00
Chris Wilson
3a5d71c431 pattern: An EXTEND_NONE surface is not opaque if we sample outside
Fixes test/clear-source as proposed by Benjamin Otte.
2010-01-22 23:01:51 +00:00
Chris Wilson
f2c32d0183 Unify the two freed object pools
Discard some duplicate code and shared a single freed object pointer
pool between the pattern and clip.
2010-01-22 23:01:50 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00