diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-02-28 12:48:12 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-02-28 17:07:44 +0000 |
commit | 5d63cf651367bee808d653213c7af7a31ad833ce (patch) | |
tree | 5a61752d9b096946d27e9df5944b3119e9cc476d /pdf | |
parent | 215550b73bfaad01b29cda005dd5b0d6b749b381 (diff) | |
download | mupdf-5d63cf651367bee808d653213c7af7a31ad833ce.tar.xz |
Pass bbox to pdf_set_annot_appearance rather than base on display list
Use of the bbox device to derive the area of the display list can lead
to bad results because of heuristics used to handle corners of stroked
paths.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/mupdf-internal.h | 2 | ||||
-rw-r--r-- | pdf/pdf_annot.c | 23 |
2 files changed, 11 insertions, 14 deletions
diff --git a/pdf/mupdf-internal.h b/pdf/mupdf-internal.h index a4e34a8f..e0c0c56a 100644 --- a/pdf/mupdf-internal.h +++ b/pdf/mupdf-internal.h @@ -589,7 +589,7 @@ int pdf_choice_widget_value(pdf_document *doc, fz_widget *tw, char *opts[]); void pdf_choice_widget_set_value(pdf_document *doc, fz_widget *tw, int n, char *opts[]); pdf_annot *pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type); void pdf_delete_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot); -void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_display_list *disp_list); +void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list); void pdf_set_markup_annot_quadpoints(pdf_document *doc, pdf_annot *annot, fz_point *qp, int n); void pdf_set_doc_event_callback(pdf_document *doc, fz_doc_event_cb *event_cb, void *data); diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index e79f8c45..db5b10f1 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -639,7 +639,7 @@ pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type) { int ind_obj_num; fz_rect rect = {0.0, 0.0, 0.0, 0.0}; - char *type_str = annot_type_str(type); + const char *type_str = annot_type_str(type); pdf_obj *annot_arr = pdf_dict_gets(page->me, "Annots"); if (annot_arr == NULL) { @@ -790,24 +790,22 @@ pdf_set_markup_annot_quadpoints(pdf_document *doc, pdf_annot *annot, fz_point *q } void -pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_display_list *disp_list) +pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list) { fz_context *ctx = doc->ctx; fz_matrix ctm; - fz_rect rect; fz_matrix mat = fz_identity; - fz_device *dev = fz_new_bbox_device(ctx, &rect); + fz_device *dev = NULL; fz_invert_matrix(&ctm, &annot->page->ctm); fz_try(ctx) { pdf_obj *ap_obj; + fz_rect trect = *rect; - fz_run_display_list(disp_list, dev, &ctm, &fz_infinite_rect, NULL); - fz_free_device(dev); - dev = NULL; + fz_transform_rect(&trect, &ctm); - pdf_dict_puts_drop(annot->obj, "Rect", pdf_new_rect(ctx, &rect)); + pdf_dict_puts_drop(annot->obj, "Rect", pdf_new_rect(ctx, &trect)); /* See if there is a current normal appearance */ ap_obj = pdf_dict_getp(annot->obj, "AP/N"); @@ -816,12 +814,12 @@ pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_display_list *d if (ap_obj == NULL) { - ap_obj = pdf_new_xobject(doc, &rect, &mat); + ap_obj = pdf_new_xobject(doc, &trect, &mat); pdf_dict_putp_drop(annot->obj, "AP/N", ap_obj); } else { - pdf_dict_puts_drop(ap_obj, "Rect", pdf_new_rect(ctx, &rect)); + pdf_dict_puts_drop(ap_obj, "Rect", pdf_new_rect(ctx, &trect)); pdf_dict_puts_drop(ap_obj, "Matrix", pdf_new_matrix(ctx, &mat)); } @@ -830,9 +828,8 @@ pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_display_list *d pdf_drop_xobject(ctx, annot->ap); annot->ap = NULL; - annot->rect = rect; - annot->pagerect = rect; - fz_transform_rect(&annot->pagerect, &annot->page->ctm); + annot->rect = trect; + annot->pagerect = *rect; dev = pdf_new_pdf_device(doc, ap_obj, pdf_dict_gets(ap_obj, "Resources"), &mat); fz_run_display_list(disp_list, dev, &ctm, &fz_infinite_rect, NULL); |