From 0abcccc4aab4d893ac2a0ef116ff1f0c006fbc30 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 6 Jul 2018 14:20:26 +0200 Subject: Rejig pdf_update_page and pdf_update_annot. The intent is for a user to iterate over the annotations on a page calling pdf_update_annot for each one. If this function returns true, then the annotation has changed since the last time it was called, and the user needs to re-render. pdf_update_page is a simple loop over the annotations on a page, for use if you only care about page level granularity. Users should no longer look at or change the pdf_annot.has_new_ap field. --- platform/x11/pdfapp.c | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'platform/x11') diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index 01011b2b..22fb7f1b 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -799,40 +799,15 @@ static void pdfapp_runpage(pdfapp_t *app, fz_device *dev, const fz_matrix ctm, f static void pdfapp_updatepage(pdfapp_t *app) { - fz_device *idev; - fz_matrix ctm; - pdf_annot *pannot; - - pdfapp_viewctm(&ctm, app); - pdf_update_page(app->ctx, (pdf_page *)app->page); - pdfapp_recreate_annotationslist(app); - - for (pannot = pdf_first_annot(app->ctx, (pdf_page*)app->page); pannot; pannot = pdf_next_annot(app->ctx, pannot)) + if (pdf_update_page(app->ctx, (pdf_page*)app->page)) { - if (pannot->has_new_ap) - { - fz_annot *annot = (fz_annot*)pannot; - fz_rect bounds; - fz_irect ibounds; - bounds = fz_transform_rect(fz_bound_annot(app->ctx, annot), ctm); - ibounds = fz_round_rect(bounds); - bounds = fz_rect_from_irect(ibounds); - fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, ibounds); - idev = fz_new_draw_device_with_bbox(app->ctx, fz_identity, app->image, &ibounds); - fz_try(app->ctx) - { - pdfapp_runpage(app, idev, ctm, bounds, NULL); - fz_close_device(app->ctx, idev); - } - fz_always(app->ctx) - fz_drop_device(app->ctx, idev); - fz_catch(app->ctx) - fz_rethrow(app->ctx); - pannot->has_new_ap = 0; - } + pdfapp_recreate_annotationslist(app); + pdfapp_showpage(app, 0, 1, 1, 0, 0); + } + else + { + pdfapp_showpage(app, 0, 0, 1, 0, 0); } - - pdfapp_showpage(app, 0, 0, 1, 0, 0); } void pdfapp_reloadpage(pdfapp_t *app) -- cgit v1.2.3