From f0d9d28a034fe3650c3c2d662090c1e8687ddb16 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 30 May 2018 16:40:00 +0000 Subject: Make CPDF_Document cache CPDF_Pages We cache pages not by page number, which can bounce around as pages are inserted or removed, but by page dictionary's object number. Since the page may be created under one function and used under another, we can't take the shortcut of not instantiating a render cache nor not parsing the page. Change-Id: I9a325cda8b3141153544ac53e78a51a44e6b411a Reviewed-on: https://pdfium-review.googlesource.com/32830 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_document.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/parser/cpdf_document.h') diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h index c2774b163a..c240e77567 100644 --- a/core/fpdfapi/parser/cpdf_document.h +++ b/core/fpdfapi/parser/cpdf_document.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_PARSER_CPDF_DOCUMENT_H_ #include +#include #include #include #include @@ -64,6 +65,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { const CPDF_Dictionary* GetInfo() const { return m_pInfoDict.Get(); } CPDF_Dictionary* GetInfo() { return m_pInfoDict.Get(); } + RetainPtr GetOrCreatePDFPage(CPDF_Dictionary* pPageDict); void DeletePage(int iPage); int GetPageCount() const; bool IsPageLoaded(int iPage) const; @@ -167,7 +169,13 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { std::unique_ptr m_pDocRender; std::unique_ptr m_pCodecContext; std::unique_ptr m_pLinksContext; - std::vector m_PageList; // Page number to page's dict objnum. + + // Page number (index) to page's dict objnum. + std::vector m_PageList; + + // Dict {objnum, gennum} to page mapping. + std::map, CPDF_Page::ObservedPtr> m_PageMap; + UnownedPtr m_pExtension; }; -- cgit v1.2.3