Commit graph

311 commits

Author SHA1 Message Date
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
Chris Wilson
4e315d8472 pattern: Premultiply color-stop when converting to solid
Fixes: test/linear-uniform
       https://bugzilla.mozilla.org/show_bug.cgi?id=539165
       Bug 539165 - gradients with a single stop do not have their color
                    multiplied by the alpha.

As reported by Jeff Muizelaar, we regressed in 2d790daa as the
color-stops are not premultiplied and so could not be treated as an
ordinary cairo_color_t. Instead we have to create a intermediate
cairo_color_t from the original values in order for the
premultiplication to be performed.
2010-01-15 12:25:53 +00:00
Chris Wilson
c701d7813b [pattern] Compute zero extents for empty patterns
If the pattern is for example a repeating 0x0 image, then treat it as
having zero extents.

This should workaround the bug presented here:

  https://bugs.freedesktop.org/show_bug.cgi?id=24693
  Attached PDF crashes evince with a Floating point exception
2009-10-23 14:58:33 +01:00
M Joonas Pihlaja
43a775f60d [meta] Rename cairo_meta_surface_t to cairo_recording_surface_t.
The new name is more descriptive than the rather opaque meta surface.
Discussed with vigour on the mailing list and #cairo:

http://lists.cairographics.org/archives/cairo/2009-July/017571.html
2009-10-22 02:29:47 +03:00
Chris Wilson
df357f26ff Support component-alpha.
Within our code base we carried a few hacks to utilize the component
alpha capabilities of pixman, whilst not supporting the concept for our
own masks. Thus we were setting it upon the pixman_image_t that we
passed around through code that was blissfully unaware and indeed the
component-alpha property was forgotten (e.g. upgrading glyph masks).

The real issue is that without explicit support that a pattern carries
subpixel masking information, that information is lost when using that
pattern with composite. Again we can look at the example of compositing
a sub-pixel glyph mask onto a remote xlib surface for further failure.
2009-10-21 11:37:16 +01:00
Chris Wilson
54df07a3da [surface] Don't AND in the desired content.
Gah, that was a horrible mistake. It was a flawed hack to create Pixmaps
of the correct depth when cloning patterns for blitting to the xlib
backend. However, it had the nasty side-effect of discarding alpha when
targeting Window surfaces. The correct solution is to simply correct the
Pixmap of the desired depth and render a matching pattern onto the
surface - i.e. a reversal the current acquire -> clone. See the
forthcoming revised xcb backend on how I should have done it originally.
2009-10-16 17:04:16 +01:00
Chris Wilson
d85eda97dd [pattern] Compute extents for gradients
As noted in the comments we could also compute the pattern extents for
gradients with CAIRO_EXTEND_NONE under certain circumstances, i.e.
radial gradients and device axis aligned linear gradients.
2009-10-15 13:05:42 +01:00
Chris Wilson
af82670dd3 [pattern] Remove unused hidden symbol for cairo_pattern_status() 2009-09-01 13:31:52 +01:00
Chris Wilson
d1740d8782 [pattern] Ensure that no repeated pattern is clipped
Previously the pattern_acquire_surface routine only had to worry about
handling extend modes NONE or REPEAT and so the test for ! REPEAT
sufficed when what was actually intended was a test for NONE.
2009-08-29 17:07:37 +01:00
Chris Wilson
005b195f06 [pattern] Ignore matrix/filter/extend when comparing solids
Solid patterns do not use their matrices, filter or extend properties so
ignore them for the purposes of comparing and hashing.
2009-08-29 08:08:34 +01:00
Chris Wilson
1327df2cf2 [pattern] Invalid access beyond end of freed-pool
Oops, we were attempting to return a pointer from beyond the end of our
array.
2009-08-06 10:16:45 +01:00
Chris Wilson
bed2701e1c Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)

In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.

Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:

ppc:
Speedups
========
image-rgba         evolution-20090607-0    1026085.22 0.18% -> 672972.07 0.77%:  1.52x speedup
▌
image-rgba         evolution-20090618-0    680579.98 0.12% -> 573237.66  0.16%:  1.19x speedup
▎
image-rgba      swfdec-fill-rate-4xaa-0    460296.92 0.36% -> 407464.63  0.42%:  1.13x speedup
▏
image-rgba      swfdec-fill-rate-2xaa-0    128431.95 0.47% -> 115051.86  0.42%:  1.12x speedup
▏
Slowdowns
=========
image-rgba     firefox-periodic-table-0    56837.61 0.78% -> 66055.17    3.20%:  1.09x slowdown
▏
2009-07-23 15:32:14 +01:00