summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-02-23 15:11:08 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-03-01 15:22:46 +0100
commit53f816f2f06de5aeb13cac72232c4f52714201cb (patch)
tree924eccc6f31db7564ab434a3491b27c7d572eed3 /include
parent8c547d302fb23950bc3f928a37d4c8baf93838cc (diff)
downloadmupdf-53f816f2f06de5aeb13cac72232c4f52714201cb.tar.xz
Add page lookup cache for faster link destination lookups in outlines.
Loading outlines wants to look up all link destinations, and doing the normal link destination lookups triggers loading all page objects used. This means we need to parse a lot of objects, which can be quite slow. We can load the page tree faster by only looking at intermediate page tree nodes. If we load the page tree and create a reverse lookup table for use when loading the outline, we can speed up the time to run 'mutool show pdfref17.pdf outline' from 900ms to 100ms.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/pdf/document.h8
-rw-r--r--include/mupdf/pdf/page.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index a84ee872..177f947c 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -549,6 +549,13 @@ struct pdf_unsaved_sig_s
pdf_unsaved_sig *next;
};
+typedef struct pdf_rev_page_map_s pdf_rev_page_map;
+struct pdf_rev_page_map_s
+{
+ int page;
+ int object;
+};
+
struct pdf_document_s
{
fz_document super;
@@ -576,6 +583,7 @@ struct pdf_document_s
int has_xref_streams;
int page_count;
+ pdf_rev_page_map *rev_page_map;
int repair_attempted;
diff --git a/include/mupdf/pdf/page.h b/include/mupdf/pdf/page.h
index f86d54cc..52d2a4ad 100644
--- a/include/mupdf/pdf/page.h
+++ b/include/mupdf/pdf/page.h
@@ -4,6 +4,8 @@
int pdf_lookup_page_number(fz_context *ctx, pdf_document *doc, pdf_obj *pageobj);
int pdf_count_pages(fz_context *ctx, pdf_document *doc);
pdf_obj *pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle);
+void pdf_load_page_tree(fz_context *ctx, pdf_document *doc);
+void pdf_drop_page_tree(fz_context *ctx, pdf_document *doc);
/*
pdf_lookup_anchor: Find the page number of a named destination.