Commit graph

199 commits

Author SHA1 Message Date
Behdad Esfahbod
333a49d01d [cairo-pattern] Don't call _cairo_stock_color() directly 2008-06-19 19:18:57 -04:00
Behdad Esfahbod
4eae72317f [cairo-pattern] Remove stale comment 2008-06-19 19:08:50 -04:00
Behdad Esfahbod
52cf67a8f2 Rename cairo_* global vars to _cairo_* 2008-06-19 17:44:43 -04:00
Behdad Esfahbod
aef25b8345 [cairo-pattern] Fix solid surface cache to check for content match too
The code in that cache is becoming uglier and uglier.  But at least it
works correctly again.  Time for a rewrite.

(Also move the destroy after unlocking)
2008-06-19 17:31:10 -04:00
Chris Wilson
565644e616 [cairo-pattern] Band-aid for the solid surface cache.
Behdad noticed that the mixing of dissimilar surfaces within the cache
was fubar
(http://lists.cairographics.org/archives/cairo/2008-June/014348.html).

This corrects the dereferencing of the evicted surface, but leaves open
the question of the future of the cache.
2008-06-19 12:29:49 +01:00
Chris Wilson
b235050316 [cairo-pattern] Generate an opaque solid colour if alpha >= 1.
If the user supplies an alpha value of >= 1 to
cairo_pattern_create_rgba(), substitute a call to
cairo_pattern_create_rgb() instead.
2008-06-13 21:37:57 +01:00
Chris Wilson
40e1aa60f2 [cairo-pattern] Try to repaint the evicted surface from the solid surface cache.
Behdad Esfahbod complained that commit
8457374c9c overwhelmed the function with
added complexity and arbitrary limited a backend to one-quarter of the
cache. The elegant solution, he outlined, was to look at the surface that
would be evicted and if possible repaint it, instead of creating a
replacement. This not only simplifies the code, reduces the number of
checks performed to find a match (or victim) and allows the cache to be
naturally shared between the various backends.
2008-06-13 21:37:57 +01:00
Behdad Esfahbod
3f02e0d74b Fix newly detected doc syntax issues 2008-06-01 18:46:45 -04:00
Jeff Muizelaar
9cc147a142 Avoid deadlock when clearing caches
cairo_surface_destroy and _cairo_scaled_font_fini will call destroy closures
which may call functions that attempt to acquire the mutex resulting in a
deadlock. We fix this by releasing the lock for the call to
cairo_surface_destroy or _cairo_scaled_font_fini.
2008-05-24 20:18:43 -04:00
Carl Worth
1ccfc4afd5 Revert "BUGGY: Add surface_backend->acquire_source_image_transformed"
This reverts commit ddcd6781a2.

This was an experimental commit that was intended to be on a side
branch but accidentally got committed and pushed to master. Sorry
for the noise.
2008-05-23 08:14:00 -07:00
Carl Worth
ddcd6781a2 BUGGY: Add surface_backend->acquire_source_image_transformed
This is an initial attempt at addressing the recently noticed
fallback-resolution bug. It isn't working correctly yet.

I'm just committing so that behdad can see what I'm up to.
2008-05-21 12:06:37 -07:00
Behdad Esfahbod
2321b91cba [cairo-pattern] Make a free() call conditional
to emphasize that the pointer may be NULL
2008-05-15 16:38:56 -04:00
Behdad Esfahbod
ee3672efdb [cairo-pattern] Extend infinite pattern extents to negative coordinates too
With things like meta-surface, the assumption that coordinates are always
non-negative make no sense.  Extend the "infinite" extents accordingly.

Also remove stale comment.  extents->width/height are unsigned these days and
cover the full range.
2008-05-09 15:54:12 +02:00
Chris Wilson
8457374c9c [cairo-pattern] Repaint existing cached similar solid surfaces.
The current solid surface cache returns an existing similar surface only
if it is an exact match for the desired colour.  This gives a high hit
rate for the original goal of drawing text, but fails when using a lot
of colours - for example drawing a pie-chart, the mosaic perf case, or
browsing the web.  So instead of creating a new surface from scratch we
can repaint an existing one, providing that we have sufficient surfaces
already cached, i.e. if we are going to evict a surface, we may as well
just repaint it.
2008-05-06 14:31:32 +01:00
Carl Worth
36246c51ba Revert "_cairo_pattern_get_extents: Fix to allow for expansion based on filter"
This reverts commit 731e121c80.

This commit introduced various problems, (some likely noticeable
in the test suite, and others perhaps not). For some details, see
the latest comments in the original bug report leading to the
fix now being reverted:

	http://bugs.freedesktop.org/show_bug.cgi?id=15349
2008-04-07 16:09:06 -07:00
Carl Worth
d1fe008440 Document default extend modes 2008-04-06 02:17:09 -07:00
Carl Worth
731e121c80 _cairo_pattern_get_extents: Fix to allow for expansion based on filter
This fixes the filter-bilinear-extents test case and the
related bug entry:

	bad clipping with EXTEND_NONE
	http://bugs.freedesktop.org/show_bug.cgi?id=15349

Though there are still differences in the PDF and PostScript
backends, (primarily because we can't capture cairo's filter
modes in those file formats).
2008-04-04 19:00:28 -07:00
Carl Worth
04608952e2 Replace open-coded transformation with a call to _cairo_matrix_transform_bounding_box
It's a wonderful feeiling to remove duplicate code.
2008-04-04 18:56:38 -07:00
Carl Worth
75972167a2 Use floating-point offsets for color stops
Previously we were using the cairo_fixed_t type which meant we've
historically only been using 16 bits of precision for these offsets,
and recently only 8 bits. Meanwhile, all manipulatons of offsets
have been in floating-point anyway, so we might as well store them
that way.

This change also prevents a rendering regression introduced with the
24.8->16.16 change betwen snapshots 1.5.10 and 1.5.12 .

This change affected gradient-rendering details for the clip-operator
and operator-source tests, so the corresponding reference images are
updated here.
2008-03-26 14:52:09 -07:00
Chris Wilson
1dd894115e [cairo-pattern] Raise an error for _cairo_pattern_create_solid() failure.
Add a missing _cairo_error() for the malloc failure in
_cairo_pattern_create_solid().
2008-03-04 09:31:21 +00:00
Chris Wilson
914f4a3ec5 [cairo-pattern] Tidy usage of _cairo_error().
Remove the duplicate calls to _cairo_error() along the constructor
error paths and a missing call to _cairo_error().
2008-03-04 09:31:20 +00:00
Behdad Esfahbod
a55f65b5d2 [doc] Fix typo 2008-01-28 22:25:37 -05:00
Behdad Esfahbod
0d898f2bad [doc] Make sure all type names in docs are prefixed by # 2008-01-28 20:49:44 -05:00
Behdad Esfahbod
9ecde82d35 [doc] Make sure all macro names in docs are prefixed by % 2008-01-28 20:48:48 -05:00
Carl Worth
e48d7ca802 Add example to documentation of cairo_pattern_set_filter
It's helpful to let the reade know about cairo_get_source here.
2008-01-28 16:11:39 -08:00
Chris Wilson
481b88dd6b [cairo-pattern] Add an ASSERT_NOT_REACHED
On the default case for an unknown pattern type, add an assert that the
code is never reached, and just in case upgrade the error to a fatal
PATTERN_TYPE_MISMATCH.
2008-01-12 20:44:02 +00:00
Chris Wilson
2e5f278da1 [cairo-pattern] Free the copied pattern on error.
Free the locally allocated pattern if the copy fails.
2008-01-10 22:11:42 +00:00
Chris Wilson
02b0743458 [cairo-pattern] Rearrange CAIRO_MUTEX_INITIALIZE.
test/pattern-get-type exposes a bug whereby we try to acquire the
_cairo_pattern_solid_pattern_cache_lock before initializing the
mutexes. To fix this move the CAIRO_MUTEX_INITIALIZE() from the
depths of _cairo_pattern_init() and perform it at the public entry
points.
2008-01-10 17:10:30 +00:00
Adrian Johnson
6ead8feaf3 Add _cairo_pattern_create_copy() 2008-01-07 20:41:43 +10:30
Adrian Johnson
583059e4a3 Fix bug in _gradient_is_opaque() 2007-10-13 21:16:49 +09:30
Chris Wilson
bed8239f03 [cairo-error] Clean up all the warnings and missing _cairo_error() calls.
Every time we assign or return a hard-coded error status wrap that value
with a call to _cairo_error(). So the idiom becomes:
    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
or
    return _cairo_error (CAIRO_STATUS_INVALID_DASH);

This ensures that a breakpoint placed on _cairo_error() will trigger
immediately cairo detects the error.
2007-10-04 13:31:44 +01:00
Chris Wilson
71120727e1 [cairo-atomic] Use an atomic operation to set the status on a shared resource.
Since the objects can be shared and may be in use simultaneously across
multiple threads, setting the status needs to be atomic. We use a
locked compare and exchange in order to avoid overwriting an existing
error - that is we use an atomic operation that only sets the new status
value if the current value is CAIRO_STATUS_SUCCESS.
2007-10-04 11:26:44 +01:00
Chris Wilson
8ad56b308a [malloc/error] Add call to _cairo_error() after a failed malloc.
Blitz all allocations to ensure that they raise a
_cairo_error(CAIRO_STATUS_NO_MEMORY) on failure.
2007-10-04 00:42:30 +01:00
Chris Wilson
e49bcde27f [malloc] Check for integer overflow when realloc'ing.
Perform similar sanity checks to Vlad's _cairo_malloc_ab() but on the
arguments to realloc instead.
2007-10-04 00:42:29 +01:00
Chris Wilson
03be41151d [cairo-atomic] Rewrite reference counting using atomic ops.
Introduce an opaque cairo_reference_count_t and define operations on it
in terms of atomic ops. Update all users of reference counters to use
the new opaque type.
2007-09-25 16:29:54 +01:00
Vladimir Vukicevic
93aee43690 Fix previous create_similar fallback patch
We can't use composite, as some backends don't implement it.
Use paint() instead.
2007-08-28 16:47:24 -07:00
Carl Worth
a9662d0aae Eliminate fragile cairo_internal_format_t
Instead we take advantage of the pixman_format_code_t
that now exists in the public interface of the new, external
pixman library.
2007-08-21 17:10:49 -07:00
Chris Wilson
50ebdda3a9 [cairo-pattern] Assert that the pattern->matrix is invertible.
We guarantee when setting the pattern->matrix that it is invertible, so
merely assert that it is so when we attempt to use its inverse.
2007-08-16 15:12:00 +01:00
Carl Worth
13cae8b5e6 Ensure that a copied pattern gets its own user_data array
This fixes the bug reported here:

	Segfault with cairo_pattern_set_user_data
	https://bugs.freedesktop.org/show_bug.cgi?id=11855
2007-08-06 11:06:47 -07:00
Vladimir Vukicevic
c0a7d33ac6 [fixpt] Fixup malloc usage to use _cairo_malloc_*
Fix some introduced mallocs as a result of the fixed point patches.
2007-07-18 22:46:46 +02:00
Vladimir Vukicevic
b719592428 [fixpt] Fix up compilation post pixman merge 2007-07-18 22:46:46 +02:00
Vladimir Vukicevic
0abe5324a5 [fixpt] Create cairo_region wrapper around pixman_region16_t
Insulate region-using code from implementation details;
at some point we'll want to switch to using 32-bit regions.
2007-07-18 22:46:46 +02:00
Vladimir Vukicevic
aaf94ef6c4 [fixpt] remove dependency on some pixman types
Introduce cairo_gradient_stop_t, and remove pixman dependency
for core pattern types.  Perform conversion from cairo types
to pixman types as necessary in fallback code.
2007-07-18 22:45:21 +02:00
Vladimir Vukicevic
be3516335c [fixpt] Replace cairo_rectangle_int16_t with cairo_rectangle_int_t
Mostly s/cairo_rectangle_int16_t/cairo_rectangle_int_t/,
as well as definitions to pick cairo_rectangle_int_t.
2007-07-18 22:45:21 +02:00
Søren Sandmann Pedersen
ef967be630 Merge branch 'master' of git+ssh://sandmann@git.freedesktop.org/git/cairo
Conflicts:

	pixman/src/fbcompose.c
	pixman/src/icimage.c
	pixman/src/pixmanint.h
	pixman/src/pixregionint.h
	src/cairo-clip.c
2007-07-02 08:33:29 -07:00
Vladimir Vukicevic
5c7d2d14d7 [fix] Avoid int overflow when allocating large buffers
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them.  The macros
return NULL if int overflow would occur during the allocation.  See
CODING_STYLE for more information.
2007-06-29 09:46:08 -07:00
Søren Sandmann
0c42dbb192 pixman_image_set_transform() returns FALSE on failure 2007-06-21 22:21:11 -07:00
Søren Sandmann
ca5760a289 Fix initialization of radial patterns 2007-06-21 22:21:11 -07:00
Søren Sandmann
12cc32b674 [pixman] Initial port to standalone pixman library. 2007-06-21 22:21:11 -07:00
Kouhei Sutou
0898411d0a [doc] Minor documentation fixes 2007-05-28 17:05:40 -04:00