summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-12-28 15:18:21 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-01-05 14:47:37 +0100
commitd5394cbcf3a98dcabc49264172d4ce6618535d91 (patch)
tree9cf89de9fa95ddc14ffdb78d2dd8ff25d7d480cd
parentcc4bd1b4f82a67f70c7ccad4da874d6e7451eeae (diff)
downloadmupdf-d5394cbcf3a98dcabc49264172d4ce6618535d91.tar.xz
Remove fz_page argument from fz_annot function calls.
-rw-r--r--include/mupdf/fitz/annotation.h4
-rw-r--r--include/mupdf/fitz/document.h25
-rw-r--r--include/mupdf/fitz/util.h2
-rw-r--r--include/mupdf/pdf/annot.h7
-rw-r--r--platform/android/jni/mupdf.c20
-rw-r--r--platform/gl/gl-main.c4
-rw-r--r--platform/ios/Classes/MuAnnotation.h4
-rw-r--r--platform/ios/Classes/MuAnnotation.m8
-rw-r--r--platform/ios/Classes/MuPageViewNormal.m12
-rw-r--r--platform/x11/pdfapp.c14
-rw-r--r--source/fitz/document.c32
-rw-r--r--source/fitz/util.c6
-rw-r--r--source/pdf/pdf-annot.c13
-rw-r--r--source/pdf/pdf-page.c3
-rw-r--r--source/pdf/pdf-run.c3
15 files changed, 90 insertions, 67 deletions
diff --git a/include/mupdf/fitz/annotation.h b/include/mupdf/fitz/annotation.h
index 122777de..82a902e6 100644
--- a/include/mupdf/fitz/annotation.h
+++ b/include/mupdf/fitz/annotation.h
@@ -52,13 +52,13 @@ fz_annot *fz_first_annot(fz_context *ctx, fz_page *page);
Does not throw exceptions.
*/
-fz_annot *fz_next_annot(fz_context *ctx, fz_page *page, fz_annot *annot);
+fz_annot *fz_next_annot(fz_context *ctx, fz_annot *annot);
/*
fz_bound_annot: Return the bounding rectangle of the annotation.
Does not throw exceptions.
*/
-fz_rect *fz_bound_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_rect *rect);
+fz_rect *fz_bound_annot(fz_context *ctx, fz_annot *annot, fz_rect *rect);
#endif
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 32f5bba6..f8e67668 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -43,15 +43,24 @@ typedef void (fz_page_drop_page_imp_fn)(fz_context *ctx, fz_page *page);
typedef fz_transition *(fz_page_page_presentation_fn)(fz_context *ctx, fz_page *page, float *duration);
typedef fz_annot *(fz_page_first_annot_fn)(fz_context *ctx, fz_page *page);
-typedef fz_annot *(fz_page_next_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot);
-typedef fz_rect *(fz_page_bound_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot, fz_rect *rect);
-typedef void (fz_page_run_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
typedef void (fz_page_control_separation_fn)(fz_context *ctx, fz_page *page, int separation, int disable);
typedef int (fz_page_separation_disabled_fn)(fz_context *ctx, fz_page *page, int separation);
typedef int (fz_page_count_separations_fn)(fz_context *ctx, fz_page *page);
typedef const char *(fz_page_get_separation_fn)(fz_context *ctx, fz_page *page, int separation, uint32_t *rgb, uint32_t *cmyk);
+typedef fz_annot *(fz_annot_next_fn)(fz_context *ctx, fz_annot *annot);
+typedef fz_rect *(fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot, fz_rect *rect);
+typedef void (fz_annot_run_fn)(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+
+struct fz_annot_s
+{
+ int refs;
+ fz_annot_bound_fn *bound_annot;
+ fz_annot_run_fn *run_annot;
+ fz_annot_next_fn *next_annot;
+};
+
struct fz_page_s
{
int refs;
@@ -60,9 +69,6 @@ struct fz_page_s
fz_page_run_page_contents_fn *run_page_contents;
fz_page_load_links_fn *load_links;
fz_page_first_annot_fn *first_annot;
- fz_page_next_annot_fn *next_annot;
- fz_page_bound_annot_fn *bound_annot;
- fz_page_run_annot_fn *run_annot;
fz_page_page_presentation_fn *page_presentation;
fz_page_control_separation_fn *control_separation;
fz_page_separation_disabled_fn *separation_disabled;
@@ -294,7 +300,7 @@ void fz_run_page_contents(fz_context *ctx, fz_page *page, fz_device *dev, const
fields inside cookie are continually updated while the page is
rendering.
*/
-void fz_run_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+void fz_run_annot(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
/*
fz_keep_page: Keep a reference to a loaded page.
@@ -311,6 +317,11 @@ fz_page *fz_keep_page(fz_context *ctx, fz_page *page);
void fz_drop_page(fz_context *ctx, fz_page *page);
/*
+ fz_new_annot: Create and initialize an annotation struct.
+*/
+void *fz_new_annot(fz_context *ctx, int size);
+
+/*
fz_page_presentation: Get the presentation details for a given page.
duration: NULL, or a pointer to a place to set the page duration in
diff --git a/include/mupdf/fitz/util.h b/include/mupdf/fitz/util.h
index 96c9e7a8..ffc13382 100644
--- a/include/mupdf/fitz/util.h
+++ b/include/mupdf/fitz/util.h
@@ -31,7 +31,7 @@ fz_pixmap *fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, cons
fz_new_pixmap_from_annot: Render an annotation to a transparent pixmap,
suitable for blending on top of the opaque pixmap returned by fz_new_pixmap_from_page_contents.
*/
-fz_pixmap *fz_new_pixmap_from_annot(fz_context *ctx, fz_page *page, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs);
+fz_pixmap *fz_new_pixmap_from_annot(fz_context *ctx, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs);
/*
fz_new_stext_page_from_page: Extract structured text from a page. The sheet must not be NULL.
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index fb9d3a69..7328be4d 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -27,14 +27,14 @@ pdf_annot *pdf_first_annot(fz_context *ctx, pdf_page *page);
Does not throw exceptions.
*/
-pdf_annot *pdf_next_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot);
+pdf_annot *pdf_next_annot(fz_context *ctx, pdf_annot *annot);
/*
pdf_bound_annot: Return the rectangle for an annotation on a page.
Does not throw exceptions.
*/
-fz_rect *pdf_bound_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_rect *rect);
+fz_rect *pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect);
/*
pdf_annot_type: Return the type of an annotation
@@ -53,10 +53,11 @@ fz_annot_type pdf_annot_type(fz_context *ctx, pdf_annot *annot);
ctm: A transformation matrix applied to the objects on the page,
e.g. to scale or rotate the page contents as desired.
*/
-void pdf_run_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
+void pdf_run_annot(fz_context *ctx, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
struct pdf_annot_s
{
+ fz_annot super;
pdf_page *page;
pdf_obj *obj;
fz_rect rect;
diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c
index e91eea70..aaade4e0 100644
--- a/platform/android/jni/mupdf.c
+++ b/platform/android/jni/mupdf.c
@@ -675,12 +675,12 @@ static void update_changed_rects(globals *glo, page_cache *pc, pdf_document *ido
{
/* FIXME: We bound the annot twice here */
rect_node *node = fz_malloc_struct(glo->ctx, rect_node);
- fz_bound_annot(ctx, pc->page, annot, &node->rect);
+ 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, pc->page, annot, &node->rect);
+ fz_bound_annot(ctx, annot, &node->rect);
node->next = pc->hq_changed_rects;
pc->hq_changed_rects = node;
}
@@ -771,8 +771,8 @@ JNI_FN(MuPDFCore_drawPage)(JNIEnv *env, jobject thiz, jobject bitmap,
fz_annot *annot;
pc->annot_list = fz_new_display_list(ctx);
dev = fz_new_list_device(ctx, pc->annot_list);
- for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, pc->page, annot))
- fz_run_annot(ctx, pc->page, annot, dev, &fz_identity, cookie);
+ for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, annot))
+ fz_run_annot(ctx, annot, dev, &fz_identity, cookie);
fz_drop_device(ctx, dev);
dev = NULL;
if (cookie != NULL && cookie->abort)
@@ -969,8 +969,8 @@ JNI_FN(MuPDFCore_updatePageInternal)(JNIEnv *env, jobject thiz, jobject bitmap,
if (pc->annot_list == NULL) {
pc->annot_list = fz_new_display_list(ctx);
dev = fz_new_list_device(ctx, pc->annot_list);
- for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, pc->page, annot))
- fz_run_annot(ctx, pc->page, annot, dev, &fz_identity, cookie);
+ for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, annot))
+ fz_run_annot(ctx, annot, dev, &fz_identity, cookie);
fz_drop_device(ctx, dev);
dev = NULL;
if (cookie != NULL && cookie->abort)
@@ -1722,7 +1722,7 @@ JNI_FN(MuPDFCore_deleteAnnotationInternal)(JNIEnv * env, jobject thiz, int annot
{
annot = fz_first_annot(ctx, pc->page);
for (i = 0; i < annot_index && annot; i++)
- annot = fz_next_annot(ctx, pc->page, annot);
+ annot = fz_next_annot(ctx, annot);
if (annot)
{
@@ -1991,18 +1991,18 @@ JNI_FN(MuPDFCore_getAnnotationsInternal)(JNIEnv * env, jobject thiz, int pageNum
fz_scale(&ctm, zoom, zoom);
count = 0;
- for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, pc->page, annot))
+ for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, annot))
count ++;
arr = (*env)->NewObjectArray(env, count, annotClass, NULL);
if (arr == NULL) return NULL;
count = 0;
- for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, pc->page, annot))
+ for (annot = fz_first_annot(ctx, pc->page); annot; annot = fz_next_annot(ctx, annot))
{
fz_rect rect;
fz_annot_type type = pdf_annot_type(ctx, (pdf_annot *)annot);
- fz_bound_annot(ctx, pc->page, annot, &rect);
+ fz_bound_annot(ctx, annot, &rect);
fz_transform_rect(&rect, &ctm);
jannot = (*env)->NewObject(env, annotClass, ctor,
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 80efbeb4..ef95246d 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -266,9 +266,9 @@ void render_page(void)
fz_drop_pixmap(ctx, pix);
annot_count = 0;
- 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))
{
- pix = fz_new_pixmap_from_annot(ctx, page, annot, &page_ctm, fz_device_rgb(ctx));
+ pix = fz_new_pixmap_from_annot(ctx, annot, &page_ctm, fz_device_rgb(ctx));
texture_from_pixmap(&annot_tex[annot_count++], pix);
fz_drop_pixmap(ctx, pix);
}
diff --git a/platform/ios/Classes/MuAnnotation.h b/platform/ios/Classes/MuAnnotation.h
index 32192dc4..a113b93f 100644
--- a/platform/ios/Classes/MuAnnotation.h
+++ b/platform/ios/Classes/MuAnnotation.h
@@ -3,8 +3,8 @@
#import <Foundation/Foundation.h>
@interface MuAnnotation : NSObject
--(id) initFromAnnot:(fz_annot *)annot forPage:(fz_page *)page;
+-(id) initFromAnnot:(fz_annot *)annot;
@property(readonly) int type;
@property(readonly) CGRect rect;
-+(MuAnnotation *) annotFromAnnot:(fz_annot *)annot forPage:(fz_page *)page;
++(MuAnnotation *) annotFromAnnot:(fz_annot *)annot;
@end
diff --git a/platform/ios/Classes/MuAnnotation.m b/platform/ios/Classes/MuAnnotation.m
index 89cc9d48..f13dedd7 100644
--- a/platform/ios/Classes/MuAnnotation.m
+++ b/platform/ios/Classes/MuAnnotation.m
@@ -8,14 +8,14 @@
@synthesize type, rect;
--(id) initFromAnnot:(fz_annot *)annot forPage:(fz_page *)page;
+-(id) initFromAnnot:(fz_annot *)annot;
{
self = [super init];
if (self)
{
fz_rect frect;
type = pdf_annot_type(ctx, (pdf_annot *)annot);
- fz_bound_annot(ctx, page, annot, &frect);
+ fz_bound_annot(ctx, annot, &frect);
rect.origin.x = frect.x0;
rect.origin.y = frect.y0;
rect.size.width = frect.x1 - frect.x0;
@@ -24,8 +24,8 @@
return self;
}
-+(MuAnnotation *) annotFromAnnot:(fz_annot *)annot forPage:(fz_page *)page;
++(MuAnnotation *) annotFromAnnot:(fz_annot *)annot;
{
- return [[[MuAnnotation alloc] initFromAnnot:annot forPage:page] autorelease];
+ return [[[MuAnnotation alloc] initFromAnnot:annot] autorelease];
}
@end
diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m
index f82c3413..e84d1767 100644
--- a/platform/ios/Classes/MuPageViewNormal.m
+++ b/platform/ios/Classes/MuPageViewNormal.m
@@ -48,8 +48,8 @@ static NSArray *enumerateAnnotations(fz_document *doc, fz_page *page)
fz_annot *annot;
NSMutableArray *arr = [NSMutableArray arrayWithCapacity:10];
- for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, page, annot))
- [arr addObject:[MuAnnotation annotFromAnnot:annot forPage:page]];
+ for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, annot))
+ [arr addObject:[MuAnnotation annotFromAnnot:annot]];
return [arr retain];
}
@@ -305,7 +305,7 @@ static void deleteAnnotation(fz_document *doc, fz_page *page, int index)
int i;
fz_annot *annot = fz_first_annot(ctx, page);
for (i = 0; i < index && annot; i++)
- annot = fz_next_annot(ctx, page, annot);
+ annot = fz_next_annot(ctx, annot);
if (annot)
pdf_delete_annot(ctx, idoc, (pdf_page *)page, (pdf_annot *)annot);
@@ -408,8 +408,8 @@ static fz_display_list *create_annot_list(fz_document *doc, fz_page *page)
pdf_update_page(ctx, idoc, (pdf_page *)page);
list = fz_new_display_list(ctx);
dev = fz_new_list_device(ctx, list);
- for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, page, annot))
- fz_run_annot(ctx, page, annot, dev, &fz_identity, NULL);
+ for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, annot))
+ fz_run_annot(ctx, annot, dev, &fz_identity, NULL);
}
fz_always(ctx)
{
@@ -508,7 +508,7 @@ static rect_list *updatePage(fz_document *doc, fz_page *page)
{
rect_list *node = fz_malloc_struct(ctx, rect_list);
- fz_bound_annot(ctx, page, annot, &node->rect);
+ fz_bound_annot(ctx, annot, &node->rect);
node->next = list;
list = node;
}
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index 491167b2..6b227ab3 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -711,8 +711,8 @@ static void pdfapp_loadpage(pdfapp_t *app, int no_cache)
mdev = NULL;
app->annotations_list = fz_new_display_list(app->ctx);
mdev = fz_new_list_device(app->ctx, app->annotations_list);
- for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, app->page, annot))
- fz_run_annot(app->ctx, app->page, annot, mdev, &fz_identity, &cookie);
+ for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
+ fz_run_annot(app->ctx, annot, mdev, &fz_identity, &cookie);
if (cookie.incomplete)
{
app->incomplete = 1;
@@ -771,8 +771,8 @@ static void pdfapp_recreate_annotationslist(pdfapp_t *app)
/* Create display list */
app->annotations_list = fz_new_display_list(app->ctx);
mdev = fz_new_list_device(app->ctx, app->annotations_list);
- for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, app->page, annot))
- fz_run_annot(app->ctx, app->page, annot, mdev, &fz_identity, &cookie);
+ for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
+ fz_run_annot(app->ctx, annot, mdev, &fz_identity, &cookie);
if (cookie.incomplete)
{
app->incomplete = 1;
@@ -824,7 +824,7 @@ static void pdfapp_updatepage(pdfapp_t *app)
{
fz_rect bounds;
fz_irect ibounds;
- fz_transform_rect(fz_bound_annot(app->ctx, app->page, annot, &bounds), &ctm);
+ 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, app->image, &ibounds);
@@ -1743,10 +1743,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
else
{
fz_annot *annot;
- for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, app->page, annot))
+ for (annot = fz_first_annot(app->ctx, app->page); annot; annot = fz_next_annot(app->ctx, annot))
{
fz_rect rect;
- fz_bound_annot(app->ctx, app->page, annot, &rect);
+ fz_bound_annot(app->ctx, annot, &rect);
if (x >= rect.x0 && x < rect.x1)
if (y >= rect.y0 && y < rect.y1)
break;
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)
{
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index 3718c20a..bfdfe306 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -503,9 +503,14 @@ pdf_load_annots(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_obj *ann
for (i = 0; i < len; i++)
{
obj = pdf_array_get(ctx, annots, i);
- annot = fz_malloc_struct(ctx, pdf_annot);
- annot->obj = pdf_keep_obj(ctx, obj);
+
+ annot = fz_new_annot(ctx, sizeof(pdf_annot));
+ annot->super.bound_annot = (fz_annot_bound_fn*)pdf_bound_annot;
+ annot->super.run_annot = (fz_annot_run_fn*)pdf_run_annot;
+ annot->super.next_annot = (fz_annot_next_fn*)pdf_next_annot;
+
annot->page = page;
+ annot->obj = pdf_keep_obj(ctx, obj);
annot->next = NULL;
*itr = annot;
@@ -613,13 +618,13 @@ pdf_first_annot(fz_context *ctx, pdf_page *page)
}
pdf_annot *
-pdf_next_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot)
+pdf_next_annot(fz_context *ctx, pdf_annot *annot)
{
return annot ? annot->next : NULL;
}
fz_rect *
-pdf_bound_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_rect *rect)
+pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect)
{
if (rect == NULL)
return NULL;
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index c7ef3422..d763b8c8 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -436,10 +436,7 @@ pdf_new_page(fz_context *ctx, pdf_document *doc)
page->super.load_links = (fz_page_load_links_fn *)pdf_load_links;
page->super.bound_page = (fz_page_bound_page_fn *)pdf_bound_page;
page->super.first_annot = (fz_page_first_annot_fn *)pdf_first_annot;
- page->super.next_annot = (fz_page_next_annot_fn *)pdf_next_annot;
- page->super.bound_annot = (fz_page_bound_annot_fn *)pdf_bound_annot;
page->super.run_page_contents = (fz_page_run_page_contents_fn *)pdf_run_page_contents;
- page->super.run_annot = (fz_page_run_annot_fn *)pdf_run_annot;
page->super.page_presentation = (fz_page_page_presentation_fn *)pdf_page_presentation;
page->resources = NULL;
diff --git a/source/pdf/pdf-run.c b/source/pdf/pdf-run.c
index 65460e2a..e84604fb 100644
--- a/source/pdf/pdf-run.c
+++ b/source/pdf/pdf-run.c
@@ -69,8 +69,9 @@ void pdf_run_page_contents(fz_context *ctx, pdf_page *page, fz_device *dev, cons
fz_throw(ctx, FZ_ERROR_TRYLATER, "incomplete rendering");
}
-void pdf_run_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
+void pdf_run_annot(fz_context *ctx, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie)
{
+ pdf_page *page = annot->page;
pdf_document *doc = page->doc;
int nocache;