Commit graph

286 commits

Author SHA1 Message Date
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
Chris Wilson
d80f5580ef [pattern] Mark _cairo_pattern_nil as static
Fixes check-def.sh failure.
2009-06-28 21:11:41 +01:00
Chris Wilson
2b1ec7a4d8 [cairo] Report true error via pattern from cairo_pop_group()
Report the correct error via the returned pattern->status rather than
simply returning the NO_MEMORY nil object.
2009-06-27 22:48:19 +01:00
Chris Wilson
f388028333 [gstate] Avoid temporary allocation for transformed patterns
Observe that patterns are not altered during an operation and so we are
safe to use the data from the original pattern without copying. (This is
enforced through the declaration that the backends operate on constant
patterns which are not allowed to be referenced or destroyed.)
2009-06-27 20:18:18 +01:00
Chris Wilson
c12533b135 [pattern] Add _cairo_pattern_fini_snapshot
Symmetric operation to _cairo_pattern_init_snapshot() this exists simply
to break the circular reference between the meta-surface and snapshot-cow.
2009-06-19 00:29:00 +01:00
Chris Wilson
f4d9a4482f [pattern] Generalise the freed pattern pool
Also cache recently freed surface and gradient patterns. With thanks to
Jonathan Morton for the inspiration and initial pointer pool code for
pixman.
2009-06-05 07:32:07 +01:00
Chris Wilson
132f44dce1 valgrindify init/fini routines
Annotate object init/fini routines to detect use-after-free for
on-stack/embedded objects.
2009-06-04 14:17:43 +01:00
Chris Wilson
8e5295979f [pattern] Typo in document
Remove extraneous markup from program-listing.

https://bugs.freedesktop.org/show_bug.cgi?id=20441
2009-06-03 20:17:59 +01:00
Chris Wilson
51193f1610 [pattern] Pass flags to _cairo_pattern_acquire_surface()
Allow the caller to choose whether or not various conversions take place.
The first flag is used to disable the expansion of reflected patterns into a
repeating surface.
2009-06-02 15:13:45 +01:00
Chris Wilson
e05097c604 [surface] Assign a unique id to the surface.
Allocate an ever-increasing, non-zero, unique identifier to each surface.
True for the first 4-billion...
2009-06-01 18:04:14 +01:00
Chris Wilson
b7f199fde2 [pattern] Trim REPEAT source size when applicable.
Some backends are quite constrained with surface sizes and so trigger
fallbacks when asked to clone large images. To avoid this we attempt
to trim ROIs (as these are often limited to the destination image, and
so can be accommodated by the hardware). This patch allows trimming
REPEAT sources both horizontally and vertically independently.
2009-05-25 22:14:56 +01:00
Chris Wilson
31596cf2b2 [debug] Check image contents using memcheck.
As an aide to tracking down the source of uninitialised reads, run
VALGRIND_CHECK_MEM_IS_DEFINED() over the contents of image surfaces at the
boundary between backends, e.g. upon setting a glyph image or acquiring
a source image.
2009-05-15 21:31:03 +01:00
Chris Wilson
c25992479a [xlib] Use minimal depth for similar clones.
Damian Frank noted
[http://lists.cairographics.org/archives/cairo/2009-May/017095.html]
a performance problem with an older XServer with an
unaccelerated composite - similar problems will be seen with non-XRender
servers which will trigger extraneous fallbacks. The problem he found was
that painting an ARGB32 image onto an RGB24 destination window (using
SOURCE) was going via the RENDER protocol and not core. He was able to
demonstrate that this could be worked around by declaring the pixel data as
an RGB24 image. The issue is that the image is uploaded into a temporary
pixmap of matching depth (i.e. 32 bit for ARGB32 and 24 bit for RGB23
data), however the core protocol can only blit between Drawables of
matching depth - so without the work-around the Drawables are mismatched
and we either need to use RENDER or fallback.

This patch adds a content mask to _cairo_surface_clone_similar() to
provide the extra bit of information to the backends for when it is
possible for them to drop channels from the clone. This is used by the
xlib backend to only create a 24 bit source when blitting to a Window.
2009-05-15 21:31:02 +01:00
Chris Wilson
1ae2ddc1dd [memfault] Manually inject faults when using stack allocations
Ensure that no assumptions are made that a small allocation will succeed
by manually injecting faults when we may be simply allocating from an
embedded memory pool.

The main advantage in manual fault injection is improved code coverage -
from within the test suite most allocations are handled by the embedded
memory pools.
2009-04-23 09:22:51 +01:00
Chris Wilson
8bf109bd2a [pattern] Silence compiler with impossible case.
Assert that the pattern is one of the four known types, and return an
error so that the compiler knows that the local variable can not be used
uninitialised.
2009-04-20 10:21:23 +01:00
Chris Wilson
75b06b8bdb [pattern] Do not modify outparam on error path.
The pdf backend was crashing as a failed pattern copy stored an invalid
pointer with the resource group.
2009-04-16 09:34:02 +01:00
Chris Wilson
a4b44ca89e [pattern] Report the true error status from getters.
As the getters actually return an error status, use it to report any
pre-existing error status on the pattern.
2009-03-18 09:44:33 +00:00
Chris Wilson
d295942b9d Inline _cairo_restrict_value()
This is one instance where the function call overhead dominated the
function call in both time and size.
2009-02-13 13:26:52 +00:00
Behdad Esfahbod
730ed68ec1 [pattern] Fix comment typo 2008-12-25 23:29:02 -05:00
Chris Wilson
2d790daa95 [pattern] Use a solid pattern for a uniform gradient.
If each color stop in a gradient is identical, replace the gradient
surface with a simple solid surface. As seen in the wild.
2008-12-18 10:40:13 +00:00
Chris Wilson
1d68ee73f8 [pattern] Compute the combined color content.
When multiplying two colors together, the combined content is simply the
or of the their contents.
2008-12-12 13:21:11 +00:00
Chris Wilson
e6963a5bfe Mark allocation failures as unlikely.
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
2008-11-29 11:20:34 +00:00
Chris Wilson
d1801c23fa Mark if(status) as being unlikely.
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
2008-11-29 11:20:33 +00:00
Chris Wilson
b6c371a47f [pattern] Cosmetic.
surface is equal to pattern->surface at this point.
2008-11-19 11:59:21 +00:00
Chris Wilson
a856371bef Add CairoScript backend.
A new meta-surface backend for serialising drawing operations to a
CairoScript file. The principal use (as currently envisaged) is to provide
a round-trip testing mechanism for CairoScript - i.e. we can generate
script files for every test in the suite and check that we can replay them
with perfect fidelity. (Obviously this does not provide complete coverage
of CairoScript's syntax, but should give reasonable coverage over the
operators.)
2008-11-13 11:36:54 +00:00
Chris Wilson
b06c50cc54 [cairoint.h] Remove unused PLT entries.
Trim the slim_hidden_proto/def to match the currently used functions.
2008-11-13 11:36:43 +00:00