summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_ext.cpp31
-rw-r--r--fpdfsdk/fpdf_progressive.cpp18
-rw-r--r--fpdfsdk/fpdfview.cpp48
-rw-r--r--fpdfsdk/fsdk_pauseadapter.cpp16
-rw-r--r--fpdfsdk/fsdk_rendercontext.cpp37
-rw-r--r--fpdfsdk/include/fsdk_define.h4
-rw-r--r--fpdfsdk/include/fsdk_pauseadapter.h25
-rw-r--r--fpdfsdk/include/fsdk_rendercontext.h41
8 files changed, 85 insertions, 135 deletions
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_