summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-07-07 13:40:30 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-07-08 12:04:51 +0200
commit048948c9705c47b0ccd4ebf835d4612496ce6eb0 (patch)
treef8ee62da63fcca7d3f698b43f563ebf516fa0d8e
parent5f11fd5eb7096d15f92abbb9d7d84d0c35eb8f53 (diff)
downloadmupdf-048948c9705c47b0ccd4ebf835d4612496ce6eb0.tar.xz
Slim pdf_annot struct: remove cached rect field.
-rw-r--r--include/mupdf/pdf/annot.h1
-rw-r--r--source/pdf/pdf-annot-edit.c10
-rw-r--r--source/pdf/pdf-annot.c8
-rw-r--r--source/pdf/pdf-appearance.c21
4 files changed, 14 insertions, 26 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index 7038a9fb..913dd80b 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -62,7 +62,6 @@ struct pdf_annot_s
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *obj;
- fz_rect rect;
pdf_xobject *ap;
int ap_iteration;
fz_matrix matrix;
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index dc07cd7f..5427ea3a 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -121,7 +121,6 @@ pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_ty
fz_invert_matrix(&inv_page_ctm, &page_ctm);
annot = pdf_new_annot(ctx, page, &page_ctm, &inv_page_ctm);
- annot->rect = rect;
annot->ap = NULL;
annot->widget_type = PDF_WIDGET_TYPE_NOT_WIDGET;
annot->annot_type = type;
@@ -256,11 +255,6 @@ pdf_set_markup_annot_quadpoints(fz_context *ctx, pdf_document *doc, pdf_annot *a
}
}
-static void update_rect(fz_context *ctx, pdf_annot *annot)
-{
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &annot->rect);
-}
-
void
pdf_set_ink_annot_list(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pts, int *counts, int ncount, float color[3], float thickness)
{
@@ -314,7 +308,6 @@ pdf_set_ink_annot_list(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_
}
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &rect));
- update_rect(ctx, annot);
bs = pdf_new_dict(ctx, doc, 1);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_BS, bs);
@@ -356,8 +349,6 @@ void pdf_set_text_annot_position(fz_context *ctx, pdf_document *doc, pdf_annot *
flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_F));
flags |= (F_NoZoom|F_NoRotate);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_F, pdf_new_int(ctx, doc, flags));
-
- update_rect(ctx, annot);
}
void pdf_set_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot, char *text)
@@ -463,7 +454,6 @@ void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *an
bounds.y1 += page_pos.y;
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME_Rect, pdf_new_rect(ctx, doc, &bounds));
- update_rect(ctx, annot);
}
fz_always(ctx)
{
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index d06d9fa4..c5354c71 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -406,9 +406,11 @@ void
pdf_transform_annot(fz_context *ctx, pdf_annot *annot)
{
fz_rect bbox = annot->ap->bbox;
- fz_rect rect = annot->rect;
+ fz_rect rect;
float w, h, x, y;
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &rect);
+
fz_transform_rect(&bbox, &annot->ap->matrix);
if (bbox.x1 == bbox.x0)
w = 0;
@@ -501,7 +503,7 @@ void
pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *annots, const fz_matrix *page_ctm)
{
pdf_annot *annot, **itr;
- pdf_obj *obj, *ap, *as, *n, *rect;
+ pdf_obj *obj, *ap, *as, *n;
int i, len, keep_annot;
fz_matrix inv_page_ctm;
@@ -558,7 +560,6 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
doc->update_appearance(ctx, doc, annot);
obj = annot->obj;
- rect = pdf_dict_get(ctx, obj, PDF_NAME_Rect);
ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
as = pdf_dict_get(ctx, obj, PDF_NAME_AS);
@@ -581,7 +582,6 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
if (!pdf_is_stream(ctx, n))
n = pdf_dict_get(ctx, n, as);
- pdf_to_rect(ctx, rect, &annot->rect);
annot->ap = NULL;
annot->annot_type = pdf_annot_obj_type(ctx, obj);
annot->widget_type = annot->annot_type == FZ_ANNOT_WIDGET ? pdf_field_type(ctx, doc, obj) : PDF_WIDGET_TYPE_NOT_WIDGET;
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index e073a1db..1e74fa15 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1564,11 +1564,6 @@ void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_a
pdf_set_markup_appearance(ctx, doc, annot, color, alpha, line_thickness, line_height);
}
-static void update_rect(fz_context *ctx, pdf_annot *annot)
-{
- pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &annot->rect);
-}
-
void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list)
{
pdf_obj *obj = annot->obj;
@@ -1629,8 +1624,6 @@ void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *ann
}
doc->dirty = 1;
-
- update_rect(ctx, annot);
}
fz_catch(ctx)
{
@@ -2172,8 +2165,10 @@ void pdf_update_free_text_annot_appearance(fz_context *ctx, pdf_document *doc, p
{
char *contents = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Contents));
char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_DA));
- fz_rect rect = annot->rect;
fz_point pos;
+ fz_rect rect;
+
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &rect);
get_font_info(ctx, doc, dr, da, &font_rec);
@@ -2358,10 +2353,14 @@ void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot
fz_try(ctx)
{
char *da = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME_DA));
- fz_rect rect = annot->rect;
+ fz_rect annot_rect;
fz_rect logo_bounds;
fz_matrix logo_tm;
unsigned char *bufstr;
+ fz_rect rect;
+
+ pdf_to_rect(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME_Rect), &annot_rect);
+ rect = annot_rect;
dlist = fz_new_display_list(ctx, NULL);
dev = fz_new_list_device(ctx, dlist);
@@ -2399,12 +2398,12 @@ void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot
if (date)
fz_buffer_printf(ctx, fzbuf, "\nDate: %s", date);
(void)fz_buffer_storage(ctx, fzbuf, &bufstr);
- rect = annot->rect;
+ rect = annot_rect;
rect.x0 = (rect.x0 + rect.x1)/2.0f;
text = fit_text(ctx, &font_rec, (char *)bufstr, &rect);
fz_fill_text(ctx, dev, text, page_ctm, cs, font_rec.da_rec.col, 1.0f);
- rect = annot->rect;
+ rect = annot_rect;
fz_transform_rect(&rect, page_ctm);
pdf_set_annot_appearance(ctx, doc, annot, &rect, dlist);