Commit graph

4218 commits

Author SHA1 Message Date
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
Chris Wilson
d6f6ec9082 [ft] Restore the ability to lazily resolve patterns.
I broke the ability for the ft font backend to resolve patterns whilst
fixing the font creation to propagate the error status from fontconfig
(be27e8). By adjusting the sequence of error checks we do not confuse
the absence of a match with a fatal error and thereby restoring the
lazy pattern resolution whilst ensuring error propagation.
2009-05-15 21:31:01 +01:00
Jeff Muizelaar
a352fd4602 Only include <strings.h> for ffs() when we HAVE_FFS
This fixes breakage caused by 3d3d10a31e
2009-05-15 15:34:05 -04:00
Chris Wilson
d8fb6a03d3 [path] Define _BSD_SOURCE to enable hypot()
hypot() is only declared for BSD/SVID/XOPEN/C99 sources. Choose BSD as
we've used that elsewhere.
2009-05-08 08:53:51 +01:00
Chris Wilson
3d3d10a31e [skiplist] Missing include for ffs() 2009-05-08 08:52:27 +01:00
Chris Wilson
e5752865ab [cairo] Protect typeof against -ansi
s/typeof/__typeof__/ to allow the [gcc-specific] macro to continue to work
despite -ansi.
2009-05-08 08:52:19 +01:00
Chris Wilson
5f4f2ab01a [cairo] Remove stray semi-colon
Pedantic finds another victim.
2009-05-08 08:52:13 +01:00
Chris Wilson
d86ad461cf [cairo] Convert C99 comments to /* ... */
First victim of -pedantic...
2009-05-08 08:51:54 +01:00
Chris Wilson
695f648607 [cairo] Fix errors reported by check-doc
Identity a few new instances of CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED in
comments with %.
2009-05-07 15:14:14 +01:00
Chris Wilson
849bdee199 [check] Quieten output during checking headers-standalone
Remove the duplication of the compile line and enable shave to replace it
entirely with a "CHECK $header". This should make errors more obvious.
2009-05-07 15:14:14 +01:00
Behdad Esfahbod
428fb58a4c [user-font] Add CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
This is useful for language bindings to signal that a method is not
implemented.
2009-05-06 20:31:04 -04:00
Behdad Esfahbod
f9573d03dd Err, make gtk-doc happy again 2009-05-06 20:31:04 -04:00
Chris Wilson
30735f790a [xlib] Use a similar content surface for cloning images
Simply request a surface with a similar content to the source image when
uploading pixel data. Failing to do so prevents using a 16-bit (or
otherwise non-standard pixman image format) window as a source - in fact
it will trigger an infinite recursion.
2009-05-05 21:38:18 +01:00
Chris Wilson
60e38d0530 [surface] Convert FORMAT_INVALID during snapshots
Currently the surface snapshotting attempts to clone the source using a
new surface of identical format. This will raise an error if the source is
an unusual xserver, for example one operating at 16bpp. The solution to
this is to create the surface using the content type rather than the
format (as elsewhere within the code base). However, we also wish to
preserve FORMAT_A1 (which is lost if we only choose the format based on
_cairo_format_from_content) as the various backends may be able to
trivially special case such bitmaps.
2009-05-05 21:21:28 +01:00
Chris Wilson
31f5a2e94d [png] Coerce FORMAT_INVALID to a known image format
It is possible for cairo_surface_write_to_png() to acquire a non-standard
image surface when, for example, we try to dump a low bit-depth XServer.
Handle this scenario by coercing the unknown image format to a standard
type via pixman.
2009-05-05 21:21:24 +01:00
Chris Wilson
c488b33644 [test] Create a new fallback surface to exercise 16-bit paths.
Add a variation of test-fallback-surface that forces the use of a 16-bit
pixman format code instead of the standard 32-bit types. This creates an
image surface akin to the fallbacks used with low bit-depth xservers.
2009-05-05 21:17:11 +01:00
Chris Wilson
1d609d6722 [image] Treat A1 image surfaces as BILEVEL_ALPHA
Categorise the transparency of FORMAT_A1 image surfaces as BILEVEL_ALPHA.
2009-05-05 21:17:05 +01:00
Chris Wilson
aac132a76a [image] Make _cairo_image_analayze_transparency() more format agnostic
Use the content in preference to the format to determine
CAIRO_IMAGE_IS_OPAQUE/CAIRO_IMAGE_HAS_ALPHA.
2009-05-05 21:17:05 +01:00
Chris Wilson
4be6de9fc6 [image] Return FORMAT_INVALID for an error surface.
The default error value should be CAIRO_FORMAT_INVALID [-1] not 0 (which
corresponds to CAIRO_FORMAT_ARGB32).
2009-05-05 21:17:05 +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
be27e844c8 [ft] Propagate status from font creation
Return the true error status whel
_cairo_ft_unscaled_font_create_internal(). This ensures that the original
error is not masked and we are able to report the error during fontconfig
pattern resolution.
2009-04-20 10:21:24 +01:00
Chris Wilson
d46c56f18c [ft] Check for pattern duplication failure.
Check the return of FcPatternDuplicate() for failure, and propagate the
error.
2009-04-20 10:21:23 +01:00
Chris Wilson
50302f156d [ft] Check (correctly!) for pattern duplication failure.
Check the return from FcPatternDuplicate() for allocation failure (and not
the original pattern)!
2009-04-20 10:21:23 +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
5a76c233bf [type3] Propagate error from font creation.
Perform an error check after creating a scaled-font to prevent operations
on a nil-object.
2009-04-16 09:34:03 +01:00
Chris Wilson
d46bd67c8b [type3] Add status checks.
Propagate error from the stream when creating the surface and add status
guards before writing to the potential nil object.
2009-04-16 09:34:03 +01:00
Chris Wilson
a6ffb69a54 [type3] Check error status before emit_image().
Be careful not to pass an error object down to emit_image() hook,
propagate the error instead. This relieves the burden of the error check
from the callee -- which was causing an assertion failure in the ps
backend.
2009-04-16 09:34:03 +01:00