diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-24 16:27:07 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-24 16:27:07 +0100 |
commit | 4c72c4df661b4cc24f40d8719da15a13adc7bb9b (patch) | |
tree | 364bc56096ae914bd7577f01ce986330e140f1c9 /src/cairo-clip.c | |
parent | cc745f5c2f5a513e195a9a3b66e4428ec932bfe3 (diff) | |
download | cairo-4c72c4df661b4cc24f40d8719da15a13adc7bb9b.tar.gz |
wrapper: Correct translation of clip for wrapper extents
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-clip.c')
-rw-r--r-- | src/cairo-clip.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cairo-clip.c b/src/cairo-clip.c index fcd1acb49..7e4f8c547 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -387,6 +387,42 @@ _cairo_clip_path_copy_with_translation (cairo_clip_t *clip, } cairo_clip_t * +_cairo_clip_translate (cairo_clip_t *clip, int tx, int ty) +{ + int fx, fy, i; + cairo_clip_path_t *clip_path; + + if (clip == NULL || _cairo_clip_is_all_clipped (clip)) + return (cairo_clip_t *)clip; + + if (tx == 0 && ty == 0) + return clip; + + fx = _cairo_fixed_from_int (tx); + fy = _cairo_fixed_from_int (ty); + + for (i = 0; i < clip->num_boxes; i++) { + clip->boxes[i].p1.x += fx; + clip->boxes[i].p2.x += fx; + clip->boxes[i].p1.y += fy; + clip->boxes[i].p2.y += fy; + } + + clip->extents.x += tx; + clip->extents.y += ty; + + if (clip->path == NULL) + return clip; + + clip_path = clip->path; + clip->path = NULL; + clip = _cairo_clip_path_copy_with_translation (clip, clip_path, fx, fy); + _cairo_clip_path_destroy (clip_path); + + return clip; +} + +cairo_clip_t * _cairo_clip_copy_with_translation (const cairo_clip_t *clip, int tx, int ty) { cairo_clip_t *copy; |