Commit graph

222 commits

Author SHA1 Message Date
Chris Wilson
ddd1615a17 [pattern] Remove incorrect assert.
It's possible to reach that point without setting the filter to NEAREST,
for example if using FAST or GAUSSIAN.
2008-10-09 12:25:07 +01:00
Chris Wilson
eaa4bd1392 [pattern] After cloning adjust [xy]_offset if possible.
For the simple case where the pattern matrix only contains an integer
translation then care is taken to convert that to a identity source matrix
with the translation applied to the [xy]_offsets. 5b97ee6525 broke this
guarantee by applying the clone offsets to the source matrix. So when the
source matrix is identity we can simply adjust the [xy]_offsets and
preserve the identity matrix. (This idea can be extended further by
removing any integer translation from the source matrix and storing it in
the [xy]_offsets as a means to extend the limited precision in
pixman_matrix_t - encountered when downscaling large images offset onto
the target surface.)
2008-10-07 21:09:16 +01:00
Chris Wilson
7cb9ccb4cb Fixup a couple of trivials doc warnings.
Correct the 'Returns' statement to match what gtk-doc expects.
2008-10-07 01:45:45 +01:00
Chris Wilson
6da8d8ea62 [pattern] Fix up OBO introduced to cloned area
In the midst of porting 5eec3e378a I failed
to include the pad in the floor() and ceil() which introduces two
potential off-by-one errors into each dimension of the region of interest
of the source surface.
2008-09-29 18:00:57 +01:00
Owen W. Taylor
5eec3e378a [pattern] Improve handling of filter radius and optimize when possible.
Factor out common filter analysis code from _cairo_pattern_get_extents()
so that we can share it with _cairo_pattern_acquire_surface_for_surface()
as well. During the analysis of the filter determine whether the pattern
matrix maps source pixels exactly onto destination pixels and if so convert
the filter to NEAREST - generalising the existing conversion to NEAREST.

(Patch ported to master by Chris Wilson, all bugs are his.)
2008-09-29 09:46:50 +01:00
Carl Worth
7d7057cf88 _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-09-29 09:46:49 +01:00
Owen W. Taylor
6ef4bd4ecf [pattern] Fix acquiring outside of source bounds
Restrict the area we acquire from the source image to the bounds of
the source image, even when we have an identity matrix. This handles
circumstances where the pattern extents may be enlarged due to
filtering, for example when applying a bilinear filter.

This patch replaces the open-coded rectangle intersection which has
already proven itself to be a source of bugs.

(Patch ported to master by Chris Wilson, all bugs are his.)
2008-09-29 09:46:49 +01:00
Owen W. Taylor
6d0f2c4421 [pattern] Remove the hack to support cloning surface patterns.
Remove instances (abuses) of calling _cairo_pattern_acquire_surface() on
a known-surface-pattern with a hack to say "give me the entire surface".
If you know you just want the entire surface as an image surface, that
can be done more simply.

(Split from original patch on
https://bugs.freedesktop.org/attachment.cgi?id=15703, by Chris Wilson -
as usual all bugs are his.)
2008-09-29 09:46:49 +01:00
Chris Wilson
871f683367 clone_similar(): s/device_offset/clone_offset/
A little bit of sleep and reflection suggested that the use of
device_offset_[xy] was confusing and clone_offset_[xy] more consistent
with the function naming.
2008-09-27 17:27:21 +01:00
Chris Wilson
5b97ee6525 Allow cloning sub-regions of similar surfaces.
Previously the rule for clone_similar() was that the returned surface
had exactly the same size as the original, but only the contents within
the region of interest needed to be copied. This caused failures for very
large images in the xlib-backend (see test/large-source).

The obvious solution to allow cloning only the region of interest seemed
to be to simply set the device offset on the cloned surface. However, this
fails as a) nothing respects the device offset on the surface at that
layer in the compositing stack and b) possibly returning references to the
original source surface provides further confusion by mixing in another
source of device offset.

The second method was to add extra out parameters so that the
device offset could be returned separately and, for example, mixed into
the pattern matrix. Not as elegant, a couple of extra warts to the
interface, but it works - one less XFAIL...
2008-09-27 02:20:42 +01:00
Chris Wilson
8f51ea4657 [pattern] Beware unsigned wrap-around with pathological surface patterns.
A surface pattern under an extreme transformation could lie entirely in
the negative quadrant. This would trigger the fixup such that it's lower
left corner was clamped to the origin, but the upper right corner was left
unchecked. This could result in the width,height being negative and
wrapping around to large values instead of being clamped to 0.
2008-09-23 23:35:53 +01:00
Chris Wilson
b7ab1fc791 Return the real error status for set_user_data()
Instead of returning a new NO_MEMORY error, return the status from the
error object.
2008-09-23 20:08:30 +01:00
Carl Worth
bdcdc8400e Rename _init_pattern_with_snapshot to _cairo_pattern_init_snapshot 2008-09-10 14:54:18 -07:00
Chris Wilson
31565677db [pattern] Unbounded patterns should have infinite extents.
Fix a slight typo that produced negative sized extents instead of the
maximum.
2008-08-11 20:43:14 +01:00
Chris Wilson
7c1078b830 Check return from pixman_image_set_filter().
Adding warn_unused_result to pixman detected a couple of instances where
we abused the knowledge that the code currently can not fail, but in
deference to its independent existence we should be more cautious.
2008-08-07 14:01:54 +01:00
Chris Wilson
6a4ddb6f47 [pattern] Set the reference count for stack allocations to 0.
Keep the reference count as zero for temporary, on-stack patterns in
order to detect attempts to keep references beyond their scope. (And
mismatched _init()/_destroy()).
2008-08-07 08:30:09 +01:00
Behdad Esfahbod
1c729f85ed [cairo-pattern] Fix crash in solid-pattern-surface cache
Ickle knew something when he only extended cache size when we are
committed to inserting something into the cache.  I broke that while
fixing other issues a while ago.  This cache just doesn't want to
give us any rest...
2008-07-03 19:15:53 -04:00
Behdad Esfahbod
74789a702b Cleanup _set_error functions a bit 2008-06-24 15:07:07 -04:00
Behdad Esfahbod
93efdce43a Add a create_solid_pattern_surface surface backend method
This can be used by _cairo_pattern_acquire_surface_for_solid() to let
the backend create custom surfaces for solid fill instead of a 1x1
similar surface.
2008-06-19 21:53:57 -04:00
Behdad Esfahbod
ff1371a0a7 [cairo-surface] Remove optional pattern argument from create_similar_solid()
This was added in 41c6eebcd1, to avoid
allocating short-lived patterns.  However, this was error prune as the
color information was duplicated in the pattern and could get out of
sync.  Indeed, it was out of sync before this commit in the call from
cairo-clip.c.

By allocating the solid pattern on the stack we fix the original problem
without creating new ones.
2008-06-19 21:06:07 -04:00
Behdad Esfahbod
240cb59fe8 [cairo-pattern] Clean up _cairo_pattern_acquire_surface_for_solid() 2008-06-19 19:49:23 -04:00
Behdad Esfahbod
b0d112756f Remove opaque solid pattern COLOR_ALPHA optimization from call sites
As we do this in _cairo_pattern_init_solid() now.
2008-06-19 19:25:33 -04:00
Behdad Esfahbod
e93e990324 [cairo-pattern] In init_solid() convert COLOR_ALPHA to COLOR if color is opaque
Moving this further than, so it benefits all callers.
2008-06-19 19:22:36 -04:00
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