summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-10-18 22:12:13 +0200
committerBenjamin Otte <otte@gnome.org>2009-10-18 22:12:13 +0200
commita2254e56474fcdf5f25232812cdbef30a2b5ea60 (patch)
treeca25402c6f7b90e1078589ffd1aa6ec8317a39c2
parent4b720d56db72d314b3b7cedb05a53321b1d0adbe (diff)
[gstate] Apply target device offsets to patterns immediately
Previously target device offsets were applied in cairo-surface.c which could cause bugs when paths were taken as fallbacks, as for example pointed out by ade55037ffa596b690c6a1051394589f76eb1f48 and quick-fixed by 79190d89853958ee8252440d35a662fabf122afd. The quick-fix is now unnecessary and was removed.
-rw-r--r--src/cairo-gstate.c4
-rw-r--r--src/cairo-surface-fallback.c41
-rw-r--r--src/cairo-surface.c59
3 files changed, 10 insertions, 94 deletions
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index ed0e8779..7ee88d6d 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -897,6 +897,10 @@ _cairo_gstate_copy_transformed_pattern (cairo_gstate_t *gstate,
if (! _cairo_matrix_is_identity (ctm_inverse))
_cairo_pattern_transform (pattern, ctm_inverse);
+
+ if (_cairo_surface_has_device_transform (gstate->target))
+ _cairo_pattern_transform (pattern,
+ &gstate->target->device_transform_inverse);
}
static void
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 15d2a63f..c5ef2740 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -984,35 +984,6 @@ _clip_to_boxes (cairo_clip_t **clip,
return status;
}
-/* XXX _cairo_surface_backend_fill? */
-static cairo_status_t
-_wrap_surface_fill (cairo_surface_t *surface,
- cairo_operator_t op,
- const cairo_pattern_t *source,
- cairo_path_fixed_t *path,
- cairo_fill_rule_t fill_rule,
- double tolerance,
- cairo_antialias_t antialias,
- cairo_clip_t *clip)
-{
- if (surface->backend->fill != NULL) {
- cairo_status_t status;
-
- status = surface->backend->fill (surface, op, source,
- path, fill_rule,
- tolerance, antialias,
- clip);
-
- if (status != CAIRO_INT_STATUS_UNSUPPORTED)
- return status;
- }
-
- return _cairo_surface_fallback_fill (surface, op, source,
- path, fill_rule,
- tolerance, antialias,
- clip);
-}
-
cairo_status_t
_cairo_surface_fallback_paint (cairo_surface_t *surface,
cairo_operator_t op,
@@ -1066,12 +1037,12 @@ _cairo_surface_fallback_paint (cairo_surface_t *surface,
if (clip != NULL && clip_path->prev == NULL &&
_cairo_operator_bounded_by_mask (op))
{
- return _wrap_surface_fill (surface, op, source,
- &clip_path->path,
- clip_path->fill_rule,
- clip_path->tolerance,
- clip_path->antialias,
- NULL);
+ return _cairo_surface_fill (surface, op, source,
+ &clip_path->path,
+ clip_path->fill_rule,
+ clip_path->tolerance,
+ clip_path->antialias,
+ NULL);
}
status = _cairo_traps_init_boxes (&traps, boxes, num_boxes);
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 51eb6f0a..e080c31e 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -91,11 +91,6 @@ static DEFINE_NIL_SURFACE(CAIRO_STATUS_WRITE_ERROR, _cairo_surface_nil_write_err
static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_STRIDE, _cairo_surface_nil_invalid_stride);
static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_SIZE, _cairo_surface_nil_invalid_size);
-static void
-_cairo_surface_copy_pattern_for_destination (const cairo_pattern_t **pattern,
- cairo_surface_t *destination,
- cairo_pattern_t *pattern_copy);
-
/**
* _cairo_surface_set_error:
* @surface: a surface
@@ -1922,7 +1917,6 @@ _cairo_surface_paint (cairo_surface_t *surface,
cairo_clip_t *clip)
{
cairo_status_t status;
- cairo_pattern_union_t dev_source;
if (unlikely (surface->status))
return surface->status;
@@ -1932,10 +1926,6 @@ _cairo_surface_paint (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
- _cairo_surface_copy_pattern_for_destination (&source,
- surface,
- &dev_source.base);
-
if (surface->backend->paint != NULL) {
status = surface->backend->paint (surface, op, source, clip);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
@@ -1956,8 +1946,6 @@ _cairo_surface_mask (cairo_surface_t *surface,
cairo_clip_t *clip)
{
cairo_status_t status;
- cairo_pattern_union_t dev_source;
- cairo_pattern_union_t dev_mask;
if (unlikely (surface->status))
return surface->status;
@@ -1967,11 +1955,6 @@ _cairo_surface_mask (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
- _cairo_surface_copy_pattern_for_destination (&source, surface,
- &dev_source.base);
- _cairo_surface_copy_pattern_for_destination (&mask, surface,
- &dev_mask.base);
-
if (surface->backend->mask != NULL) {
status = surface->backend->mask (surface, op, source, mask, clip);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
@@ -2012,16 +1995,9 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
if (surface->backend->fill_stroke) {
- cairo_pattern_union_t dev_stroke_source;
- cairo_pattern_union_t dev_fill_source;
cairo_matrix_t dev_ctm = *stroke_ctm;
cairo_matrix_t dev_ctm_inverse = *stroke_ctm_inverse;
- _cairo_surface_copy_pattern_for_destination (&stroke_source, surface,
- &dev_stroke_source.base);
- _cairo_surface_copy_pattern_for_destination (&fill_source, surface,
- &dev_fill_source.base);
-
status = surface->backend->fill_stroke (surface,
fill_op, fill_source, fill_rule,
fill_tolerance, fill_antialias,
@@ -2065,7 +2041,6 @@ _cairo_surface_stroke (cairo_surface_t *surface,
cairo_clip_t *clip)
{
cairo_status_t status;
- cairo_pattern_union_t dev_source;
if (unlikely (surface->status))
return surface->status;
@@ -2075,9 +2050,6 @@ _cairo_surface_stroke (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
- _cairo_surface_copy_pattern_for_destination (&source, surface,
- &dev_source.base);
-
if (surface->backend->stroke != NULL) {
status = surface->backend->stroke (surface, op, source,
path, stroke_style,
@@ -2110,7 +2082,6 @@ _cairo_surface_fill (cairo_surface_t *surface,
cairo_clip_t *clip)
{
cairo_status_t status;
- cairo_pattern_union_t dev_source;
if (unlikely (surface->status))
return surface->status;
@@ -2120,8 +2091,6 @@ _cairo_surface_fill (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
- _cairo_surface_copy_pattern_for_destination (&source, surface,
- &dev_source.base);
if (surface->backend->fill != NULL) {
status = surface->backend->fill (surface, op, source,
path, fill_rule,
@@ -2429,7 +2398,6 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
{
cairo_status_t status;
cairo_scaled_font_t *dev_scaled_font = scaled_font;
- cairo_pattern_union_t dev_source;
if (unlikely (surface->status))
return surface->status;
@@ -2442,9 +2410,6 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
_cairo_surface_begin_modification (surface);
- _cairo_surface_copy_pattern_for_destination (&source, surface,
- &dev_source.base);
-
if (_cairo_surface_has_device_transform (surface) &&
! _cairo_matrix_is_integer_translation (&surface->device_transform, NULL, NULL))
{
@@ -2794,30 +2759,6 @@ _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t *dst,
}
/**
- * _cairo_surface_copy_pattern_for_destination
- * @pattern: the pattern to copy
- * @destination: the destination surface for which the pattern is being copied
- * @pattern_copy: the location to hold the copy
- *
- * Copies the given pattern, taking into account device scale and offsets
- * of the destination surface.
- */
-static void
-_cairo_surface_copy_pattern_for_destination (const cairo_pattern_t **pattern,
- cairo_surface_t *destination,
- cairo_pattern_t *pattern_copy)
-{
- if (! _cairo_surface_has_device_transform (destination))
- return;
-
- _cairo_pattern_init_static_copy (pattern_copy, *pattern);
- _cairo_pattern_transform (pattern_copy,
- &destination->device_transform_inverse);
-
- *pattern = pattern_copy;
-}
-
-/**
* _cairo_surface_set_resolution
* @surface: the surface
* @x_res: x resolution, in dpi