diff options
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/document.c | 32 | ||||
-rw-r--r-- | source/fitz/util.c | 6 |
2 files changed, 23 insertions, 15 deletions
diff --git a/source/fitz/document.c b/source/fitz/document.c index 61d3091e..abcbfd9c 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -275,18 +275,18 @@ fz_first_annot(fz_context *ctx, fz_page *page) } fz_annot * -fz_next_annot(fz_context *ctx, fz_page *page, fz_annot *annot) +fz_next_annot(fz_context *ctx, fz_annot *annot) { - if (page && page->next_annot && annot) - return page->next_annot(ctx, page, annot); + if (annot && annot->next_annot) + return annot->next_annot(ctx, annot); return NULL; } fz_rect * -fz_bound_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_rect *rect) +fz_bound_annot(fz_context *ctx, fz_annot *annot, fz_rect *rect) { - if (page && page->bound_annot && annot && rect) - return page->bound_annot(ctx, page, annot, rect); + if (annot && annot->bound_annot && rect) + return annot->bound_annot(ctx, annot, rect); if (rect) *rect = fz_empty_rect; return rect; @@ -310,13 +310,13 @@ fz_run_page_contents(fz_context *ctx, fz_page *page, fz_device *dev, const fz_ma } void -fz_run_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie) +fz_run_annot(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie) { - if (page && page->run_annot && page && annot) + if (annot && annot->run_annot) { fz_try(ctx) { - page->run_annot(ctx, page, annot, dev, transform, cookie); + annot->run_annot(ctx, annot, dev, transform, cookie); } fz_catch(ctx) { @@ -340,12 +340,12 @@ fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *tra if (cookie && cookie->progress_max != -1) { int count = 1; - for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, page, annot)) + for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, annot)) count++; cookie->progress_max += count; } - for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, page, annot)) + for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, annot)) { /* Check the cookie for aborting */ if (cookie) @@ -355,13 +355,21 @@ fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *tra cookie->progress++; } - fz_run_annot(ctx, page, annot, dev, transform, cookie); + fz_run_annot(ctx, annot, dev, transform, cookie); } fz_end_page(ctx, dev); } void * +fz_new_annot(fz_context *ctx, int size) +{ + fz_page *page = Memento_label(fz_calloc(ctx, 1, size), "fz_annot"); + page->refs = 1; + return page; +} + +void * fz_new_page(fz_context *ctx, int size) { fz_page *page = Memento_label(fz_calloc(ctx, 1, size), "fz_page"); diff --git a/source/fitz/util.c b/source/fitz/util.c index 54e5754d..0d782ba8 100644 --- a/source/fitz/util.c +++ b/source/fitz/util.c @@ -112,14 +112,14 @@ fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, const fz_matrix } fz_pixmap * -fz_new_pixmap_from_annot(fz_context *ctx, fz_page *page, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs) +fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs) { fz_rect rect; fz_irect irect; fz_pixmap *pix; fz_device *dev; - fz_bound_annot(ctx, page, annot, &rect); + fz_bound_annot(ctx, annot, &rect); fz_transform_rect(&rect, ctm); fz_round_rect(&irect, &rect); @@ -129,7 +129,7 @@ fz_new_pixmap_from_annot(fz_context *ctx, fz_page *page, fz_annot *annot, const fz_try(ctx) { dev = fz_new_draw_device(ctx, pix); - fz_run_annot(ctx, page, annot, dev, ctm, NULL); + fz_run_annot(ctx, annot, dev, ctm, NULL); } fz_always(ctx) { |