summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-06-29 19:47:26 +0200
committerCarl Worth <cworth@cworth.org>2006-06-29 21:33:34 +0200
commitbd92eb7f3c58fdcbe05f67b9a879798246c616bc (patch)
tree02ce459db66aaf17344e5ddcad1e5391f62d5367
parent29caf8915f822778f0e59add7d364a03bcdb8327 (diff)
Move device_transform of path to before floating->fixed conversion.
This is an attempt to fix the following bug: http://bugzilla.gnome.org/show_bug.cgi?id=332266 With the recent rewrite of the device-offset code, which pushed things from the gstate to the surface layer, the 16-bit limitations on coordinates which previously applied to device space only, have lately been applying to user space. This commit moves the device_transform back up above the conversion from floating-point to fixed-point values so that once again the limitation only applies to device space.
-rw-r--r--src/cairo-clip.c10
-rw-r--r--src/cairo-gstate.c8
-rw-r--r--src/cairo-surface-fallback.c1
-rw-r--r--src/cairo-surface.c54
-rw-r--r--src/cairo-xlib-surface.c1
-rw-r--r--src/cairoint.h1
6 files changed, 31 insertions, 44 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 0a3bd5f86..630ec89f2 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -433,14 +433,6 @@ _cairo_clip_clip (cairo_clip_t *clip,
{
cairo_status_t status;
cairo_traps_t traps;
- cairo_path_fixed_t path_transformed;
-
- if (_cairo_surface_has_device_transform (target)) {
- _cairo_path_fixed_init_copy (&path_transformed, path);
- _cairo_path_fixed_device_transform (&path_transformed,
- &target->device_transform);
- path = &path_transformed;
- }
status = _cairo_clip_intersect_path (clip,
path, fill_rule, tolerance,
@@ -467,8 +459,6 @@ _cairo_clip_clip (cairo_clip_t *clip,
bail:
_cairo_traps_fini (&traps);
- if (path == &path_transformed)
- _cairo_path_fixed_fini (&path_transformed);
return status;
}
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index e262630db..f852d506c 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -696,11 +696,13 @@ void
_cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y)
{
cairo_matrix_transform_point (&gstate->ctm, x, y);
+ cairo_matrix_transform_point (&gstate->target->device_transform, x, y);
}
void
_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y)
{
+ cairo_matrix_transform_point (&gstate->target->device_transform_inverse, x, y);
cairo_matrix_transform_point (&gstate->ctm_inverse, x, y);
}
@@ -1435,9 +1437,9 @@ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate,
for (i = 0; i < num_glyphs; ++i)
{
transformed_glyphs[i] = glyphs[i];
- _cairo_gstate_user_to_backend (gstate,
- &transformed_glyphs[i].x,
- &transformed_glyphs[i].y);
+ _cairo_gstate_user_to_device (gstate,
+ &transformed_glyphs[i].x,
+ &transformed_glyphs[i].y);
}
_cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 5f7607a1a..090da70a8 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -991,6 +991,7 @@ _cairo_surface_fallback_snapshot (cairo_surface_t *surface)
image, &image_extra);
snapshot->device_transform = surface->device_transform;
+ snapshot->device_transform_inverse = surface->device_transform_inverse;
snapshot->is_snapshot = TRUE;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 0aafa7366..51c1bccf6 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -57,6 +57,10 @@ const cairo_surface_t _cairo_surface_nil = {
0.0, 1.0,
0.0, 0.0
}, /* device_transform */
+ { 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0
+ }, /* device_transform_inverse */
0.0, /* x_fallback_resolution */
0.0, /* y_fallback_resolution */
0, /* next_clip_serial */
@@ -79,6 +83,10 @@ const cairo_surface_t _cairo_surface_nil_file_not_found = {
0.0, 1.0,
0.0, 0.0
}, /* device_transform */
+ { 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0
+ }, /* device_transform_inverse */
0.0, /* x_fallback_resolution */
0.0, /* y_fallback_resolution */
0, /* next_clip_serial */
@@ -101,6 +109,10 @@ const cairo_surface_t _cairo_surface_nil_read_error = {
0.0, 1.0,
0.0, 0.0
}, /* device_transform */
+ { 1.0, 0.0,
+ 0.0, 1.0,
+ 0.0, 0.0
+ }, /* device_transform_inverse */
0.0, /* x_fallback_resolution */
0.0, /* y_fallback_resolution */
0, /* next_clip_serial */
@@ -208,6 +220,7 @@ _cairo_surface_init (cairo_surface_t *surface,
_cairo_user_data_array_init (&surface->user_data);
cairo_matrix_init_identity (&surface->device_transform);
+ cairo_matrix_init_identity (&surface->device_transform_inverse);
surface->x_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
surface->y_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
@@ -651,6 +664,9 @@ _cairo_surface_set_device_scale (cairo_surface_t *surface,
surface->device_transform.xx = sx;
surface->device_transform.yy = sy;
+
+ surface->device_transform_inverse.xx = 1.0 / sx;
+ surface->device_transform_inverse.yy = 1.0 / sy;
}
/**
@@ -688,6 +704,9 @@ cairo_surface_set_device_offset (cairo_surface_t *surface,
surface->device_transform.x0 = x_offset;
surface->device_transform.y0 = y_offset;
+
+ surface->device_transform_inverse.x0 = - x_offset;
+ surface->device_transform_inverse.y0 = - y_offset;
}
/**
@@ -1227,24 +1246,9 @@ _cairo_surface_stroke (cairo_surface_t *surface,
_cairo_surface_copy_pattern_for_destination (source, surface, &dev_source.base);
- if (_cairo_surface_has_device_transform (surface))
- {
- cairo_matrix_t tmp;
- _cairo_path_fixed_init_copy (&real_dev_path, path);
- _cairo_path_fixed_device_transform (&real_dev_path,
- &surface->device_transform);
- dev_path = &real_dev_path;
-
- cairo_matrix_multiply (&dev_ctm, &dev_ctm, &surface->device_transform);
- tmp = surface->device_transform;
- status = cairo_matrix_invert (&tmp);
- assert (status == CAIRO_STATUS_SUCCESS);
- cairo_matrix_multiply (&dev_ctm_inverse, &tmp, &dev_ctm_inverse);
- }
-
if (surface->backend->stroke) {
status = surface->backend->stroke (surface, op, &dev_source.base,
- dev_path, stroke_style,
+ path, stroke_style,
&dev_ctm, &dev_ctm_inverse,
tolerance, antialias);
@@ -1253,7 +1257,7 @@ _cairo_surface_stroke (cairo_surface_t *surface,
}
status = _cairo_surface_fallback_stroke (surface, op, &dev_source.base,
- dev_path, stroke_style,
+ path, stroke_style,
&dev_ctm, &dev_ctm_inverse,
tolerance, antialias);
@@ -1276,24 +1280,14 @@ _cairo_surface_fill (cairo_surface_t *surface,
{
cairo_status_t status;
cairo_pattern_union_t dev_source;
- cairo_path_fixed_t *dev_path = path;
- cairo_path_fixed_t real_dev_path;
assert (! surface->is_snapshot);
_cairo_surface_copy_pattern_for_destination (source, surface, &dev_source.base);
- if (_cairo_surface_has_device_transform (surface))
- {
- _cairo_path_fixed_init_copy (&real_dev_path, path);
- _cairo_path_fixed_device_transform (&real_dev_path,
- &surface->device_transform);
- dev_path = &real_dev_path;
- }
-
if (surface->backend->fill) {
status = surface->backend->fill (surface, op, &dev_source.base,
- dev_path, fill_rule,
+ path, fill_rule,
tolerance, antialias);
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
@@ -1301,12 +1295,10 @@ _cairo_surface_fill (cairo_surface_t *surface,
}
status = _cairo_surface_fallback_fill (surface, op, &dev_source.base,
- dev_path, fill_rule,
+ path, fill_rule,
tolerance, antialias);
FINISH:
- if (dev_path == &real_dev_path)
- _cairo_path_fixed_fini (&real_dev_path);
_cairo_pattern_fini (&dev_source.base);
return status;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 6ce7557ae..8b9d02e5c 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2276,6 +2276,7 @@ _cairo_xlib_surface_add_glyph (Display *dpy,
cairo_destroy (cr);
tmp_surface->device_transform = glyph_surface->base.device_transform;
+ tmp_surface->device_transform_inverse = glyph_surface->base.device_transform_inverse;
glyph_surface = (cairo_image_surface_t *) tmp_surface;
diff --git a/src/cairoint.h b/src/cairoint.h
index 54995d2e3..9ecb0726d 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -868,6 +868,7 @@ struct _cairo_surface {
cairo_user_data_array_t user_data;
cairo_matrix_t device_transform;
+ cairo_matrix_t device_transform_inverse;
double x_fallback_resolution;
double y_fallback_resolution;