diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-05 12:21:40 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-06 02:21:38 +0200 |
commit | 65af65d1e82fd2bda7ba05ecea0b8d586c25c6c1 (patch) | |
tree | c5e4d0730df7e76d7217c079f3912ba57313f7c0 /fitz | |
parent | 87103a29cc90e5b48279f31ae98de1d530b90f18 (diff) | |
download | mupdf-65af65d1e82fd2bda7ba05ecea0b8d586c25c6c1.tar.xz |
fitz: Simplify dev_bbox code.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_bbox.c | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/fitz/dev_bbox.c b/fitz/dev_bbox.c index 0f2f3cfe..179ff030 100644 --- a/fitz/dev_bbox.c +++ b/fitz/dev_bbox.c @@ -2,63 +2,56 @@ /* TODO: add clip stack and use to intersect bboxes */ -typedef struct fz_bbox_device_s fz_bbox_device; - -struct fz_bbox_device_s -{ - fz_bbox *bbox; -}; - static void fz_bbox_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_bound_path(path, NULL, ctm)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void fz_bbox_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_bound_path(path, stroke, ctm)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void fz_bbox_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void fz_bbox_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void fz_bbox_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_bound_shade(shade, ctm)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void fz_bbox_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) { - fz_bbox_device *bdev = user; + fz_bbox *result = user; fz_bbox bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect)); - *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); + *result = fz_union_bbox(*result, bbox); } static void @@ -68,23 +61,13 @@ fz_bbox_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_bbox_fill_image(user, image, ctm, alpha); } -static void -fz_bbox_free_user(void *user) -{ - fz_bbox_device *bdev = user; - fz_free(bdev); -} - fz_device * -fz_new_bbox_device(fz_bbox *bboxp) +fz_new_bbox_device(fz_bbox *result) { fz_device *dev; - fz_bbox_device *bdev = fz_malloc(sizeof(fz_bbox_device)); - bdev->bbox = bboxp; - *bdev->bbox = fz_empty_bbox; - dev = fz_new_device(bdev); - dev->free_user = fz_bbox_free_user; + dev = fz_new_device(result); + dev->fill_path = fz_bbox_fill_path; dev->stroke_path = fz_bbox_stroke_path; dev->fill_text = fz_bbox_fill_text; @@ -92,5 +75,8 @@ fz_new_bbox_device(fz_bbox *bboxp) dev->fill_shade = fz_bbox_fill_shade; dev->fill_image = fz_bbox_fill_image; dev->fill_image_mask = fz_bbox_fill_image_mask; + + *result = fz_empty_bbox; + return dev; } |