summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_progressive.cpp18
-rw-r--r--fpdfsdk/fpdfview.cpp40
-rw-r--r--fpdfsdk/fsdk_mgr.cpp4
-rw-r--r--fpdfsdk/include/fsdk_define.h1
-rw-r--r--fpdfsdk/include/fsdk_mgr.h3
-rw-r--r--fpdfsdk/include/fsdk_rendercontext.h5
6 files changed, 35 insertions, 36 deletions
diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp
index d42d954bb9..90e8402bf8 100644
--- a/fpdfsdk/fpdf_progressive.cpp
+++ b/fpdfsdk/fpdf_progressive.cpp
@@ -40,15 +40,16 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
return FPDF_RENDER_FAILED;
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
pContext->m_pDevice = new CFX_FxgeDevice;
- if (flags & FPDF_REVERSE_BYTE_ORDER)
+ if (flags & FPDF_REVERSE_BYTE_ORDER) {
((CFX_FxgeDevice*)pContext->m_pDevice)
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
+ } else {
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
- IFSDK_PAUSE_Adapter IPauseAdapter(pause);
+ }
+ IFSDK_PAUSE_Adapter IPauseAdapter(pause);
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
rotate, flags, FALSE, &IPauseAdapter);
@@ -68,7 +69,8 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,
if (!pPage)
return FPDF_RENDER_FAILED;
- CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
+ CRenderContext* pContext =
+ static_cast<CRenderContext*>(pPage->GetRenderContext());
if (pContext && pContext->m_pRenderer) {
IFSDK_PAUSE_Adapter IPauseAdapter(pause);
pContext->m_pRenderer->Continue(&IPauseAdapter);
@@ -83,11 +85,11 @@ DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) {
if (!pPage)
return;
- CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
+ CRenderContext* pContext =
+ static_cast<CRenderContext*>(pPage->GetRenderContext());
if (!pContext)
return;
pContext->m_pDevice->RestoreState();
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index cdcaba4318..bf7ae0f5c2 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -517,10 +517,6 @@ DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
return pPage ? pPage->GetPageHeight() : 0.0;
}
-void DropContext(void* data) {
- delete (CRenderContext*)data;
-}
-
#if defined(_WIN32)
DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
FPDF_PAGE page,
@@ -535,7 +531,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
return;
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
#if !defined(_WIN32_WCE)
CFX_DIBitmap* pBitmap = nullptr;
@@ -619,8 +615,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
if (bBackgroundAlphaNeeded || bHasImageMask)
delete pBitmap;
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
#endif // defined(_WIN32)
@@ -634,24 +629,25 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
int flags) {
if (!bitmap)
return;
+
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
+
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
pContext->m_pDevice = new CFX_FxgeDevice;
-
- if (flags & FPDF_REVERSE_BYTE_ORDER)
+ if (flags & FPDF_REVERSE_BYTE_ORDER) {
((CFX_FxgeDevice*)pContext->m_pDevice)
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
+ } else {
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
+ }
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
- rotate, flags, TRUE, NULL);
+ rotate, flags, TRUE, nullptr);
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
#ifdef _SKIA_SUPPORT_
@@ -661,33 +657,33 @@ DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return nullptr;
- std::unique_ptr<CRenderContext> pContext(new CRenderContext);
- pPage->SetPrivateData((void*)1, pContext.get(), DropContext);
+
+ CRenderContext* pContext = new CRenderContext;
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
CFX_FxgeDevice* skDevice = new CFX_FxgeDevice;
FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y);
pContext->m_pDevice = skDevice;
-
FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE,
- NULL);
- pPage->RemovePrivateData((void*)1);
+ nullptr);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
return recorder;
}
#endif
DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
+ UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
if (!page)
return;
#ifdef PDF_ENABLE_XFA
- CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
pPage->Release();
#else // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
- (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page);
+ static_cast<CPDFSDK_PageView*>(pPage->GetView());
if (pPageView && pPageView->IsLocked()) {
pPageView->TakeOverPage();
return;
}
- delete (CPDF_Page*)page;
+ delete pPage;
#endif // PDF_ENABLE_XFA
}
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index fac98d8aa3..83fee907d2 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -480,7 +480,7 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,
#endif // PDF_ENABLE_XFA
}
#ifndef PDF_ENABLE_XFA
- m_page->SetPrivateData((void*)m_page, (void*)this, nullptr);
+ m_page->SetView(this);
#endif // PDF_ENABLE_XFA
}
@@ -493,7 +493,7 @@ CPDFSDK_PageView::~CPDFSDK_PageView() {
m_fxAnnotArray.clear();
m_pAnnotList.reset();
#ifndef PDF_ENABLE_XFA
- m_page->RemovePrivateData((void*)m_page);
+ m_page->SetView(nullptr);
if (m_bTakeOverPage) {
delete m_page;
}
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index f3ed2da00f..536e35886f 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -109,7 +109,6 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
-void DropContext(void* data);
void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
void FPDF_RenderPage_Retail(CRenderContext* pContext,
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index ca46a069f1..a47f230c92 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -11,6 +11,7 @@
#include <memory>
#include <vector>
+#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/include/fsdk_actionhandler.h"
@@ -530,7 +531,7 @@ class CPDFSDK_Document {
FX_BOOL m_bBeingDestroyed;
};
-class CPDFSDK_PageView final {
+class CPDFSDK_PageView final : public CPDF_Page::View {
public:
CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
~CPDFSDK_PageView();
diff --git a/fpdfsdk/include/fsdk_rendercontext.h b/fpdfsdk/include/fsdk_rendercontext.h
index f984a64583..1bcd076466 100644
--- a/fpdfsdk/include/fsdk_rendercontext.h
+++ b/fpdfsdk/include/fsdk_rendercontext.h
@@ -8,14 +8,15 @@
#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 {
+class CRenderContext : public CFX_Deletable {
public:
CRenderContext() { Clear(); }
- ~CRenderContext();
+ ~CRenderContext() override;
void Clear();