Commit graph

4244 commits

Author SHA1 Message Date
Chris Wilson
24e51dd2ee [atomic] Hide compiler warnings
Add uint variants of _cairo_atomic_int_*() to hide the compiler warnings
about sign conversions.
2009-06-05 18:35:52 +01:00
Chris Wilson
4ae5e2d445 [atomic] Provide mutex-based ptr cmpxchg
To handle those CPUs where we do not have an atomic cmpxchg.
2009-06-05 18:29:40 +01:00
Thomas Jaeger
a1d0a06b62 xlib, xcb: Hand off EXTEND_PAD/EXTEND_REFLECT to Render
Most drivers and the X server used to have incorrect RepeatPad/RepeatReflect
implementations, forcing cairo to fall back to client-side software rendering,
which is painfully slow due to pixmaps being transfered over the wire.  These
issues are mostly fixed in the drivers (with the exception of radeonhd, whose
developers didn't respond) and the RepeatPad software fallback is implemented
correctly as of pixman-0.15.0, so this patch will hand off composite operations
with EXTEND_PAD/EXTEND_REFLECT source patterns to XRender.

There is no way to detect whether the X server or the drivers use a
broken Render implementation, we make a guess based on the server
version:  It's probably safe to assume that 1.7 X servers will use
fixed drivers and a recent enough version of pixman.
2009-06-05 17:26:09 +01:00
Chris Wilson
9d7a7e76b8 [scaled-font] Close race from 16d128
Whilst waiting for the fontmap lock on destruction another thread may not
only have resurrected the font but also destroyed it acquired the lock
first and inserted into the holdovers before the first thread resumes. So
check that the font is not already in the holdovers array before
inserting.
2009-06-05 07:32:44 +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
e89828c533 [freelist] valgrindify freed blocks
Mark freed blocks as unaccessible upon free() and then as undefined
on alloc().
2009-06-04 12:50:39 +01:00
Chris Wilson
1b92ea250f [ft] Don't call FT_Done_Face() on a face we do not own
_font_map_release_face_lock_held() was being called unconditionally during
_cairo_ft_font_reset_static_data(). This presents two problems. The first
is that we call FT_Done_Face() on an object not owned by cairo, and the
second is that the bookkeeping is then incorrect which will trigger an
assert later.
2009-06-03 20:34:01 +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
c988dc3719 [cairo] Doc typo.
Fix conflicting sentence as pointed out by
https://bugs.freedesktop.org/show_bug.cgi?id=20183
2009-06-03 10:51:23 +01:00
Chris Wilson
35d0dd00c9 [image] Doc typo.
Correct parameter reference as pointed out by
https://bugs.freedesktop.org/show_bug.cgi?id=20182
2009-06-03 10:49:16 +01:00
Chris Wilson
58459ac643 [font-options] Doc typo
Remove duplicate 'with' as pointed out by
https://bugs.freedesktop.org/show_bug.cgi?id=20180
2009-06-03 10:45:51 +01:00
Chris Wilson
8d39dee8e2 [cairo] Update documentation for bug 20154
Several typographical errors were pointed out in
https://bugs.freedesktop.org/show_bug.cgi?id=20154
2009-06-03 10:40:38 +01:00
Chris Wilson
73469e693c [cairo] Tweak error strings.
Rewrite a few error strings so that they more closer match the
documentation. Where they differ, I believe I have chosen the more
informative combination of the two texts.
2009-06-03 09:51:52 +01:00
Chris Wilson
c9cd2f9ca1 [cairo] PLT symbols for cairo_set_source_rgb
Added a private use in user-font, but forgot to add a hidden symbol.
2009-06-02 18:47:07 +01:00
Chris Wilson
21550a7530 [user-font] Set the initial colour to white
An issue occured when using subpixel antialiasing with user-fonts and
XRender - the glyphs were transparent, as demonstrated by the font-view
example.

The problem lies in that enabling subpixel antialiasing triggers use of an
ARGB32 image surface for rendering the glyph, but the default colour is
black (so the only information is in the alpha-channel). Given an ARGB32
glyph XRender treats it as a per-channel mask, but since the R,G,B
channels were uniformly zero, the glyph is rendered as transparent.

Fix this by setting the initial colour to white before rendering the image
surface for a user-font glyph, which generates the appropiate gray-level
mask by default.
2009-06-02 18:16:52 +01:00
Chris Wilson
b5799e073e [xlib] Use bswap_32
Byteswap the ARGB32 glyphs using bswap_32 instead of open-coding.
2009-06-02 18:16:52 +01:00
Adrian Johnson
c9ddaf8e7f PDF: Don't embed the same pattern more than once
The PDF surface now keeps track of all the patterns it is embedding in
a hash table keyed by the unique_id returned by the
_cairo_surface_get_unique_id().
2009-06-02 15:13:48 +01:00
Paolo Bonzini
f7613eeece Add more surface snapshots providers
This patch adds more implementation of the snapshot method.  For
surface types where acquire_source_image is already making a copy
of the bits, doing another one as is the case for the fallback
implementation is a waste.
2009-06-02 15:13:48 +01:00
Chris Wilson
cffb398f5a Add a generic cow-snapshotting framework
Provide a mechanism for backends to attach and remove snapshots. This can
be used by backends to provide a cache for _cairo_surface_clone_similar(),
or by the meta-surfaces to only emit a single pattern for each unique
snapshot.

In order to prevent stale data being returned upon a snapshot operation,
if the surface is modified (via the 5 high level operations, and on
notification of external modification) we break the association with any
current snapshot of the surface and thus preserve the current data for
their use.
2009-06-02 15:13:47 +01:00
Chris Wilson
b7c03d4e40 [ps] Trivial warning fix. 2009-06-02 15:13:46 +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
4ec451a2fa [scaled-font] Cache repeated glyphs during probing device_extents
Maintain a local on-stack cache of recently queried glyphs to avoid
relatively expensive hash table queries.
2009-06-02 15:13:45 +01:00
Chris Wilson
ec22ae5b1d [scaled-font] Compare most recently used font directly
Avoid the relatively expensive _cairo_scaled_font_init_key() operation
when checking against the most recently used font.
2009-06-02 15:13:45 +01:00
Chris Wilson
16d128c15e [scaled-font] Lazily acquire the font_map_lock on font destruction.
We can defer taking the cairo_scaled_font_map_lock until we drop the
last reference to the scaled font so long as we double check the reference
count after waiting for the lock and not making assumptions about
unreferenced fonts during construction. This is significant as even
acquiring the uncontended cairo_scaled_font_map_lock during
cairo_scaled_font_destroy() was showing up as a couple of percent on text
heavy profiles (e.g. gnome-terminal).
2009-06-02 15:13:44 +01:00
Chris Wilson
dc083ab30a [cairo] Track the MRU scaled font
When observing applications two patterns emerge. The first is due to
Pango, which wraps each glyph run within a context save/restore. This
causes the scaled font to be evicted after every run and reloaded on the
next. This is caught by the MRU slot on the cairo_scaled_font_map and
prevents a relatively costly traversal of the hash table and holdovers.

The second pattern is by applications that directly manage the rendering
of their own glyphs. The prime example of this is gnome-terminal/vte. Here
the application frequently alternates between a few scaled fonts - which
requires a hash table retrieval every time.

By introducing a MRU slot on the gstate we are able to directly recover
the scaled font around 90% of the time.

Of 110,000 set-scaled-fonts:
  4,000 were setting the current font
 96,000 were setting to the previous font
  2,500 were recovered from the MRU on the cairo_scaled_font_map
  7,500 needed a hash retrieval
which compares to ~106,000 hash lookups without the additional MRU slot on
the gstate.

This translates to an elapsed time saving of ~5% when replaying a
gnome-terminal trace using the drm backend.
2009-06-02 15:13:44 +01:00
Chris Wilson
fda89c56ff Markup a few more functions as const/pure 2009-06-02 15:13:44 +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
45835f623f [cache] Expose init/fini methods so that caches can be embedded.
The structure is already exposed, so just expose the
constructors/destructors in order to enable caches to be embedded and
remove a superfluous malloc.
2009-06-01 18:04:14 +01:00
Chris Wilson
c3aac9cf49 [image] Eliminate trapezoid array allocation
By simply iterating over the array cairo_trapezoid_t, converting each one
separately to a pixman_trapezoid_t and rasterizing each one individually
we can avoid the common heap allocation. pixman performs exactly the same
iteration internally so there is no efficiency loss.
2009-06-01 18:04:13 +01:00
Chris Wilson
7b2bc44138 [surface-fallback] Tidy pattern handling.
Make the treatment of replacing the NULL source pattern with WHITE
consistent. As it is a solid pattern, we can skip _cairo_pattern_fini()
and so make the code more readable, and consistent along the error paths.
2009-06-01 18:04:13 +01:00
Chris Wilson
e83e113eae [surface] Speed up cairo_surface_get_mime_data().
The number of mime-types attached to a surface is usually small,
typically zero. Therefore it is quicker to do a strcmp() against
each key in the private mime-data array than it is to intern the
string (i.e. compute a hash, search the hash table, and do a final
strcmp).
2009-06-01 18:04:13 +01:00
Chris Wilson
c5e85835b2 [debug] Relax ASSERT_NOT_REACHED
Need to actually handle random pixman image formats...
For the time being, ignore them.
2009-06-01 18:04:12 +01:00
Behdad Esfahbod
4232719af9 [ft] Fix vertical advance metrics of bitmap fonts (#21985) 2009-05-30 23:03:55 -04:00
Adrian Johnson
4314cae874 Fix typo in comment 2009-05-27 17:56:05 +09:30
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
d840deb57b [in-fill] Fix typo in on-vertex test.
Eeek! Comparing point->y against in_fill->x is a bad idea.
2009-05-25 22:14:56 +01:00
Chris Wilson
b71b019fe5 [in-fill] Treat on-edge queries as inside.
Jeff Muizelaar noted that the treatment of edges differed with firefox's
canvas definition, which considers a point on any edge as inside. The
current implementation has a similar definition to that of flash, for
which the top and right edges are outside. Arguably, firefox has the more
intuitive definition here...
2009-05-22 16:55:30 +01:00
Chris Wilson
efd0f0b292 [xlib] Handle too-large images gracefully.
Trigger a fallback to an image surface for massive patterns.
2009-05-22 16:41:58 +01:00
Chris Wilson
3c6838532a [surface] Early return if the backend cannot clone an image
If the backend cannot create a similar surface to hold the image, then
report back the failure before embarking upon an infinite recursion.
The UNSUPPORTED return should percolate up through the call stack and
trigger a fallback.
2009-05-22 16:41:57 +01:00
Chris Wilson
bf2c7356d4 [surface] Provide nil-surface for INVALID_SIZE
So that we can faithfully report back failure if the user tries to create
a surface larger than the backend can support.
2009-05-22 16:41:57 +01:00
Chris Wilson
6717f0d748 [win32] Wrap win32-font usage with CAIRO_HAS_WIN32_FONT
Bug 19251: --enable-win32=yes and --enable-win32-font=no causes
compilation failure
[https://bugs.freedesktop.org/show_bug.cgi?id=19251]

Wrap use of the win32 font backend within win32-printing-surface within
CAIRO_HAS_WIN32_FONT ifdefs to prevent compilation failure if the user
explicitly disables the win32 font backend.
2009-05-22 16:41:57 +01:00
Chris Wilson
c7d2b0de83 [win32] Typo
Correct function name in error string.
2009-05-22 16:41:57 +01:00
Adrian Johnson
6e87e354e4 Correct the comment for the index_to_ucs4 font backend function 2009-05-17 18:14:28 +09:30
Adrian Johnson
2a34992ccc Ensure win32 font index_to_ucs4() sets ucs4 to -1 if lookup fails 2009-05-17 18:12:39 +09:30
Adrian Johnson
4c8e5485a1 Fix win32 build breakage
that was caused by c25992479a
2009-05-17 18:05:42 +09:30
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
791a6fa399 [memfault] Update macros to avoid namescape collision with memcheck
Basing the macro names of the memfault skin lead to a namespace
collision with memcheck. After updating the headers, update cairo's usage
to match.
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
Karl Tomlinson
0238fe2caf [ft] Resolve mutual referencing problems with zombie faces
Bug 21706 -- zombie ft_font_face / ft_unscaled_font mutual
             referencing problems
[http://bugs.freedesktop.org/show_bug.cgi?id=21706]

There can be more than one zombie font_face belonging to an unscaled_font,
but only the first is destroyed.  This leaks the client's FT_Face
(and associated font data) as release of the FT_Face depends on release
of the font_face.

(The reason why Firefox ends up with two different font_faces for one
unscaled_font is that load_flags for faces with artificial oblique have
FT_LOAD_NO_BITMAP set.
https://bugzilla.mozilla.org/show_bug.cgi?id=486974)

Also it's possible for _cairo_ft_font_face_create to pull out a zombie
font_face from the unscaled_font, which would crash
_cairo_ft_font_face_scaled_font_create, as that expects non-null
font_face->unscaled (if !font-face->pattern).
2009-05-15 21:31:02 +01:00