diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-09-22 16:00:21 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-10-07 17:22:58 +0200 |
commit | 8e244f7e2add3606283c0c797d75067fd01ad740 (patch) | |
tree | 1d3d70646b637792865c0b14be37127eb5eef250 /platform | |
parent | 170f35a5802ec7093b00fb2e39bbde3756516f15 (diff) | |
download | mupdf-8e244f7e2add3606283c0c797d75067fd01ad740.tar.xz |
Remove separate tmp/deleted/changed annotation lists.
Use a flag in the pdf_annot struct instead.
Don't pass pdf_document to annotation edit functions.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/viewer/jni/mupdf.c | 34 | ||||
-rw-r--r-- | platform/gl/gl-main.c | 4 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 20 | ||||
-rw-r--r-- | platform/x11/pdfapp.c | 29 |
4 files changed, 49 insertions, 38 deletions
diff --git a/platform/android/viewer/jni/mupdf.c b/platform/android/viewer/jni/mupdf.c index b682296c..96dc36df 100644 --- a/platform/android/viewer/jni/mupdf.c +++ b/platform/android/viewer/jni/mupdf.c @@ -669,21 +669,27 @@ JNI_FN(MuPDFCore_javascriptSupported)(JNIEnv *env, jobject thiz) static void update_changed_rects(globals *glo, page_cache *pc, pdf_document *idoc) { fz_context *ctx = glo->ctx; - fz_annot *annot; + pdf_page *ppage = (pdf_page*)pc->page; + pdf_annot *pannot; - pdf_update_page(ctx, idoc, (pdf_page *)pc->page); - while ((annot = (fz_annot *)pdf_poll_changed_annot(ctx, idoc, (pdf_page *)pc->page)) != NULL) + pdf_update_page(ctx, ppage); + for (pannot = pdf_first_annot(ctx, ppage); pannot; pannot = pdf_next_annot(ctx, pannot)) { - /* FIXME: We bound the annot twice here */ - rect_node *node = fz_malloc_struct(glo->ctx, rect_node); - fz_bound_annot(ctx, annot, &node->rect); - node->next = pc->changed_rects; - pc->changed_rects = node; - - node = fz_malloc_struct(glo->ctx, rect_node); - fz_bound_annot(ctx, annot, &node->rect); - node->next = pc->hq_changed_rects; - pc->hq_changed_rects = node; + if (pannot->changed) + { + fz_annot *annot = (fz_annot*)pannot; + + /* FIXME: We bound the annot twice here */ + rect_node *node = fz_malloc_struct(ctx, rect_node); + fz_bound_annot(ctx, annot, &node->rect); + node->next = pc->changed_rects; + pc->changed_rects = node; + + node = fz_malloc_struct(ctx, rect_node); + fz_bound_annot(ctx, annot, &node->rect); + node->next = pc->hq_changed_rects; + pc->hq_changed_rects = node; + } } } @@ -1740,7 +1746,7 @@ JNI_FN(MuPDFCore_deleteAnnotationInternal)(JNIEnv * env, jobject thiz, int annot if (annot) { - pdf_delete_annot(ctx, idoc, (pdf_page *)pc->page, (pdf_annot *)annot); + pdf_delete_annot(ctx, (pdf_page *)pc->page, (pdf_annot *)annot); dump_annotation_display_lists(glo); } } diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c index 904f3f51..712e02aa 100644 --- a/platform/gl/gl-main.c +++ b/platform/gl/gl-main.c @@ -679,7 +679,7 @@ static void do_forms(float xofs, float yofs) { if (pdf->focus) ui.active = do_forms; - pdf_update_page(ctx, pdf, (pdf_page*)page); + pdf_update_page(ctx, (pdf_page*)page); render_page(); ui_needs_update = 1; } @@ -692,7 +692,7 @@ static void do_forms(float xofs, float yofs) event.event.pointer.ptype = PDF_POINTER_UP; if (pdf_pass_event(ctx, pdf, (pdf_page*)page, &event)) { - pdf_update_page(ctx, pdf, (pdf_page*)page); + pdf_update_page(ctx, (pdf_page*)page); render_page(); ui_needs_update = 1; } diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index 496b62ce..f5afdcee 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -504,19 +504,21 @@ static rect_list *updatePage(fz_document *doc, fz_page *page) fz_try(ctx) { pdf_document *idoc = pdf_specifics(ctx, doc); - if (idoc) { - fz_annot *annot; + pdf_page *page = (pdf_page*)page; + pdf_annot *pannot; - pdf_update_page(ctx, idoc, (pdf_page *)page); - while ((annot = (fz_annot *)pdf_poll_changed_annot(ctx, idoc, (pdf_page *)page)) != NULL) + pdf_update_page(ctx, (pdf_page *)page); + for (pannot = pdf_first_annot(ctx, ppage); pannot; pannot = pdf_next_annot(ctx, pannot)) { - rect_list *node = fz_malloc_struct(ctx, rect_list); - - fz_bound_annot(ctx, annot, &node->rect); - node->next = list; - list = node; + if (pannot->changed) + { + rect_list *node = fz_malloc_struct(ctx, rect_list); + fz_bound_annot(ctx, (fz_annot*)pannot, &node->rect); + node->next = list; + list = node; + } } } } diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index a7e9ebea..0b81d37f 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -786,26 +786,29 @@ static void pdfapp_runpage(pdfapp_t *app, fz_device *dev, const fz_matrix *ctm, static void pdfapp_updatepage(pdfapp_t *app) { - pdf_document *idoc = pdf_specifics(app->ctx, app->doc); fz_device *idev; fz_matrix ctm; - fz_annot *annot; + pdf_annot *pannot; pdfapp_viewctm(&ctm, app); - pdf_update_page(app->ctx, idoc, (pdf_page *)app->page); + pdf_update_page(app->ctx, (pdf_page *)app->page); pdfapp_recreate_annotationslist(app); - while ((annot = (fz_annot *)pdf_poll_changed_annot(app->ctx, idoc, (pdf_page *)app->page)) != NULL) + for (pannot = pdf_first_annot(app->ctx, (pdf_page*)app->page); pannot; pannot = pdf_next_annot(app->ctx, pannot)) { - fz_rect bounds; - fz_irect ibounds; - fz_transform_rect(fz_bound_annot(app->ctx, annot, &bounds), &ctm); - fz_rect_from_irect(&bounds, fz_round_rect(&ibounds, &bounds)); - fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, &ibounds); - idev = fz_new_draw_device_with_bbox(app->ctx, NULL, app->image, &ibounds); - pdfapp_runpage(app, idev, &ctm, &bounds, NULL); - fz_close_device(app->ctx, idev); - fz_drop_device(app->ctx, idev); + if (pannot->changed) + { + fz_annot *annot = (fz_annot*)pannot; + fz_rect bounds; + fz_irect ibounds; + fz_transform_rect(fz_bound_annot(app->ctx, annot, &bounds), &ctm); + fz_rect_from_irect(&bounds, fz_round_rect(&ibounds, &bounds)); + fz_clear_pixmap_rect_with_value(app->ctx, app->image, 255, &ibounds); + idev = fz_new_draw_device_with_bbox(app->ctx, NULL, app->image, &ibounds); + pdfapp_runpage(app, idev, &ctm, &bounds, NULL); + fz_close_device(app->ctx, idev); + fz_drop_device(app->ctx, idev); + } } pdfapp_showpage(app, 0, 0, 1, 0, 0); |