diff options
author | weili <weili@chromium.org> | 2016-07-24 08:08:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-24 08:08:24 -0700 |
commit | 9f515bcccb40e8ae251bbe8afc1ef6c4db1f05a8 (patch) | |
tree | 83db93367d20abf65f8b4eb459f54d9f60a05732 | |
parent | 8f19e4bc617d19e871137be55a34992e421585ad (diff) | |
download | pdfium-9f515bcccb40e8ae251bbe8afc1ef6c4db1f05a8.tar.xz |
Use actual type instead CFX_Deletable
Change two places that used CFX_Deletable to use actual types. This makes
the type more obvious, and avoids unnecessary casts.
Review-Url: https://codereview.chromium.org/2180443002
-rw-r--r-- | BUILD.gn | 5 | ||||
-rw-r--r-- | core/fpdfapi/cpdf_pagerendercontext.cpp | 21 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_page.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/include/cpdf_page.h | 9 | ||||
-rw-r--r-- | core/fpdfapi/include/cpdf_modulemgr.h | 18 | ||||
-rw-r--r-- | core/fpdfapi/include/cpdf_pagerendercontext.h | 31 | ||||
-rw-r--r-- | fpdfsdk/fpdf_ext.cpp | 31 | ||||
-rw-r--r-- | fpdfsdk/fpdf_progressive.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 48 | ||||
-rw-r--r-- | fpdfsdk/fsdk_pauseadapter.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/fsdk_rendercontext.cpp | 37 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_define.h | 4 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_pauseadapter.h | 25 | ||||
-rw-r--r-- | fpdfsdk/include/fsdk_rendercontext.h | 41 | ||||
-rw-r--r-- | pdfium.gyp | 5 |
15 files changed, 171 insertions, 144 deletions
@@ -80,11 +80,12 @@ static_library("pdfium") { "fpdfsdk/fsdk_baseannot.cpp", "fpdfsdk/fsdk_baseform.cpp", "fpdfsdk/fsdk_mgr.cpp", - "fpdfsdk/fsdk_rendercontext.cpp", + "fpdfsdk/fsdk_pauseadapter.cpp", "fpdfsdk/include/fsdk_actionhandler.h", "fpdfsdk/include/fsdk_annothandler.h", "fpdfsdk/include/fsdk_baseannot.h", "fpdfsdk/include/fsdk_baseform.h", + "fpdfsdk/include/fsdk_pauseadapter.h", "public/fpdf_dataavail.h", "public/fpdf_doc.h", "public/fpdf_edit.h", @@ -253,6 +254,7 @@ static_library("fpdfdoc") { static_library("fpdfapi") { sources = [ "core/fpdfapi/cpdf_modulemgr.cpp", + "core/fpdfapi/cpdf_pagerendercontext.cpp", "core/fpdfapi/fpdf_cmaps/CNS1/Adobe-CNS1-UCS2_5.cpp", "core/fpdfapi/fpdf_cmaps/CNS1/B5pc-H_0.cpp", "core/fpdfapi/fpdf_cmaps/CNS1/B5pc-V_0.cpp", @@ -472,6 +474,7 @@ static_library("fpdfapi") { "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h", "core/fpdfapi/fpdf_render/render_int.h", "core/fpdfapi/include/cpdf_modulemgr.h", + "core/fpdfapi/include/cpdf_pagerendercontext.h", ] configs += [ ":pdfium_core_config" ] } diff --git a/core/fpdfapi/cpdf_pagerendercontext.cpp b/core/fpdfapi/cpdf_pagerendercontext.cpp new file mode 100644 index 0000000000..04ae3a8e33 --- /dev/null +++ b/core/fpdfapi/cpdf_pagerendercontext.cpp @@ -0,0 +1,21 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "core/fpdfapi/include/cpdf_pagerendercontext.h" + +#include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" +#include "core/fpdfapi/fpdf_render/include/cpdf_rendercontext.h" +#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" +#include "core/fpdfdoc/cpdf_annotlist.h" +#include "core/fpdfdoc/include/fpdf_doc.h" +#include "core/fxge/include/fx_ge.h" + +CPDF_PageRenderContext::CPDF_PageRenderContext() {} + +CPDF_PageRenderContext::~CPDF_PageRenderContext() { + if (m_pOptions) + delete m_pOptions->m_pOCContext; +} diff --git a/core/fpdfapi/fpdf_page/cpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_page.cpp index 441bbfe28b..289ef717c4 100644 --- a/core/fpdfapi/fpdf_page/cpdf_page.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_page.cpp @@ -14,6 +14,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" +#include "core/fpdfapi/include/cpdf_pagerendercontext.h" #include "third_party/base/stl_util.h" CPDF_Page::CPDF_Page(CPDF_Document* pDocument, @@ -95,6 +96,11 @@ void CPDF_Page::ParseContent() { ContinueParse(nullptr); } +void CPDF_Page::SetRenderContext( + std::unique_ptr<CPDF_PageRenderContext> pContext) { + m_pRenderContext = std::move(pContext); +} + CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const { CPDF_Dictionary* pPageDict = m_pFormDict; std::set<CPDF_Dictionary*> visited; diff --git a/core/fpdfapi/fpdf_page/include/cpdf_page.h b/core/fpdfapi/fpdf_page/include/cpdf_page.h index e73c41db79..5be82d5451 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_page.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_page.h @@ -18,6 +18,7 @@ class CPDF_Dictionary; class CPDF_Document; class CPDF_Object; class CPDF_PageRenderCache; +class CPDF_PageRenderContext; class CPDF_Page : public CPDF_PageObjectHolder { public: @@ -44,10 +45,10 @@ class CPDF_Page : public CPDF_PageObjectHolder { CPDF_Object* GetPageAttr(const CFX_ByteString& name) const; CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); } - CFX_Deletable* GetRenderContext() const { return m_pRenderContext.get(); } - void SetRenderContext(std::unique_ptr<CFX_Deletable> pContext) { - m_pRenderContext = std::move(pContext); + CPDF_PageRenderContext* GetRenderContext() const { + return m_pRenderContext.get(); } + void SetRenderContext(std::unique_ptr<CPDF_PageRenderContext> pContext); View* GetView() const { return m_pView; } void SetView(View* pView) { m_pView = pView; } @@ -62,7 +63,7 @@ class CPDF_Page : public CPDF_PageObjectHolder { CFX_Matrix m_PageMatrix; View* m_pView; std::unique_ptr<CPDF_PageRenderCache> m_pPageRender; - std::unique_ptr<CFX_Deletable> m_pRenderContext; + std::unique_ptr<CPDF_PageRenderContext> m_pRenderContext; }; #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_ diff --git a/core/fpdfapi/include/cpdf_modulemgr.h b/core/fpdfapi/include/cpdf_modulemgr.h index 95c5385e64..6e00385480 100644 --- a/core/fpdfapi/include/cpdf_modulemgr.h +++ b/core/fpdfapi/include/cpdf_modulemgr.h @@ -20,6 +20,17 @@ class CCodec_JpxModule; class CCodec_ModuleMgr; class CPDF_PageModule; +class CFSDK_UnsupportInfo_Adapter { + public: + explicit CFSDK_UnsupportInfo_Adapter(void* unsp_info) + : m_unsp_info(unsp_info) {} + + void* GetUnspInfo() const { return m_unsp_info; } + + private: + void* const m_unsp_info; +}; + class CPDF_ModuleMgr { public: static CPDF_ModuleMgr* Get(); @@ -33,10 +44,11 @@ class CPDF_ModuleMgr { void InitPageModule(); CPDF_PageModule* GetPageModule() const { return m_pPageModule.get(); } - void SetUnsupportInfoAdapter(std::unique_ptr<CFX_Deletable> pAdapter) { + void SetUnsupportInfoAdapter( + std::unique_ptr<CFSDK_UnsupportInfo_Adapter> pAdapter) { m_pUnsupportInfoAdapter = std::move(pAdapter); } - CFX_Deletable* GetUnsupportInfoAdapter() const { + CFSDK_UnsupportInfo_Adapter* GetUnsupportInfoAdapter() const { return m_pUnsupportInfoAdapter.get(); } @@ -58,7 +70,7 @@ class CPDF_ModuleMgr { CCodec_ModuleMgr* m_pCodecModule; std::unique_ptr<CPDF_PageModule> m_pPageModule; - std::unique_ptr<CFX_Deletable> m_pUnsupportInfoAdapter; + std::unique_ptr<CFSDK_UnsupportInfo_Adapter> m_pUnsupportInfoAdapter; }; #endif // CORE_FPDFAPI_INCLUDE_CPDF_MODULEMGR_H_ diff --git a/core/fpdfapi/include/cpdf_pagerendercontext.h b/core/fpdfapi/include/cpdf_pagerendercontext.h new file mode 100644 index 0000000000..2ee3daeda3 --- /dev/null +++ b/core/fpdfapi/include/cpdf_pagerendercontext.h @@ -0,0 +1,31 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFAPI_INCLUDE_CPDF_PAGERENDERCONTEXT_H_ +#define CORE_FPDFAPI_INCLUDE_CPDF_PAGERENDERCONTEXT_H_ + +#include <memory> + +class CFX_RenderDevice; +class CPDF_AnnotList; +class CPDF_ProgressiveRenderer; +class CPDF_RenderContext; +class CPDF_RenderOptions; + +// Everything about rendering is put here: for OOM recovery +class CPDF_PageRenderContext { + public: + CPDF_PageRenderContext(); + ~CPDF_PageRenderContext(); + + std::unique_ptr<CFX_RenderDevice> m_pDevice; + std::unique_ptr<CPDF_RenderContext> m_pContext; + std::unique_ptr<CPDF_ProgressiveRenderer> m_pRenderer; + std::unique_ptr<CPDF_AnnotList> m_pAnnots; + std::unique_ptr<CPDF_RenderOptions> m_pOptions; +}; + +#endif // CORE_FPDFAPI_INCLUDE_CPDF_PAGERENDERCONTEXT_H_ diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp index d262e3c0a5..bb2c9ff0a5 100644 --- a/fpdfsdk/fpdf_ext.cpp +++ b/fpdfsdk/fpdf_ext.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" #include "core/fxcrt/include/fx_basic.h" +#include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_xml.h" #include "fpdfsdk/include/fsdk_define.h" @@ -19,33 +20,15 @@ #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" #endif // PDF_ENABLE_XFA -#define FPDFSDK_UNSUPPORT_CALL 100 - -class CFSDK_UnsupportInfo_Adapter : public CFX_Deletable { - public: - explicit CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) - : m_unsp_info(unsp_info) {} - - void ReportError(int nErrorType); - - private: - UNSUPPORT_INFO* const m_unsp_info; -}; - -void CFSDK_UnsupportInfo_Adapter::ReportError(int nErrorType) { - if (m_unsp_info && m_unsp_info->FSDK_UnSupport_Handler) { - m_unsp_info->FSDK_UnSupport_Handler(m_unsp_info, nErrorType); - } -} - FX_BOOL FPDF_UnSupportError(int nError) { CFSDK_UnsupportInfo_Adapter* pAdapter = - static_cast<CFSDK_UnsupportInfo_Adapter*>( - CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter()); + CPDF_ModuleMgr::Get()->GetUnsupportInfoAdapter(); if (!pAdapter) return FALSE; - pAdapter->ReportError(nError); + UNSUPPORT_INFO* info = static_cast<UNSUPPORT_INFO*>(pAdapter->GetUnspInfo()); + if (info && info->FSDK_UnSupport_Handler) + info->FSDK_UnSupport_Handler(info, nError); return TRUE; } @@ -54,8 +37,8 @@ FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info) { if (!unsp_info || unsp_info->version != 1) return FALSE; - CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter(std::unique_ptr<CFX_Deletable>( - new CFSDK_UnsupportInfo_Adapter(unsp_info))); + CPDF_ModuleMgr::Get()->SetUnsupportInfoAdapter( + WrapUnique(new CFSDK_UnsupportInfo_Adapter(unsp_info))); return TRUE; } diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp index efde1eb029..2912e8b6c3 100644 --- a/fpdfsdk/fpdf_progressive.cpp +++ b/fpdfsdk/fpdf_progressive.cpp @@ -8,9 +8,11 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" +#include "core/fpdfapi/include/cpdf_pagerendercontext.h" +#include "core/fxcrt/include/fx_memory.h" #include "core/fxge/include/fx_ge.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/fsdk_rendercontext.h" +#include "fpdfsdk/include/fsdk_pauseadapter.h" #include "public/fpdfview.h" // These checks are here because core/ and public/ cannot depend on each other. @@ -40,10 +42,10 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, if (!pPage) return FPDF_RENDER_FAILED; - CRenderContext* pContext = new CRenderContext; - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); + CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; + pPage->SetRenderContext(WrapUnique(pContext)); CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; - pContext->m_pDevice = pDevice; + pContext->m_pDevice.reset(pDevice); CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); @@ -67,8 +69,7 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, if (!pPage) return FPDF_RENDER_FAILED; - CRenderContext* pContext = - static_cast<CRenderContext*>(pPage->GetRenderContext()); + CPDF_PageRenderContext* pContext = pPage->GetRenderContext(); if (pContext && pContext->m_pRenderer) { IFSDK_PAUSE_Adapter IPauseAdapter(pause); pContext->m_pRenderer->Continue(&IPauseAdapter); @@ -83,11 +84,10 @@ DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { if (!pPage) return; - CRenderContext* pContext = - static_cast<CRenderContext*>(pPage->GetRenderContext()); + CPDF_PageRenderContext* pContext = pPage->GetRenderContext(); if (!pContext) return; pContext->m_pDevice->RestoreState(false); - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); + pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>()); } diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index f47de1518d..6a70df5367 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -11,14 +11,17 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" +#include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" #include "core/fpdfapi/include/cpdf_modulemgr.h" +#include "core/fpdfapi/include/cpdf_pagerendercontext.h" #include "core/fxcodec/include/fx_codec.h" +#include "core/fxcrt/include/fx_memory.h" #include "core/fxcrt/include/fx_safe_types.h" #include "core/fxge/include/fx_ge.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/fsdk_rendercontext.h" +#include "fpdfsdk/include/fsdk_pauseadapter.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_ext.h" #include "public/fpdf_progressive.h" @@ -562,8 +565,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, if (!pPage) return; - CRenderContext* pContext = new CRenderContext; - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); + CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; + pPage->SetRenderContext(WrapUnique(pContext)); CFX_DIBitmap* pBitmap = nullptr; FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); @@ -573,10 +576,10 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, pBitmap->Create(size_x, size_y, FXDIB_Argb); pBitmap->Clear(0x00ffffff); CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; - pContext->m_pDevice = pDevice; + pContext->m_pDevice.reset(pDevice); pDevice->Attach(pBitmap, false, nullptr, false); } else { - pContext->m_pDevice = new CFX_WindowsDevice(dc); + pContext->m_pDevice.reset(new CFX_WindowsDevice(dc)); } FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, @@ -603,7 +606,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, if (bBackgroundAlphaNeeded || bHasImageMask) delete pBitmap; - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); + pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>()); } #endif // defined(_WIN32) @@ -622,17 +625,17 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, if (!pPage) return; - CRenderContext* pContext = new CRenderContext; - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); + CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; + pPage->SetRenderContext(WrapUnique(pContext)); CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; - pContext->m_pDevice = pDevice; + pContext->m_pDevice.reset(pDevice); CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, rotate, flags, TRUE, nullptr); - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); + pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>()); } #ifdef _SKIA_SUPPORT_ @@ -643,14 +646,14 @@ DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, if (!pPage) return nullptr; - CRenderContext* pContext = new CRenderContext; - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); + CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; + pPage->SetRenderContext(WrapUnique(pContext)); CFX_FxgeDevice* skDevice = new CFX_FxgeDevice; FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); - pContext->m_pDevice = skDevice; + pContext->m_pDevice.reset(skDevice); FPDF_RenderPage_Retail(pContext, page, 0, 0, size_x, size_y, 0, 0, TRUE, nullptr); - pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); + pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>()); return recorder; } #endif @@ -827,7 +830,7 @@ DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { delete CFXBitmapFromFPDFBitmap(bitmap); } -void FPDF_RenderPage_Retail(CRenderContext* pContext, +void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext, FPDF_PAGE page, int start_x, int start_y, @@ -842,7 +845,7 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, return; if (!pContext->m_pOptions) - pContext->m_pOptions = new CPDF_RenderOptions; + pContext->m_pOptions.reset(new CPDF_RenderOptions); if (flags & FPDF_LCD_TEXT) pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; @@ -881,18 +884,19 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, pContext->m_pDevice->SetClip_Rect( FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y)); - pContext->m_pContext = new CPDF_RenderContext(pPage); + pContext->m_pContext.reset(new CPDF_RenderContext(pPage)); pContext->m_pContext->AppendLayer(pPage, &matrix); if (flags & FPDF_ANNOT) { - pContext->m_pAnnots = new CPDF_AnnotList(pPage); + pContext->m_pAnnots.reset(new CPDF_AnnotList(pPage)); FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY; - pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrinting, - &matrix, TRUE, nullptr); + pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext.get(), + bPrinting, &matrix, TRUE, nullptr); } - pContext->m_pRenderer = new CPDF_ProgressiveRenderer( - pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); + pContext->m_pRenderer.reset(new CPDF_ProgressiveRenderer( + pContext->m_pContext.get(), pContext->m_pDevice.get(), + pContext->m_pOptions.get())); pContext->m_pRenderer->Start(pause); if (bNeedToRestore) pContext->m_pDevice->RestoreState(false); diff --git a/fpdfsdk/fsdk_pauseadapter.cpp b/fpdfsdk/fsdk_pauseadapter.cpp new file mode 100644 index 0000000000..067177b5e9 --- /dev/null +++ b/fpdfsdk/fsdk_pauseadapter.cpp @@ -0,0 +1,16 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/include/fsdk_pauseadapter.h" + +IFSDK_PAUSE_Adapter::IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause) + : m_IPause(IPause) {} + +IFSDK_PAUSE_Adapter::~IFSDK_PAUSE_Adapter() {} + +FX_BOOL IFSDK_PAUSE_Adapter::NeedToPauseNow() { + return m_IPause->NeedToPauseNow && m_IPause->NeedToPauseNow(m_IPause); +} diff --git a/fpdfsdk/fsdk_rendercontext.cpp b/fpdfsdk/fsdk_rendercontext.cpp deleted file mode 100644 index 0888d6ba4a..0000000000 --- a/fpdfsdk/fsdk_rendercontext.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "fpdfsdk/include/fsdk_rendercontext.h" - -#include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" -#include "core/fxge/include/fx_ge.h" - -void CRenderContext::Clear() { - m_pDevice = nullptr; - m_pContext = nullptr; - m_pRenderer = nullptr; - m_pAnnots = nullptr; - m_pOptions = nullptr; -} - -CRenderContext::~CRenderContext() { - delete m_pRenderer; - delete m_pContext; - delete m_pDevice; - delete m_pAnnots; - delete m_pOptions->m_pOCContext; - delete m_pOptions; -} - -IFSDK_PAUSE_Adapter::IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause) { - m_IPause = IPause; -} - -IFSDK_PAUSE_Adapter::~IFSDK_PAUSE_Adapter() {} - -FX_BOOL IFSDK_PAUSE_Adapter::NeedToPauseNow() { - return m_IPause->NeedToPauseNow && m_IPause->NeedToPauseNow(m_IPause); -} diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 89c3e739a7..fe221c9d7d 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -31,7 +31,7 @@ ((uint32_t)rgb & 0x0000FF00) | (((uint32_t)rgb & 0x00FF0000) >> 16)) typedef unsigned int FX_UINT; -class CRenderContext; +class CPDF_PageRenderContext; class IFSDK_PAUSE_Adapter; class CPDF_CustomAccess final : public IFX_FileRead { @@ -112,7 +112,7 @@ CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap); void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); -void FPDF_RenderPage_Retail(CRenderContext* pContext, +void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext, FPDF_PAGE page, int start_x, int start_y, diff --git a/fpdfsdk/include/fsdk_pauseadapter.h b/fpdfsdk/include/fsdk_pauseadapter.h new file mode 100644 index 0000000000..793e8f2772 --- /dev/null +++ b/fpdfsdk/include/fsdk_pauseadapter.h @@ -0,0 +1,25 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_INCLUDE_FSDK_PAUSEADAPTER_H_ +#define FPDFSDK_INCLUDE_FSDK_PAUSEADAPTER_H_ + +#include "core/fxcrt/include/fx_basic.h" +#include "core/fxcrt/include/fx_system.h" +#include "public/fpdf_progressive.h" + +class IFSDK_PAUSE_Adapter : public IFX_Pause { + public: + explicit IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause); + ~IFSDK_PAUSE_Adapter() override; + + FX_BOOL NeedToPauseNow() override; + + private: + IFSDK_PAUSE* const m_IPause; +}; + +#endif // FPDFSDK_INCLUDE_FSDK_PAUSEADAPTER_H_ diff --git a/fpdfsdk/include/fsdk_rendercontext.h b/fpdfsdk/include/fsdk_rendercontext.h deleted file mode 100644 index c2ae45eef5..0000000000 --- a/fpdfsdk/include/fsdk_rendercontext.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FPDFSDK_INCLUDE_FSDK_RENDERCONTEXT_H_ -#define FPDFSDK_INCLUDE_FSDK_RENDERCONTEXT_H_ - -#include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" -#include "core/fxcrt/include/fx_basic.h" -#include "fpdfsdk/include/fsdk_define.h" -#include "public/fpdf_progressive.h" - -// Everything about rendering is put here: for OOM recovery -class CRenderContext : public CFX_Deletable { - public: - CRenderContext() { Clear(); } - ~CRenderContext() override; - - void Clear(); - - CFX_RenderDevice* m_pDevice; - CPDF_RenderContext* m_pContext; - CPDF_ProgressiveRenderer* m_pRenderer; - CPDF_AnnotList* m_pAnnots; - CPDF_RenderOptions* m_pOptions; -}; - -class IFSDK_PAUSE_Adapter : public IFX_Pause { - public: - explicit IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause); - ~IFSDK_PAUSE_Adapter() override; - - FX_BOOL NeedToPauseNow() override; - - private: - IFSDK_PAUSE* m_IPause; -}; - -#endif // FPDFSDK_INCLUDE_FSDK_RENDERCONTEXT_H_ diff --git a/pdfium.gyp b/pdfium.gyp index 05972f2073..21b63aa1a2 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -86,6 +86,7 @@ 'fpdfsdk/include/fsdk_annothandler.h', 'fpdfsdk/include/fsdk_baseannot.h', 'fpdfsdk/include/fsdk_baseform.h', + 'fpdfsdk/include/fsdk_pauseadapter.h', 'fpdfsdk/fpdfdoc.cpp', 'fpdfsdk/fpdfeditimg.cpp', 'fpdfsdk/fpdfeditpage.cpp', @@ -106,7 +107,7 @@ 'fpdfsdk/fsdk_baseannot.cpp', 'fpdfsdk/fsdk_baseform.cpp', 'fpdfsdk/fsdk_mgr.cpp', - 'fpdfsdk/fsdk_rendercontext.cpp', + 'fpdfsdk/fsdk_pauseadapter.cpp', 'public/fpdf_dataavail.h', 'public/fpdf_doc.h', 'public/fpdf_edit.h', @@ -235,6 +236,7 @@ 'type': 'static_library', 'sources': [ 'core/fpdfapi/cpdf_modulemgr.cpp', + 'core/fpdfapi/cpdf_pagerendercontext.cpp', 'core/fpdfapi/fpdf_cmaps/CNS1/Adobe-CNS1-UCS2_5.cpp', 'core/fpdfapi/fpdf_cmaps/CNS1/B5pc-H_0.cpp', 'core/fpdfapi/fpdf_cmaps/CNS1/B5pc-V_0.cpp', @@ -453,6 +455,7 @@ 'core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h', 'core/fpdfapi/fpdf_render/render_int.h', 'core/fpdfapi/include/cpdf_modulemgr.h', + 'core/fpdfapi/include/cpdf_pagerendercontext.h', ], }, { |